Set The ShowInTaskBar Property At Runtime
Preparations
Add 2 Command Buttons to your
form.
Module Code
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
Form Code
Private Sub Command1_Click()
Call
setShowInTaskbar(True, Me.hwnd)
End Sub
Private Sub
Command2_Click()
Call setShowInTaskbar(False, Me.hwnd)
End Sub