Link to home
Start Free TrialLog in
Avatar of matrixworld
matrixworld

asked on

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

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.
Avatar of kretzschmar
kretzschmar
Flag of Germany image

?? what for a message
- which components you have?
- are connected special messages to this components?
wbr Janos
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
ASKER CERTIFIED SOLUTION
Avatar of geobul
geobul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of matrixworld
matrixworld

ASKER

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
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
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