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

Custom Event Handler on a button instantiated at runtime

120 views
Skip to first unread message

JakeBaze

unread,
Jan 19, 2001, 4:51:47 PM1/19/01
to
Hi Newsgroup,

How does one assign a handler to handle the OnClick event of a button that
is created at runtime?
The button will be on a component
(Delphi 5)

Many thanks.

Jake Baze


Ing. Wolfgang Bures

unread,
Jan 19, 2001, 5:18:28 PM1/19/01
to
After you have created the button use
Button.OnClick:=MyClick;

With MyClick beeing defined like a normal event creted in the IDE

Procedure TForm.MyClick(Sender:TObject);

"JakeBaze" <jb...@fenix2.dol-esa.gov> schrieb im Newsbeitrag
news:01c08261$ede636e0$7fc4c8c7@jboon...

Markus Dommann

unread,
Jan 19, 2001, 5:23:31 PM1/19/01
to JakeBaze
Just do something like:

procedure TMyObject.MyOnClick(Sender: TObject);

...

var
MyButton: TButton;

...

MyButton := TButton.Create(Owner);
MyButton.OnClick := MyOnClick;

That's all

JakeBaze

unread,
Jan 19, 2001, 5:35:39 PM1/19/01
to
Seems logical, yet I get this fatal error:
Incompatible types: 'TNotifyEvent' and 'procedure, untyped pointer or
untyped parameter'
-Jake

> Button.OnClick:=MyClick;

JakeBaze

unread,
Jan 19, 2001, 5:37:27 PM1/19/01
to
Yes, but ....
I get this error: Incompatible types: 'TNotifyEvent' and 'procedure,
untyped pointer or untyped parameter' ;
Thanks. - Jake


Markus Dommann <mdom...@postweb.net> wrote in article
<3A68BE63...@postweb.net>...
> Just do something like:

> MyButton.OnClick := MyOnClick;

Markus Dommann

unread,
Jan 19, 2001, 6:15:35 PM1/19/01
to JakeBaze
Are you sure the procedure that should process the event is not a normal
procedure but a method of an object? I can't get any error message
otherwise.

Markus

Ing. Wolfgang Bures

unread,
Jan 20, 2001, 4:33:58 AM1/20/01
to
If the procedure ist part of an object (= if it is a method) then this must
work.
Maybe you should post the object declaration....

"JakeBaze" <jb...@fenix2.dol-esa.gov> schrieb im Newsbeitrag

news:01c08268$0e83c420$7fc4c8c7@jboon...

Peter Below (TeamB)

unread,
Jan 20, 2001, 12:07:51 PM1/20/01
to
In article <01c08268$0e83c420$7fc4c8c7@jboon>, JakeBaze wrote:
> Seems logical, yet I get this fatal error:
> Incompatible types: 'TNotifyEvent' and 'procedure, untyped pointer or
> untyped parameter'

You are trying to use a standalone procedure as the handler. That does not
work, the handler has to be a method of some object.


Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: Till Feb.2001 i will only visit the groups on weekends, so be
patient if i don't reply immediately.

0 new messages