jussara
asked on
Taskbar Buttom to modal form application
Hello !
My App is composed of severals modal form dialogs called in sequence in sub main. Theses forms hide then taskbar button.
How to show tasbar app butto if I using modal form dialogs?
thanks
My App is composed of severals modal form dialogs called in sequence in sub main. Theses forms hide then taskbar button.
How to show tasbar app butto if I using modal form dialogs?
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry again, I really should try these things out before answering sometimes. You need to put the .left and call of main in the form_gotfocus event not the form_load event otherwise the taskbar button will still not appear as it has not been fully created.
No.
Modal forms will NOT be shown in the task bar no matter what you do.
Modal forms will NOT be shown in the task bar no matter what you do.
I agree that modal forms will not be shown, but at least my workaround does allow for something to be shown in the taskbar. I may not have made this sufficiently clear, but then as is sometimes my failing I type first and think later.
Yes, I see...
OK, the best workaround would be to show the main form Modelessly, and show all other forms modal on the main form.
That way the main form can give the application the taskbar icon it needs. As the main form is <cough> the MAIN form of the application there is no difference between showing it modally or modelessly anyway.
If you don't have a main form in your application your only option is to go for a rather nasty workaround, such as the one TimCottee is suggesting. Give your form a border style of 0 - None, and simply set the height and/or the width of the form to 0 in the Form_Load procedure. I don't think you even need to bother moving it off the screen. Make sure the form has a caption though; even though it is not visible at design time the caption is what determines the text shown in the taskbar icon. And make sure the ShowInTaskbar property is set to true. VB kindly (?) switches it to False when you set a form's borderstyle to 0 - None.
OK, the best workaround would be to show the main form Modelessly, and show all other forms modal on the main form.
That way the main form can give the application the taskbar icon it needs. As the main form is <cough> the MAIN form of the application there is no difference between showing it modally or modelessly anyway.
If you don't have a main form in your application your only option is to go for a rather nasty workaround, such as the one TimCottee is suggesting. Give your form a border style of 0 - None, and simply set the height and/or the width of the form to 0 in the Form_Load procedure. I don't think you even need to bother moving it off the screen. Make sure the form has a caption though; even though it is not visible at design time the caption is what determines the text shown in the taskbar icon. And make sure the ShowInTaskbar property is set to true. VB kindly (?) switches it to False when you set a form's borderstyle to 0 - None.
If you use normal forms set as dialogs, you can show the icon of a titleless form in the taskbar using API.
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_STYLE = (-16)
Private Const WS_SYSMENU = &H80000
'<<<<<< Form load >>>>>>
Private Sub Form_Load()
Call SetWindowLong(Me.hwnd, GWL_STYLE, WS_SYSMENU)
End Sub
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_STYLE = (-16)
Private Const WS_SYSMENU = &H80000
'<<<<<< Form load >>>>>>
Private Sub Form_Load()
Call SetWindowLong(Me.hwnd, GWL_STYLE, WS_SYSMENU)
End Sub
No.... that will NOT work for modal dialogs. Trust me ;-).
And if you don't, try it:
Form module
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 Const GWL_STYLE = (-16)
Private Const WS_SYSMENU = &H80000
Private Sub Form_Load()
Dim lngOld As Long
lngOld = GetWindowLong(Me.hwnd, GWL_STYLE)
SetWindowLong Me.hwnd, GWL_STYLE, lngOld Or WS_SYSMENU
End Sub
Main module:
Option Explicit
Private Sub main()
Form1.Show vbModal
End Sub
And if you don't, try it:
Form module
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 Const GWL_STYLE = (-16)
Private Const WS_SYSMENU = &H80000
Private Sub Form_Load()
Dim lngOld As Long
lngOld = GetWindowLong(Me.hwnd, GWL_STYLE)
SetWindowLong Me.hwnd, GWL_STYLE, lngOld Or WS_SYSMENU
End Sub
Main module:
Option Explicit
Private Sub main()
Form1.Show vbModal
End Sub
You're right...I forgot about the form having to be modal...
Wayne
Wayne
ASKER
Well, I try all.
TimCotte's sugestions works well to my dirty job. The Juillet's comment don't work if that form is modal opened with the Sub Main.
Thank You.
TimCotte's sugestions works well to my dirty job. The Juillet's comment don't work if that form is modal opened with the Sub Main.
Thank You.
One way around this is: Create an empty form with no border and very small, with nothing on it, but make sure that showintaskbar is still true (it may change depending on various other properties). In the form_load event, set the .left = -20000 to move it out of the visible range of the screen.Then call Main.