Incorrect parameter for custom event handler

c++ builder

    Sponsored Links


  • 1. Why my TEditCopy created at run-time can't work properly?
    I created a TEditCopy at run-time in TMDIForm1's constructor like this: __fastcall TMDIForm1::TMDIForm1(TComponent *Owner) : TForm(Owner) { actEditCopy = new TEditCut(ActionList1); actEditCopy->Caption = "Copy"; actEditCopy->OnExecute = myEditCopy; //myEditCopy is a foobar function with nothing to do. I just learn TEditCopy. menuEditCopy->Action = actEditCopy; //menuEditCopy is submenu Copy in menu Edit } But, when this application runs and I does not New File yet, my Copy submenu is ENABLED! Why like so? OS: W2K IDE: BCB6
  • 2. nodefault keyword
    Hi, I cannot seem to determine the purpose of the nodefault keyword which is used with properties. So far all my examples that I have tried have not needed the nodefault keyword at all. In all cases leaving out the keyword has the same affect as including it! Can any explain with a simple example what it does and when it should be used. Regards Farmer Jo
  • 3. Problem with using Delphi TCollection-successor
    Hello, Does anybody know how to use TCollection-succesor written in Delphi from Builder code? It installed right, but when I try to execute next code, I get AV or stack overload (depend on compiler settings) d = MyCollection->Add(); when I trace that call in CPU window, I see - when Builder-created code load virtual table for TCollection it differs from virtual table which loaded by code which was created by dcc32. Is there any way to resolve that mismatch? Alex Zencovich
  • 4. How can i send key strokes to underlying parent control?
    Hello. I want to close child form when it recieves Navigation Key messages. But when that happens i want the parent control to recive that message as well. I implemented WMDialogKey handler to close the child form. But i m not sure how to pass the message to its parent. Following is what i have got so far... //------------------------------------------------------------------------ void __fastcall TChildForm::WMDialogKey(TWMKey& Msg) { switch (Msg.CharCode) { case VK_LEFT: case VK_UP: case VK_RIGHT: case VK_DOWN: PostMessage(ParentForm->Handle, Msg.Msg, Msg.CharCode, Msg.Unused); Close(); break; } } //------------------------------------------------------------------------
  • 5. Property Editor for a Set - Problem solved
    Colleagues Thank you to those who responded to my query. I have now resolved the problem with the insights provided by them. I did have a setter function to write the property, but it did not include any lines of code in it then because I intended to include them later to do something really clever!!! Regards Ray Carpenter Remy Lebeau (TeamB) < XXXX@XXXXX.COM > wrote in message news:40468c1d$ XXXX@XXXXX.COM ... > > "Ray Carpenter" < XXXX@XXXXX.COM > wrote in message > news: XXXX@XXXXX.COM ... > > > When an uninitialsed Set is expanded in the Object Inspector, it > > shows the value of all elements as false as would be expected. > > However, I cannot change the value of any element to true, and > > so it appears that I am missing something here. > > I would suspect a bug in your own component code before I suspect a bug in > the native editors. Please show your actual code for the property in > question. > > > Gambit > >

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 28 guest