Incorrect parameter for custom event handler

c++ builder

    Sponsored Links


  • 1. Resource.
    I am trying to use the resource from a package, but I am getting some error. Anyone have some idea? I am trying this on the component source: Qgraphics::TBitmap *temp = new Qgraphics::TBitmap(); temp->LoadFromResourceName((unsigned int) HInstance, "BARRA01NOVO"); Thanks Arnaldo Giacomitti Junior.
  • 2. Not an allowed type
    I want the two components shown partially below to have a pointer to the other. For some reason, I keep getting "Not an allowed type". Why? Thanks for your help. Hugh Stewart tmCalendar.h <snip> #include "tmClockControl.h" class TtmClockControl; class PACKAGE TtmCalendar : public TWinControl { private: <snip> TtmClockControl* FClockCtrl; protected: void __fastcall CreateWnd(); public: __fastcall TtmCalendar(TComponent* Owner); <snip> __published: __property TtmClockControl* ClockCtrl = {read=FClockCtrl, write=FClockCtrl}; // Not an allowed type }; //--------------------------------------------------------------------------- tmClockControl.h #include "tmCalendar.h" //--------------------------------------------------------------------------- class TtmCalendar; class PACKAGE TtmClockControl : public TPanel { private: <snip> TtmCalendar* FCalendar; <snip> protected: void __fastcall CreateWnd(); public: <snip> __fastcall TtmClockControl(TComponent* Owner); __published: __property TtmCalendar Calendar* = {write=FCalendar, read=FCalendar}; // Not an allowed type }; //----------------------------------------------------------------------------
  • 3. My own class type of Property
    hi again folks! i have another problem, and hope that you can help me out, like you always do. =) this is related to my previous post, about events with parameters. I wanted to use Valedit::TItemProp for my customized ListView to use the properties of the ValueListEditor's ItemProps. So I declared my own __property Valedit::TItemProp ColumnProps[int] = {read = GetColumnProps, write = SetColumnProps}; but it says "VCL-style classes must be constructed using the operator new." so I just decided to have my own class, class TColumnProp { // members }; then use it as a property : __property TColumnProp ColumnProps[int] = { // read and write}; but now the error is "Not an allowed type". Am I allowed to use my own class as a type for a property? Or do you have any other suggestions on how I can implement TValueListEditor's ItemProps?
  • 4. Component events in the Object Inspector
    Here are snippets from two components I created. Common to everyone: typedef void __fastcall (__closure *TTellDateTime)(Extended DateTime); In the header of the component creating the event: __published: __property TTellDateTime TellCal = {read=FTellCal, write=FTellCal}; In the code of the component creating the event: if (FTellCal) FTellCal (FDateTime); In the header of the component responding to the event: __private void __fastcall SetDateTime(Extended ADateTime); __published: __property Extended DateTime = {read=FDateTime, write=SetDateTime}; The event shows in the Object Inspector for the component creating the event, but it does not show the second component's function, so I can't connect them with the Object Inspector. I could, of course, connect them at run time. But I'd like this to work. Where am I going wrong? Many thanks.
  • 5. Writing an event with parameters
    hi, good day! i'm writing a vcl component which is derived from TListView. its columns has an editStyle like that of the valuelist editor (similar to esSimple, esEllipsis, and isPickList). I want to create a published event which is similar to the GetPickList event of the valuelisteditor. How am i going to declare this event? Is the type TNotifyEvent? From Borland C++ Builder Help : "Notifications use the type TNotifyEvent, which carries only one parameter, the sender of the event. In some cases, it is not enough to know which event happened and what component it happened to. For example, if the event is a key-press event, it is likely that the handler will want to know which key the user pressed. In these cases, you need handler types that include parameters for additional information. If your event was generated in response to a message, it is likely that the parameters you pass to the event handler come directly from the message parameters." How will an event such as this be written and declared? AssignPickItems(TObject *Sender, int ACol, TStrings *Values) Thanks ... = )

Incorrect parameter for custom event handler

Postby Myles Rippenhagen » Wed, 26 Oct 2005 02:43:50 GMT


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 
typedef void __fastcall (__closure *OnPutToDatabaseEvent) (TObject* Sender, 
bool &DoDefault);
   OnPutToDatabaseEvent FOnPutToDatabaseEvent;
   __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

Postby Remy Lebeau (TeamB) » Wed, 26 Oct 2005 03:12:24 GMT

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.

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.

The OI does not care about typedefs.  It only cares about signatures.


Similar Threads:

1.Why event handler first parameters are incorrect

I noticed that DataGridView CellValidated() and other event handler first 
parameter is object:


        void Grid_CellValidated(object sender, DataGridViewCellEventArgs e) 

Why ? Correct signature must be

void Grid_CellValidated(DataGridView sender, DataGridViewCellEventArgs e) {


2.Custom event handler

Hello, all.  I am trying to develop my first component and I am trying to
figure something out.  I created a MouseMove event handler for my component
(TMyComponent::MouseMove) and it works fine.  I added my component to a new
project (TMyComponent *MyComponent1) and I want perform a task in the
MyComponent1MouseMove event.  My problem is that the TMyComponent::MouseMove
function is executing, but the TForm1::MyComponent1MouseMove function is
not.  I set the OnMouseMove event to MouseMove for the MyComponent1
instance, but it still only calls the component handler, not the custom
handler.  Why won't it call my custom handler?  Actually, I will need both
functions to execute.  Will I need to explicitly call
TMyComponent::MouseMove() from within the TForm1::MyComponent1MouseMove
function to get both to execute?  Any feedback will be greatly appreciated.



3.Custom event handlers in .NET Winforms

4.Custom Event Handler

I am getting an error down below, this same code works in VB, what gives?

private void Form1_Load(object sender, System.EventArgs e)


System.Windows.Forms.LinkLabel l = new System.Windows.Forms.LinkLabel();

FileSystemWatcher watcher = new FileSystemWatcher();

watcher.Path = @"C:\TempFolder";

watcher.Filter = "*.txt";

//error here: Cannot implicitly convert type System.EventHandler to

watcher.Created += new System.EventHandler(OnCreated);

watcher.EnableRaisingEvents = true;


private void OnCreated(object sender, System.EventArgs e)




5.Custom event handlers and searching a listview

6. Passing in a OnMouseDown/OnMouseUp event handler as a parameter of a function

7. How to pass more than two parameters in the event handler

8. TADODataset.Parameters.Refresh results in incorrect parameter names

Return to c++ builder


Who is online

Users browsing this forum: No registered users and 76 guest