Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #87072
| From | Manfred <noname@add.invalid> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: calling a Event Handler within a class |
| Date | 2022-10-19 02:43 +0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <tinh7v$1tfs$1@gioia.aioe.org> (permalink) |
| References | <jr5tj7F6h7bU1@mid.individual.net> <tilj96$ee4$1@gioia.aioe.org> <jr753uFc0h4U1@mid.individual.net> |
On 10/18/2022 10:06 AM, Jens wrote:
> Now, the question is: is it possible, to set a event handler on
> the OnClick event of a TButton object without having implicit a
> TObject inherited class ?
>
> If the answer YES, then: How can this be done in C++ Builder ?
>
> Under Delphi, I just assign it like:
>
> ....
> btn := TButton.Create(AOwner);
> btn.Parent := AOwner;
> btn.OnClick := btnOnClick;
> ....
>
> In C++ Builder 6.0, i try the similar same procedure, but I fail
> with the code:
>
> extern "C"
> __declspec(dllexport) void
> __stdcall foo(int owner)
> {
> ....
> TForm *form = new TForm((HWND)owner);
> ....
> TButton *btn = new TButton(form);
> btn->Parent = form;
> btn->OnClick = btnOnClick; // <-- this fails
> ....
> }
I am not that familiar with Borland products, but from a C++ perspective
it would help if you could post the exact and complete error message -
this might show which are the types of the OnClick member, and of
btnOnClick.
You may also want to compare the following:
- declaration of the OnClick member of TButton - I guess this should be
documented by Borland - it may be an object of some class that overloads
the assignment operator; inspecting what is the expected argument type
of such operator might help
- prototype of btnOnClick
In C++ an "event" is not a built-in primitive. C++ offers all the lower
level ingredients to build an event system, so the details of events and
event handlers are specific to your implementation (Borland), and their
docs should tell how to use their events, rather than the language itself.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
calling a Event Handler within a class Jens <paule32.jk@gmail.com> - 2022-10-17 22:51 +0200
Re: calling a Event Handler within a class Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2022-10-17 14:32 -0700
Re: calling a Event Handler within a class Juha Nieminen <nospam@thanks.invalid> - 2022-10-18 07:06 +0000
Re: calling a Event Handler within a class Jens <paule32.jk@gmail.com> - 2022-10-18 10:06 +0200
Re: calling a Event Handler within a class Juha Nieminen <nospam@thanks.invalid> - 2022-10-18 09:27 +0000
Re: calling a Event Handler within a class JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-20 18:36 +0300
Re: calling a Event Handler within a class David Brown <david.brown@hesbynett.no> - 2022-10-18 11:45 +0200
Re: calling a Event Handler within a class Manfred <noname@add.invalid> - 2022-10-19 02:43 +0200
Re: calling a Event Handler within a class Bonita Montero <Bonita.Montero@gmail.com> - 2022-10-18 14:21 +0200
Re: calling a Event Handler within a class Jens <paule32.jk@gmail.com> - 2022-10-19 12:58 +0200
Re: calling a Event Handler within a class Lynn McGuire <lynnmcguire5@gmail.com> - 2022-10-20 00:25 -0500
csiph-web