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

event and OOP

0 views
Skip to first unread message

fwang11

unread,
Oct 18, 2004, 4:05:53 AM10/18/04
to

How could a Button object send ButtonClick() event message to
a Form object? It is not an OOP concept.
The Form object "has a" Button object.
So, a button can not send message to a form object.

The ButtonClick event handler is IDE-managed, it is not OOP.


Stuart Borden

unread,
Oct 19, 2004, 2:34:03 AM10/19/04
to
On 18 Oct 2004 01:05:53 -0700, "fwang11" <fwa...@pub3.fz.fj> wrote:

>
>
>How could a Button object send ButtonClick() event message to
>a Form object? It is not an OOP concept.
>The Form object "has a" Button object.
>So, a button can not send message to a form object.
>

It does not. The form actually sends the message to the "button" that the button has been clicked, then the button acts
upon that information.

>The ButtonClick event handler is IDE-managed, it is not OOP.


Don't confuse OOP with how a program actually functions. They are not always related. But in this case, they are.

Advice: Look into message handling by Windows and VCL. You will begin to see the burdensome reality of OOP.

Stuart B.

fwang11

unread,
Oct 20, 2004, 4:08:54 AM10/20/04
to

Stuart Borden <sbo...@spectrontech.com> wrote:
>On 18 Oct 2004 01:05:53 -0700, "fwang11" <fwa...@pub3.fz.fj> wrote:
>>How could a Button object send ButtonClick() event message to
>>a Form object? It is not an OOP concept.
>>The Form object "has a" Button object.
>>So, a button can not send message to a form object.
>>
>
>It does not. The form actually sends the message to the "button" that the button has been clicked, then the button acts
>upon that information.

It does. The ButtonClick() event handler is called from Button object to Form object.


Alisdair Meredith [TeamB]

unread,
Oct 27, 2004, 10:00:39 AM10/27/04
to
fwang11 wrote:

> It does. The ButtonClick() event handler is called from Button object
> to Form object.

No, the button objects stores a callback object, of a special BCB type
called a __closure. If such an object is stored in its OnClick
property, it asks it to perform its action.

When the form loads, it sets various properties of the Button object it
owns, such as Caption, Top and Left. It may also set a value for the
OnClick property, by making the appropriate callback object.

So the button knows nothing about the form, all it knows is the
callback. The callback is created by the form, and typically points to
a bound member function in itself. That is OK though, as the form has
the info to do this, not the button.

AlisdairM(TeamB)

0 new messages