Link to home
Create AccountLog in
Avatar of bvanmatre1
bvanmatre1

asked on

How do I minimize the main form but stil keep a taskbar icon?

I am using C++ builder 2007.  I have an application that starts with a main form, but opens sub-forms.  I'd like to do something like the following from the main form:

...
TMyForm* f = new TMyForm(this);
Visible=false;
f->ShowModal()
Visible=true;
...

When I do this, however, the task bar icon for my application goes away.  Minimizing the TMyForm puts it into a little icon above the start button.  

I want to keep a single taskbar icon for my application even if I set the main form to not be visible.  How do I do such a thing?
SOLUTION
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of bvanmatre1
bvanmatre1

ASKER

The problem with this method is that the modal form (the HelpAboutForm in the snippet you posted) is behind all other windows, since the main form for the application is minimized.  If a user has any other windows open, the modal form comes up behind them.  Even calling 'BringToFront() and / or SetFocus() in the activate event of the modal form does not bring it to focus.  Not even Application->BringToFront() works.

Am I just out of luck here?  It seems there should be a way to do this.

What if you muddle with a few of the main controls?  Set Height to 0 and BorderStyle to bsNone.  (Being sure to save and restore the original values.


Kent
Try minimize instead of visible...

George Tokas.
gtokas:  that's exactly what Kdo already said.

 While not a perfect solution, it is better than what I had.  I'm going to wait a day and see if someone can tell me how to force 'focus'  back to my application so that 'child' modal forms show up on top of other applications' windows even when the main form is minimized.  If someone can help me with that, they'll split the points with Kdo.  Otherwise, he'll get them tomorrow.  Thanks for the help so far!
The modal form has focus untill you close it and sends the focus back to calling form...
In front of any other app can be done partially controling the FormStyle property of the form....
Total top most usually can fail...
In example no application can be on top of Task Manager of windows...
By that I mean that there are ways other apps suppress the on top of your form...
Form Style property will serve you well I hope, without the need of any other API call

George Tokas.

P.S. Sorry Kent... Using Direct3D make me forget that there isn't anywhere Form->minimize...
Just Application->minimize....
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
>>Here's another "odd" idea.
GOOD..:-))
It will be best if the modal form has the Position property to poDesktopCenter to be allways displayed at the center of the screen....

George Tokas.

"odd", "good"....

In my code it's often hard to differentiate.   :)


Hi George,

Send me an update on "life as George" when you get a chance.


Kent
Thanks for the help.  A clever idea, that!
Thanks both of you for the help.  Points to Kent since he had the minimize idea first, and the 'hidden' idea too.  I appreciate it!
>>Points to Kent since
I agree totaly...:-)