Attribute VB_Name = "Place_Form_Icon_On_Task_Bar" '''''''''''''''' ' PlaceOnTaskBar.bas ' ' 03-16-99 Robert Clemenzi ' '''''''''''''''' ' ' PlaceOnTaskBar is based on code from comp.lang.basic.visual.misc ' When Alt-Tab is used to switch applications (windows), ' only those windows included on the TaskBar are available. ' Unfortunately, only the first form in an application is automatically ' added to the task bar. If you hide the main form and display a ' secondary form, neither form appears in the Task Bar and there is no ' way to use Alt-Tab to find the secondary form. ' The PlaceOnTaskBar subroutine solves this problem. ' 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 Const GWL_EXSTYLE = (-20) Private Const WS_EX_APPWINDOW = &H40000 Private Sub Example_Calls() ' PlaceOnTaskBar Me.hWnd, True ' PlaceOnTaskBar Me.hWnd, False End Sub Public Sub PlaceOnTaskBar(hWnd As Long, bFlag As Boolean) 'hWnd - handle of the window 'bFlag - True - Show on Task Bar ' False - Remove from Task Bar Dim lRetVal As Long 'Get the current style bits lRetVal = GetWindowLong(hWnd, GWL_EXSTYLE) If bFlag Then 'Modify the style bits to show on the task bar lRetVal = lRetVal Or WS_EX_APPWINDOW Else 'Modify the style bits to delete from the task bar lRetVal = lRetVal And Not WS_EX_APPWINDOW End If 'Set the new style bits lRetVal = SetWindowLong(hWnd, GWL_EXSTYLE, lRetVal) End Sub