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 "
Connect with Us