Order Entry macro problem

Hi,

I have created a macro for OE Entry using VBA, and have created a shortcut in “Order Entry” directory in the Sage 300 ERP. But, The question are

- Now there are 2 icons, the original and the macro. how I can hide the original icon, without changing the user permission?

- The macro is unable to show in the Windows task bar, so if the user open another window, the user has difficulty to find the macro window.

- The macro doesn't have minimize and maximize button, how to show these buttons?

Thanks,

David

  • 0
    1. You need the SDK to customize the desktop to remove icons
    2.

    Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    Private Declare Function GetActiveWindow Lib "user32.dll" () As Long
    Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long

    Private Const GWL_STYLE As Long = (-16)
    Private Const WS_SYSMENU As Long = &H80000
    Private Const WS_MINIMIZEBOX As Long = &H20000
    Private Const WS_MAXIMIZEBOX As Long = &H10000
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_NOSIZE = &H1
    Private Const GWL_EXSTYLE = (-20)
    Private Const HWND_TOP = 0
    Private Const SWP_NOACTIVATE = &H10
    Private Const SWP_HIDEWINDOW = &H80
    Private Const SWP_SHOWWINDOW = &H40
    Private Const WS_EX_APPWINDOW = &H40000
    Private Const SWP_FRAMECHANGED = &H20
    Private Const WM_SETICON = &H80
    Private Const ICON_SMALL = 0&
    Private Const ICON_BIG = 1&

    Private Sub AddMinimizeButton()
    Dim hwnd As Long
    hwnd = GetActiveWindow
    Call SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX)
    Call SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOSIZE)
    End Sub

    Private Sub AppTasklist(myForm)
    Dim WStyle As Long
    Dim Result As Long
    Dim hwnd As Long

    hwnd = FindWindow(vbNullString, myForm.Caption)
    WStyle = GetWindowLong(hwnd, GWL_EXSTYLE)
    WStyle = WStyle Or WS_EX_APPWINDOW
    Result = SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE Or SWP_HIDEWINDOW)
    Result = SetWindowLong(hwnd, GWL_EXSTYLE, WStyle)
    Result = SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE Or SWP_SHOWWINDOW)
    End Sub

    Sub TaskBarIconSet(lFormHwnd As Long, Optional lHwndIcon As Long, Optional sIconPath As String, Optional lIconIndex As Long = 0)
    Const WM_GETICON = &H7F, WM_SETICON = &H80, ICON_BIG = 1, GWL_HWNDPARENT As Long = (-8)
    Dim lHwndTopMost As Long, lTestHwnd As Long

    If lHwndIcon = 0 Then
    'Get the handle to the icon
    lHwndIcon = ExtractIcon(0, sIconPath, lIconIndex)
    End If

    ' Get the topmost window handle
    lHwndTopMost = lFormHwnd
    lTestHwnd = GetWindowLong(lFormHwnd, GWL_HWNDPARENT)
    Do While lTestHwnd <> 0
    lHwndTopMost = lTestHwnd
    lTestHwnd = GetWindowLong(lHwndTopMost, GWL_HWNDPARENT)
    Loop

    'Set the task bar icon for the topmost window
    SendMessage lHwndTopMost, WM_SETICON, ICON_BIG, ByVal lHwndIcon
    End Sub

    Private Sub UserForm_Activate()
    AddMinimizeButton
    AppTasklist Me
    Dim hwnd As Long
    hwnd = GetActiveWindow
    TaskBarIconSet hwnd, , a4wLink.Session.ProgramsPathOnServer & "\Runtime\a4wmacd.exe", 0

    End Sub
  • 0 in reply to Jay Converse Acumen
    Hi Jay,

    That's very helpful.
    Thank you very much.