Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Wrong event type when double clicking component event handler


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Jan 16, 2018 6:24 AM Last Post By: Andreas Bickele Threads: [ Previous | Next ]
Andreas Bickele

Posts: 2
Registered: 4/24/10
Wrong event type when double clicking component event handler  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 15, 2018 6:06 AM
Hello!

We are developing custom components for a VCL application and we have a problem regarding event properties:

When double clicking any event, the event type of the property is not recognized correct and it will always be
void __fastcall TestComponent1Something(Variant );


I've implemented a small example unit TTestComponent which can reproduce the problem:

Header-File:
//---------------------------------------------------------------------------
 
#ifndef TTestComponentH
#define TTestComponentH
//---------------------------------------------------------------------------
#include <System.SysUtils.hpp>
#include <System.Classes.hpp>
//---------------------------------------------------------------------------
class PACKAGE TTestComponent : public TComponent
{
private:
	TNotifyEvent FOnSomething;
protected:
public:
	__fastcall TTestComponent(TComponent* Owner);
 
    void Something();
__published:
	__property TNotifyEvent OnSomething = { read = FOnSomething, write = FOnSomething };
};
//---------------------------------------------------------------------------
#endif
 


Source File:
//---------------------------------------------------------------------------
 
#include <vcl.h>
 
#pragma hdrstop
 
#include "TTestComponent.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// Durch ValidCtrCheck wird sichergestellt, dass die erstellen Komponenten
// keine virtuellen Funktionen haben.
//
 
static inline void ValidCtrCheck(TTestComponent *)
{
	new TTestComponent(NULL);
}
//---------------------------------------------------------------------------
__fastcall TTestComponent::TTestComponent(TComponent* Owner)
	: TComponent(Owner)
{
}
 
void TTestComponent::Something()
{
 	if(FOnSomething)
    	FOnSomething(this);
}
 
//---------------------------------------------------------------------------
namespace Ttestcomponent
{
	void __fastcall PACKAGE Register()
	{
		TComponentClass classes[1] = {__classid(TTestComponent)};
		RegisterComponents(L"Custom Components", classes, 0);
	}
}
//---------------------------------------------------------------------------


I placed the component in C++ Builder into a VCL Form and double clicked the event handler "OnSomething". The result is the creation of the following event handler stub as well as the error message Error in Module MainFrame: Wrong method declaration in class TForm1

void __fastcall TForm1::TestComponent1Something(Variant )
{
 
}


Am I doing something wrong or is this a bug in C++ Builder?

PS.: C++ Builder Version is "Embarcadero® C++Builder 10 Seattle Version 23.0.20618.2753 "

chen zero

Posts: 30
Registered: 5/26/00
Re: Wrong event type when double clicking component event handler  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 16, 2018 4:16 AM   in response to: Andreas Bickele in response to: Andreas Bickele
Andreas Bickele wrote:
....
void __fastcall TForm1::TestComponent1Something(Variant )
{

}
{code}

Am I doing something wrong or is this a bug in C++ Builder?

PS.: C++ Builder Version is "Embarcadero® C++Builder 10 Seattle Version 23.0.20618.2753 "


Hi Andreas,
I tried your code and it's fine, however, I do not have the CB version you have. I am using XE.
If manually correct the "Variant" to "TObject* Sender", whether the project can be compiled ?
Andreas Bickele

Posts: 2
Registered: 4/24/10
Re: Wrong event type when double clicking component event handler  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 16, 2018 6:24 AM   in response to: chen zero in response to: chen zero
I tried your code and it's fine, however, I do not have the CB version you have. I am using XE.
If manually correct the "Variant" to "TObject* Sender", whether the project can be compiled ?

Yes, then the project can be compiled, but I have to manually assign the event handler in the constructor.

I noticed that the problem only appears when using bcc32c, but not when using the bcc32, so it seems to be a bug in C++ Builder or the Clang based compiler
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02