Private Declare Function ShowWindow Lib "User32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
API VBA SHOWWINDOW WINDOWS
'we need to use the Use32.dll Windows API to get the two required functions
API VBA SHOWWINDOW CODE
Use the code below, I will explain what each bit is for in the code comments. To hide the task bar using VBA, get into the VBA editor by clicking ALT+F11 and create a new module. 'Returns the value from the AddressOf unary operator.Let's say you want to hide Windows task bar for some reason, this is the bar at the bottom of your screen where all the running applications are displayed. TranslateMessage tmessage 'Translate virtual-key messages into character messages (character messages are posted to the calling thread's message queue).ĭispatchMessage tmessage 'Dispatch message to window procedure (WindowProc) MsgBox "Could not open window - GetLastError reports " + Str(lres)ĭo While 0 GetMessage(tmessage, 0&, 0&, 0&) 'Retrieve a message from the calling thread’s message queue ' a_hWnd = CreateWindowEx(ByVal 0&, "STATIC", "TEST", WS_BORDER Or WS_CAPTION Or WS_POPUP, 20, 20, 324, 290, ByVal 0&, ByVal 0&, hInst, ByVal 0&) Wc.hIconSm = LoadIcon(0&, IDI_APPLICATION) Wc.hbrBackground = GetStockObject(BLACK_BRUSH) Wc.lpfnWndProc = FunctionPointer(AddressOf WndProc) Private Const IDI_APPLICATION As Long = 32512&
API VBA SHOWWINDOW 32 BIT
Private Type WNDCLASSEX 'size=48/56 on 32 bit and 80 on 64 bit? Private Declare PtrSafe Function DispatchMessage Lib "user32" Alias "DispatchMessageA" (lpMsg As MSG) As Long Private Declare PtrSafe Function TranslateMessage Lib "user32" (lpMsg As MSG) As Long Public Declare PtrSafe Function GetMessage Lib "user32" Alias "GetMessageA" (lpMsg As MSG, ByVal lhwnd As LongPtr, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr Private Declare PtrSafe Function GetLastError Lib "kernel32" () As Long Private Declare PtrSafe Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As LongPtr Private Declare PtrSafe Function ShowCursor Lib "user32" (ByVal fShow As Long) As Long Private Declare PtrSafe Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As LongPtr, ByVal lpCursorName As Any) As LongPtr Private Declare PtrSafe Function LoadIcon Lib "user32" Alias "LoadIconA" (ByVal hInstance As LongPtr, ByVal lpIconName As Any) As LongPtr Private Declare PtrSafe Function DefWindowProc Lib "user32" Alias "DefWindowProcA" (ByVal lhwnd As LongPtr, ByVal wMsg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As Long Private Declare PtrSafe Function UnregisterClass Lib "user32" Alias "UnregisterClassA" (ByVal lpClassName As String, ByVal hInstance As LongPtr) As Long Private Declare PtrSafe Function RegisterClassEx Lib "user32" Alias "RegisterClassExA" (pcWndClassEx As WNDCLASSEX) As Long Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal lhwnd As LongPtr, ByVal nCmdShow As Long) As Long Private Declare PtrSafe Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As LongPtr, ByVal hMenu As LongPtr, ByVal hInstance As LongPtr, lpParam As Any) As LongPtrPrivate Declare PtrSafe Function DestroyWindow Lib "user32" (ByVal hWnd As LongPtr) As Long