Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #87061

Re: calling a Event Handler within a class

From Jens <paule32.jk@gmail.com>
Newsgroups comp.lang.c++
Subject Re: calling a Event Handler within a class
Date 2022-10-18 10:06 +0200
Message-ID <jr753uFc0h4U1@mid.individual.net> (permalink)
References <jr5tj7F6h7bU1@mid.individual.net> <tilj96$ee4$1@gioia.aioe.org>

Show all headers | View raw


Hello,

I am a member of a church organization for peoples with
some problems.

My hobby is it, to programming applications for computers.
I master me self in Delphi (beginning with Turbo Pascal 6/7,
GNU C/C++, and finally C++ Builder 1..6 (32-Bit).

I am able to download the Community Versions of Emberracdo
Delphi, and C++ Builder in both (32, and 64-Bit for Windows).

But I have to deal with C, and Pascal code twice.
But, I can only install Delphi, or C++ Builder.
But not the same RAD Tools together - and after a year, I have
to re-new the license, and re-install all Tools again.

This implicit the installing all the RAD Tools (Components)
that I had install before I use them.
And this is a nogo.

So, I back to days, as BORLAND came with his good 32-Bit Tools
of Delphi, and C++ Builder.

My first problem, in the past few days was, that I had a problem
to "parent window" a TSplitter (a component which can be used to
move parts of GUI components vertical, or horizontal on a desktop
window form (TForm), to make more visibility of the components on
the given/underlaying TSplitter componentes.

This problem was done by me, by experiment hours of wasteing time
and stressed lost of hair.

Okay, ...

Now, I have a problem, to "set" the Event Handler of a BORLAND
C++ Builder component (TSpeedButton) - a TSpeedButton is like a
normal Windows Desktop Application Button, except, it would be
*not* appear in the tabular order of selectable items of the
applications "tabable" components (ListBox, ComboBox, Button, ...)

I said: I have to deal with Pascal, and C Code ... :
I created a .DLL project under C++ Builder 6.0, compile it, and
place it in the directory of my application .exe binary.

As code/to comunicate with the C+++ .dll code, I export functions
from the .dll library, and import it in Delphi.

All code goes done.
Till, I would create a OnClick event on a TButton/TSpeedButton.
It seems, that I must have a class that decents from a TControl,
so, the VCL manager knows, which VMT (virtual method table)
proceure, or function can be called within this (TObject) class.

I have to use:  extern "C" void foo(void) { /* ... */ }

because C++ mangles functions members in C++ and fit it in space
of the VMT's of it handled TClass.
So, I can not directly call mangled C++ functions in Delphi by
simply "import" them - this came to a caos of the differnt memory
system's between Delphi, and C++ Builder.

That's why, I use pointer between Delphi, and C++ Builder.

Okay, ...

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
....
}

To make more sense in this posting, I can point You to my
StackOverflow/RetroComputing article with the followin URL:

https://retrocomputing.stackexchange.com/questions/25400/how-to-embeed-c-builder-6-32-bit-tframe-into-a-delphi-7-32-bit-application

This has not directly to do with my (second) part/question about
the described problem in this post.
But it depends on in future step's.

Thanks for reading, and helping hand.
Jens

Back to comp.lang.c++ | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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