CodeItBetter Programming Another VB Programming Blog

How to Set the ShowInTaskBar Property 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
'Forms - How to Set the ShowInTaskBar Property at Runtime

Option Explicit
 
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, _
    ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, _
    ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Const SW_HIDE = 0
Public Const SW_SHOW = 5
Public Const GWL_EXSTYLE = (-20)
Public Const WS_EX_TOOLWINDOW = &H80&
 
Public Sub setShowInTaskbar(Visible As Boolean, hwnd As Long)
    Dim L As Long
    L = ShowWindow(hwnd, SW_HIDE)
    DoEvents
    L = SetWindowLong(hwnd, GWL_EXSTYLE, IIf(Visible, -WS_EX_TOOLWINDOW, WS_EX_TOOLWINDOW))
    DoEvents
    L = ShowWindow(hwnd, SW_SHOW)
End Sub
 
Private Sub Command1_Click()
   Call setShowInTaskbar(True, Me.hwnd)
End Sub
 
Private Sub Command2_Click()
   Call setShowInTaskbar(False, Me.hwnd)
End Sub
Filed under: Forms Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.