BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sample Code For Minimizing An Application With Multiple Form

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Gary Gee
Guest





PostPosted: Sun Nov 16, 2003 7:36 am    Post subject: Sample Code For Minimizing An Application With Multiple Form Reply with 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.

Thanks,

Gary


Back to top
Rob Kennedy
Guest





PostPosted: Sun Nov 16, 2003 8:09 am    Post subject: Re: Sample Code For Minimizing An Application With Multiple Reply with quote



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





PostPosted: Sun Nov 16, 2003 8:36 am    Post subject: Re: Sample Code For Minimizing An Application With Multiple Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.