Show/Hide the System Tray

This a good and short code to show and hide the Windows Tray.
It compatible with VB6 and also .net

Declaration :
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
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Const Tray_SHOW = 5
Private Const Tray_HIDE = 0
Dim Trayhwnd As Long
Code :
Private Sub Form_Load()
Trayhwnd = FindWindow("Shell_TrayWnd", "")
Trayhwnd = FindWindowEx(Trayhwnd, 0, "TrayNotifyWnd", vbNullString)
ShowWindow Trayhwnd, Tray_HIDE 'To Hide
'To show the System Tray add this code insteed of above
'ShowWindow Trayhwnd, Tray_SHOW 'To Show
End Sub

0 comments:

Post a Comment