Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simulating an OnAfterShow event

0 views
Skip to first unread message

Paul Coshott

unread,
Jun 28, 2002, 12:09:36 AM6/28/02
to
Hi,

Delphi 5 pro.
I often want to autoamtically run some code directly after the form has
shown. If this is done in the OnShow event it gets done while the form is
still invisible (not good if the code takes a little while to run.)
Currently, I use a Timer with its interval property set to about 200 and
enabled set to false. In the OnShow event I set Timer.Enabled := True and
the first statement in the OnTimer event is Timer.Enabled := False so the
event only runs once.

BUT knowing delphi, there is probably a much nicer way to do this. Any ideas
?

--

Cheers,
Paul
PAC Software Solutions

www.pacsoftware.com.au
pa...@pacsoftware.com.au


Dave

unread,
Jun 28, 2002, 12:37:49 AM6/28/02
to

"Paul Coshott" <pa...@pacsoftware.com.au> wrote in message
news:3d1be183_2@dnews...

Sure,
Post a message to yourself.

Dave

Paul Coshott

unread,
Jun 28, 2002, 12:39:11 AM6/28/02
to
Hi Dave,

could you maybe give me an example of how to do this ?

--

Cheers,
Paul
PAC Software Solutions

www.pacsoftware.com.au
pa...@pacsoftware.com.au


"Dave" <dgsom...@bigpond.com> wrote in message news:3d1be81e_1@dnews...

Thomas Stutz

unread,
Jun 28, 2002, 1:02:23 AM6/28/02
to
> > > I often want to autoamtically run some code directly after the form
has
> > > shown.

> > Post a message to yourself.

Hi,

Use this code to post a custom message to yourself.

const
WM_AFTER_SHOW = WM_USER + 300; // custom message

type
TForm1 = class(TForm)
procedure FormShow(Sender: TObject);
private
procedure WmAfterShow(Var Msg: TMessage); message WM_AFTER_SHOW;
public
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.WmAfterShow(var Msg: TMessage);
begin
ShowMessage('WM_AFTER_SHOW received!');
end;

procedure TForm1.FormShow(Sender: TObject);
begin
// Post the custom message to our form
PostMessage(Self.handle, WM_AFTER_SHOW, 0, 0);
end;

HTH

tom

Paul Coshott

unread,
Jun 28, 2002, 1:05:31 AM6/28/02
to
Thanks Dave and Thomas.

--

Cheers,
Paul
PAC Software Solutions

www.pacsoftware.com.au
pa...@pacsoftware.com.au


"Thomas Stutz" <t...@swissdelphicenter.ch> wrote in message
news:3d1bede7$1_2@dnews...

Paul Coshott

unread,
Jun 28, 2002, 12:09:36 AM6/28/02
to
Hi,

Delphi 5 pro.


I often want to autoamtically run some code directly after the form has

shown. If this is done in the OnShow event it gets done while the form is
still invisible (not good if the code takes a little while to run.)
Currently, I use a Timer with its interval property set to about 200 and
enabled set to false. In the OnShow event I set Timer.Enabled := True and
the first statement in the OnTimer event is Timer.Enabled := False so the
event only runs once.

BUT knowing delphi, there is probably a much nicer way to do this. Any ideas
?

--

Thomas Stutz

unread,
Jun 28, 2002, 1:02:23 AM6/28/02
to
> > > I often want to autoamtically run some code directly after the form
has
> > > shown.

> > Post a message to yourself.

Hi,

Dave

unread,
Jun 28, 2002, 12:37:49 AM6/28/02
to

"Paul Coshott" <pa...@pacsoftware.com.au> wrote in message
news:3d1be183_2@dnews...

Sure,


Post a message to yourself.

Dave

Paul Coshott

unread,
Jun 28, 2002, 1:05:31 AM6/28/02
to
Thanks Dave and Thomas.

--

Cheers,
Paul
PAC Software Solutions

www.pacsoftware.com.au
pa...@pacsoftware.com.au


"Thomas Stutz" <t...@swissdelphicenter.ch> wrote in message
news:3d1bede7$1_2@dnews...

Paul Coshott

unread,
Jun 28, 2002, 12:39:11 AM6/28/02
to
Hi Dave,

could you maybe give me an example of how to do this ?

--

Cheers,
Paul
PAC Software Solutions

www.pacsoftware.com.au
pa...@pacsoftware.com.au


"Dave" <dgsom...@bigpond.com> wrote in message news:3d1be81e_1@dnews...
>

0 new messages