Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To show modal forms in TaskBar 1

Status
Not open for further replies.

cdls

Programmer
Sep 7, 2001
15
0
0
AU
Hi,
I would like to show a modal form in taskbar. Is it possible to do in Visual Basic? I have form1 which appears in the Taskbar.This form hides itself and calls form2 modally and form2 appears in the taskbar.When form2 is closed, it gets unloaded and form1 gets shown modally, but now form1 does not appear in the taskbar.
Can anybody let me know how to show modal forms in the taskbar? Is there any Windows API function which can display a form in the taskbar?

Thanks in Advance.
 
This piece of code may be of assistance:
[tt]
' Credit to Deborah L. Cooper at Inside Visual Basic
Option Explicit
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow 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 Const GWL_EXSTYLE = (-20)
Public Const WS_EX_APPWINDOW = &H40000 ' The magic constant!
Public Const SW_HIDE = &H0
Public Const SW_SHOW = &H5


Public Sub ToggleTaskbarButton(hWnd As Long)
Dim lCurrent As Long
Dim lAppWin As Long

lCurrent = GetWindowLong(hWnd, GWL_EXSTYLE)

If lCurrent And WS_EX_APPWINDOW Then
lAppWin = lCurrent And (Not WS_EX_APPWINDOW) ' OK, claim not to be an application window, which means we don't appear on task bar
Else
lAppWin = lCurrent Or WS_EX_APPWINDOW ' OK, claim to be an application window, which means we appear on task bar
End If

' We need to hide, set, and show for new setting to work.
ShowWindow hWnd, SW_HIDE
SetWindowLong hWnd, GWL_EXSTYLE, lAppWin
ShowWindow hWnd, SW_SHOW
End Sub
 
Thanks a lot, I used the WIndows API functions that you had mentioned and it worked. It was very useful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top