Results 1 to 8 of 8

Thread: Set/Get the ShowInTaskbar property for a window at runtime

Threaded View

  1. #1

    Thread Starter
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Set/Get the ShowInTaskbar property for a window at runtime

    VB Code:
    1. 'You need 2 command buttons 'cmdToggle' and 'cmdCheck'
    2.  
    3. Option Explicit
    4.  
    5. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
    6.     (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    7.    
    8. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    9.     (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    10.  
    11. Private Declare Function ShowWindow Lib "user32" _
    12.     (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    13.    
    14. Private Const GWL_EXSTYLE = (-20)
    15. Private Const WS_EX_APPWINDOW = &H40000
    16.  
    17. Const SW_HIDE = 0
    18. Const SW_NORMAL = 1
    19.  
    20. Private Sub ShowInTheTaskbar(hwnd As Long, bShow As Boolean)
    21.     Dim lStyle As Long
    22.    
    23.     ShowWindow hwnd, SW_HIDE
    24.    
    25.     lStyle = GetWindowLong(hwnd, GWL_EXSTYLE)
    26.    
    27.     If bShow = False Then
    28.         If lStyle And WS_EX_APPWINDOW Then
    29.             lStyle = lStyle - WS_EX_APPWINDOW
    30.         End If
    31.     Else
    32.         lStyle = lStyle Or WS_EX_APPWINDOW
    33.     End If
    34.    
    35.     SetWindowLong hwnd, GWL_EXSTYLE, lStyle
    36.    
    37.     App.TaskVisible = bShow
    38.    
    39.     ShowWindow hwnd, SW_NORMAL
    40. End Sub
    41.  
    42. Private Function IsVisibleInTheTaskbar(hwnd As Long) As Boolean
    43.     Dim lStyle As Long
    44.    
    45.     lStyle = GetWindowLong(hwnd, GWL_EXSTYLE)
    46.    
    47.     If lStyle And WS_EX_APPWINDOW Then
    48.         IsVisibleInTheTaskbar = True
    49.     End If
    50. End Function
    51.  
    52. Private Sub cmdToggle_Click()
    53.     Static bVisible As Boolean
    54.    
    55.     bVisible = Not IsVisibleInTheTaskbar(Me.hwnd)
    56.    
    57.     ShowInTheTaskbar Me.hwnd, bVisible
    58. End Sub
    59.  
    60. Private Sub Form_Load()
    61.     cmdToggle.Caption = "Toggle visibility"
    62.     cmdCheck.Caption = "Check visibility"
    63. End Sub
    Last edited by manavo11; Aug 25th, 2005 at 08:49 PM.


    Has someone helped you? Then you can Rate their helpful post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width