VB Code:
'You need 2 command buttons 'cmdToggle' and 'cmdCheck' 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 GWL_EXSTYLE = (-20) Private Const WS_EX_APPWINDOW = &H40000 Const SW_HIDE = 0 Const SW_NORMAL = 1 Private Sub ShowInTheTaskbar(hwnd As Long, bShow As Boolean) Dim lStyle As Long ShowWindow hwnd, SW_HIDE lStyle = GetWindowLong(hwnd, GWL_EXSTYLE) If bShow = False Then If lStyle And WS_EX_APPWINDOW Then lStyle = lStyle - WS_EX_APPWINDOW End If Else lStyle = lStyle Or WS_EX_APPWINDOW End If SetWindowLong hwnd, GWL_EXSTYLE, lStyle App.TaskVisible = bShow ShowWindow hwnd, SW_NORMAL End Sub Private Function IsVisibleInTheTaskbar(hwnd As Long) As Boolean Dim lStyle As Long lStyle = GetWindowLong(hwnd, GWL_EXSTYLE) If lStyle And WS_EX_APPWINDOW Then IsVisibleInTheTaskbar = True End If End Function Private Sub cmdToggle_Click() Static bVisible As Boolean bVisible = Not IsVisibleInTheTaskbar(Me.hwnd) ShowInTheTaskbar Me.hwnd, bVisible End Sub Private Sub Form_Load() cmdToggle.Caption = "Toggle visibility" cmdCheck.Caption = "Check visibility" End Sub




Reply With Quote