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(TFo rm1, Form1);
Application.Run;
but still cannot display my message first before other messages.
Anyone can help me in this problem ? Thanks.
example I try to add like this
showmessage('I'm the 1st Message');
Application.Initialize;
Application.CreateForm(TFo
Application.Run;
but still cannot display my message first before other messages.
Anyone can help me in this problem ? Thanks.
?? what for a message
- which components you have?
- are connected special messages to this components?
wbr Janos
- 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
There are 3 Buttons on Form1 having each of them fast the same message:
procedure TForm1.Button1Click(Sender
begin
showmessage('I am the Button1');
end;
procedure TForm1.Button2Click(Sender
begin
showmessage('I am the Button2');
end;
procedure TForm1.Button3Click(Sender
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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
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
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
ASKER
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
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