 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Gary Gee Guest
|
Posted: Sun Nov 16, 2003 7:36 am Post subject: Sample Code For Minimizing An Application With Multiple Form |
|
|
I have an application that has a dummy main form. In the Main Form's
FormCreate event handler, I create one of several forms depending on a parm
passed on the command line, do a ShowModal of the form and then an
Application.Terminate when the form that I created is closed. What I want to
do is when the created form is minimized, minimize the whole application.
When the minimized application is clicked on the bottom taskbar, I'd like
the created form to be restored to the screen. Can someone post up some
sample code on how to do this? I'd be willing to pay for this.
Thanks,
Gary
|
|
| Back to top |
|
 |
Rob Kennedy Guest
|
Posted: Sun Nov 16, 2003 8:09 am Post subject: Re: Sample Code For Minimizing An Application With Multiple |
|
|
Gary Gee wrote:
| Quote: | I have an application that has a dummy main form. In the Main Form's
FormCreate event handler, I create one of several forms depending on
a parm passed on the command line, do a ShowModal of the form and
then an Application.Terminate when the form that I created is closed.
What I want to do is when the created form is minimized, minimize the
whole application. When the minimized application is clicked on the
bottom taskbar, I'd like the created form to be restored to the
screen. Can someone post up some sample code on how to do this? I'd
be willing to pay for this.
|
Is that really the entire purpose of the "dummy main form"? If so, then
I think there's a better way. Get rid of the dummy form and put your
command-line processing in your DPR file. Then, when you've determined
which of your several forms should be shown, use Application.CreateForm
to create and display it. CreateForm automatically assigns the first
created form to be the application's realy main form, and when the main
form closes, the application. is automatically terminated. Furthermore,
since the form will no longer be shown modally, you'll be able to
minimize the application.
var
Index: Integer;
begin
Application.Initialize;
Index := StrToInt(ParamStr(1));
case Index of
1: Application.CreateForm(TOneForm, OneForm);
2: Application.CreateForm(TTwoForm, TwoForm);
3: Application.CreateForm(TThreeForm, ThreeForm);
else Application.CreateForm(TDefaultForm, DefaultForm);
end;
Application.Run;
end.
I'll leave the error checking to you. :)
Beware that the IDE has its own idea of how the DPR file should be laid
out, so you might need to adjust the format of the CASE statement
slightly. (Actually, the IDE will adjust the layout, and you'll need to
find a compromise.) The IDE might get confused about which forms are
being auto-created.
--
Rob
|
|
| Back to top |
|
 |
Gary Gee Guest
|
Posted: Sun Nov 16, 2003 8:36 am Post subject: Re: Sample Code For Minimizing An Application With Multiple |
|
|
Rob,
This worked great!
Thanks,
Gary
"Rob Kennedy" <.> wrote
| Quote: | Gary Gee wrote:
I have an application that has a dummy main form. In the Main Form's
FormCreate event handler, I create one of several forms depending on
a parm passed on the command line, do a ShowModal of the form and
then an Application.Terminate when the form that I created is closed.
What I want to do is when the created form is minimized, minimize the
whole application. When the minimized application is clicked on the
bottom taskbar, I'd like the created form to be restored to the
screen. Can someone post up some sample code on how to do this? I'd
be willing to pay for this.
Is that really the entire purpose of the "dummy main form"? If so, then
I think there's a better way. Get rid of the dummy form and put your
command-line processing in your DPR file. Then, when you've determined
which of your several forms should be shown, use Application.CreateForm
to create and display it. CreateForm automatically assigns the first
created form to be the application's realy main form, and when the main
form closes, the application. is automatically terminated. Furthermore,
since the form will no longer be shown modally, you'll be able to
minimize the application.
var
Index: Integer;
begin
Application.Initialize;
Index := StrToInt(ParamStr(1));
case Index of
1: Application.CreateForm(TOneForm, OneForm);
2: Application.CreateForm(TTwoForm, TwoForm);
3: Application.CreateForm(TThreeForm, ThreeForm);
else Application.CreateForm(TDefaultForm, DefaultForm);
end;
Application.Run;
end.
I'll leave the error checking to you. :)
Beware that the IDE has its own idea of how the DPR file should be laid
out, so you might need to adjust the format of the CASE statement
slightly. (Actually, the IDE will adjust the layout, and you'll need to
find a compromise.) The IDE might get confused about which forms are
being auto-created.
--
Rob
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|