CodeItBetter Programming Another VB Programming Blog

How to Change the visibility of the app in the taskbar at runtime

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'System & API - How to Change the visibility of the app in the taskbar at runtime
Option Explicit
 
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 ShowWindow Lib "user32" (ByVal hWnd As Long, _
    ByVal nCmdShow As Long) As Long
Private Const SW_HIDE = 0
Private Const SW_SHOW = 5
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_APPWINDOW = &H40000
 
Private Sub TaskbarVisible(hWnd As Long, visible As Boolean)
    Dim wl As Long
    ShowWindow hWnd, SW_HIDE
    wl = GetWindowLong(hWnd, GWL_EXSTYLE)
    If visible = False Then
        wl = wl And Not WS_EX_APPWINDOW
    Else
        wl = wl Or WS_EX_APPWINDOW
    End If
    SetWindowLong hWnd, GWL_EXSTYLE, wl
    ShowWindow hWnd, SW_SHOW
End Sub
 
Private Sub cmdHide_Click()
    TaskbarVisible Me.hWnd, False
End Sub
 
Private Sub cmdShow_Click()
    TaskbarVisible Me.hWnd, True
End Sub
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.