VB Center | Code Library | Windows 95 / NT 4 Shell

Hide / Show the Windows Taskbar

Written exclusively for VB Center by Marco Cordero.


Start a new project. To the form, add the following command buttons.

Type Name Index Caption
       
Command Button cmdHide   Hide
Command Button cmdShow   Show

Place the following into the general declarations area of the form.

Option Explicit

Dim hwnd1 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 FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Const SWP_HIDEWINDOW = &H80

Const SWP_SHOWWINDOW = &H40


Add the following code to the form.

Private Sub cmdHide_Click()

' Hide the taskbar
hwnd1 = FindWindow("Shell_traywnd", "")
Call SetWindowPos(hwnd1, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)

End Sub

Private Sub cmdShow_Click()

' Show the taskbar
Call SetWindowPos(hwnd1, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)

End Sub


Now, press F5 to run the project. If you click the button labeled 'Hide', you will see the Windows Taskbar hide. By pressing the button labeled 'Show', the Windows Taskbar will be shown.

Back to Code Library - Windows 95 / NT 4 Shell

1