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
jussaraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimCotteeHead of Software ServicesCommented:
Check the ShowInTaskBar property of the forms. It should be True, though the default for a dialog form is normally false.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TimCotteeHead of Software ServicesCommented:
That was a bit of a snappy answer which probably won't work for you. The reason is that you are calling the dialogs from the sub main. Windows does not then recognise them as "unowned" windows and does not automatically create a taskbar icon for them. It won't do so even if you use a normal form.

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.

0
TimCotteeHead of Software ServicesCommented:
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.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

caraf_gCommented:
No.

Modal forms will NOT be shown in the task bar no matter what you do.
0
TimCotteeHead of Software ServicesCommented:
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.
0
caraf_gCommented:
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.
0
JuiletteCommented:
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

0
caraf_gCommented:
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
0
JuiletteCommented:
You're right...I forgot about the form having to be modal...

Wayne
0
jussaraAuthor Commented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.