Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to Create different MainForm by different parameter ?

Posted on 2002-06-24
10
Medium Priority
?
319 Views
Last Modified: 2010-04-04
1. How to Create different MainForm
by different parameter( ParamStr(i)... ) in an application ?

2. How to show some hints when mouse is over application name in System Appbar ?

0
Comment
Question by:sina2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 

Author Comment

by:sina2000
ID: 7103186
I think the two questions above are very easy ... waiting..  :*)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7103219
>1. How to Create different MainForm
>by different parameter( ParamStr(i)... ) in an >application ?

this may be handled in your projectsource like
if ParamStr(i) = 'Whatever' then
  Application.CreateForm(..
else
  Application.CreateForm(..
;

>2. How to show some hints when mouse is over application
>name in System Appbar ?

just provide an application.hint

meikl ;-)
0
 

Author Comment

by:sina2000
ID: 7103259
I use Delphi6 sp2 , the methods you said I have tried ...
But no effect ...  

:-(

1> When I compile my project , the IDE auto change my codes to :
    if (ParamStr(i) = 'u') then
        Application.CreateForm(TForm1,Form1);
    else
    ;

2> I set :

Application.Hint:=  'hints';
Application.ShowHint:= True;

But I still can't see the hint . :-(
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 27

Expert Comment

by:kretzschmar
ID: 7103305
hmm, bad,
i have no delphi on hand yet,
this evening i try myself,
if not solved until then

meikl ;-)
0
 
LVL 2

Expert Comment

by:Griffon
ID: 7104270
for the menu itself

form.menu.hint

and for the items on the menu it is

form.menu.item.hint

if that is any help
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7106714
hmm, not so easy as i guessed :-(
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7106751
well,

you can't switch the mainform,
but you could use a dummy-hidden mainform
and then decide, which form is shown

just as idea

meikl ;-)
0
 

Author Comment

by:sina2000
ID: 7106869

Thanks. I know that :
>>Application.ShowMainForm:= false;
But I want to know if an application can switch MainForm -creating in runtime . I am in study. :-)

And, Application.Hint doesn't affects application's  
name in System Appbar ...

0
 
LVL 7

Accepted Solution

by:
Cynna earned 548 total points
ID: 7113903
sina2000,

(1)
> But I want to know if an application can switch MainForm -creating in runtime

Well... no, it really can't. Main form is just a form
as any other. The only difference is that, when you
close main form, you actually terminated your application.
Any other form can be closed and opened at will.
The first form that application create is the main form.

So, there are two ways to approach your problem, as
kretzschmar suggested. I don't quite undertand what you
want, so I'll try explaining both.
For clarity, lets take example of application Project1, with 3 forms: Form1, Form2, Form3.

a) You can choose your 'real' main form ONLY ONCE, simply
   by picking which form gets created first. But once
   first form is created, that's it - you can't change
   it any more.
 
   Example
   -------------
   Assume that if 1. parameter is 'u', Form1 is main form,
   if not, Form2 will be the main form.
   Go to Project1.dpr page and change auto-generated code
   to this:

begin
  Application.Initialize;
  if (ParamStr(0) = 'u') then begin
     Application.CreateForm(TForm1, Form1);
     Application.CreateForm(TForm2, Form2);
  end
  else begin
     Application.CreateForm(TForm2, Form2);
     Application.CreateForm(TForm1, Form1);
  end;
  Application.CreateForm(TForm3, Form3);
  Application.Run;
end.


b) If you need to change your main form later, you can
   do a bit clumsy trick. Since only difference between
   main form and any other occures during close, you
   could ensure that your 'real' main form is 'dummy-form'
   that stays open, but hidden during application
   lifecycle. All you have to do then, is to close it from
   OnClose event of the form you wish to make 'main'.

   To make things a bit more clearer, I'll use example
   of 3 forms. Form1 will be 'dummy-form', that is real  
   main form, but is kept hidden. Form2 or Form3 can
   be made 'main' form anytime you want.

   Example
   -------------

   1. Make Form1 (real main form) hidden:
      - set its Visible property to FALSE
      - before Application.Run in Project1.dpr add line:
           Application.ShowMainForm:=FALSE;

   2. Add global variable 'MainFormIndex: Integer' in Project1.dpr

   3. Set it to 2 or 3 from anywhere in your application
      Use its value to determine what form will be treated
      as main form (ie, close application when it's closed)
 
   4. Add OnClose events of Form2 and Form3:
     
       procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
       begin
         // If this is our main form, then closing it means closing real main form:
         if MainFormIndex=2 then Form1.Close;
       end;
       
       procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
       begin
         // If this is our main form, then closing it means closing real main form:
         if MainFormIndex=3 then Form1.Close;
       end;



> And, Application.Hint doesn't affects application's name in System Appbar ...

'System Appbar's hint' is auto-assigned by OS, and you
can't do anything to change it to anything different then
your application title.
Therefore, if you need application 'hint' to change, do:

     Application.Title:='My hint';




0
 

Author Comment

by:sina2000
ID: 7115504
Many thanks . :)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question