Board index » cppbuilder » Incorrect parameter for custom event handler

Incorrect parameter for custom event handler


2005-10-25 01:43:50 AM
cppbuilder54
Hi,
I have created several custom components and generally have had great
success with them, but I am currently running into a problem where when I
double-click on a published custom event (on the "Events" tab of the "Object
Inspector" in the IDE), the inserted method declaration contains the wrong
variable name. The signature matches another, similar custom event, and it
seems to be picking up the parameter name from this other definition. I
have double-checked that I am referencing the correct typedef in the
definition of my custom component and I didn't see any problem. I am using
BCB6 Enterprise on WinXP. Following are the important bits of the code.
...
typedef void __fastcall (__closure *BeforePostEvent) (TObject* Sender, bool
&CanPost);
typedef void __fastcall (__closure *OnPutToDatabaseEvent) (TObject* Sender,
bool &DoDefault);
...
private:
OnPutToDatabaseEvent FOnPutToDatabaseEvent;
...
__published:
__property OnPutToDatabaseEvent OnPutToDatabase =
{read=FOnPutToDatabaseEvent, write=FOnPutToDatabaseEvent};
...
When I double-click on the "OnPutToDatabase" event in the IDE, the inserted
code labels the bool parameter "CanPost" instead of "DoDefault". It appears
to just pick up the first typedef with a matching signature instead of using
the typdef that I specified.
Any suggestions??
 
 

Re:Incorrect parameter for custom event handler

"Myles Rippenhagen" < XXXX@XXXXX.COM >wrote in message
Quote
when I double-click on a published custom event (on the "Events" tab
of the "Object Inspector" in the IDE), the inserted method declaration
contains the wrong variable name.
That is a long-standing known issue. The OI matches events by signatures
only, not names. You have two different events that have the exact same
signature (return value, calling convention, parameter data types, and
parameter ordering). The OI always generates code using the first event
type that matches the required signature.
Quote
The signature matches another, similar custom event and it seems to
be picking up the parameter name from this other definition.
That is exactly why you are seeing what you have described. There is
nothing you can do to prevent the OI from behaving that way. You will just
have to change the signature of one of your events so that they no longer
match each other.
Quote
I have double-checked that I am referencing the correct typedef
in the definition of my custom component and I didn't see any
problem.
The OI does not care about typedefs. It only cares about signatures.
Gambit