How to display a message before other component display it own message ?

matrixworld
matrixworld used Ask the Experts™
on
I have 3 components, if I add it to a form, it always display each own message when open the application before display my own message, how can i add a message before other components display it own message ?

example I try to add like this

  showmessage('I'm the 1st Message');
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;

but still cannot display my message first before other messages.
Anyone can help me in this problem ? Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2004

Commented:
?? what for a message
kacorretired

Commented:
- which components you have?
- are connected special messages to this components?
wbr Janos
kacorretired

Commented:
I made for you a simple demoproject:
There are 3 Buttons on Form1 having each of them fast the same message:

procedure TForm1.Button1Click(Sender: TObject);
begin
   showmessage('I am the Button1');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   showmessage('I am the Button2');
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
   showmessage('I am the Button3');
end;

And they appear after pressing the buttons.
But I created the first message too connected to the On Create event of the form which appears before creating the form1:

procedure TForm1.FormCreate(Sender: TObject);
begin
   showmessage('I am the 1st message');
end;

Otherwise your statement
        showmessage('I'm the 1st Message');
is wrong because you have to doble the ' character:
        showmessage('I''m the 1st Message');

I hope I could help

wbr
Janos
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Hi,

Add this at the end of your main form:

initialization
  showmessage('I''m the 1st Message');

end.

Regards, Geo

Author

Commented:
Hi Geo,
   your method is working unless I create a component with initialization and then place it before other components under uses call, is that any possible to do it before the uses call ? Thanks & Regards.
Hi,

Make a new unit with the code above only and add that unit on the first place in main form's uses clause.

Regards, Geo
ttd

Commented:
Hi,

Try to debug your application from the very first step by pressing F7 in the IDE, you will learn how units will be initialized, which order components are created in, and so on. You will found the right place to put your message. Very simple, isn't it?

Regards,

ttd

Author

Commented:
Hi Geo,

   How can I set a variable under initialization example like below

initialization
  sTest := 'This is testing';
  showmessage('I''m the 1st Message');


Thanks & Regards,
Peter Oh

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial