Incorrect parameter for custom event handler

c++ builder

    Sponsored Links


  • 1. Adding new dialog boxes to legacy projects - Unable to find target project file
    Good afternoon! I am adding new forms and dialog boxes to an existing project and encountering an error that has really stopped my progress. When I add the new dialog box or form to the project, I get a fatal error that reads "Unable to find target project file. The target project is usually winMain ...". I am able to add these additional forms to new projects I create, but for some reason this particular project is throwing me a curve. I'd appreciate any suggestions! Thanks a lot, Scott
  • 2. Changing Options property for TCustomDBGrid not working
    Hello, I have a component that I derive from class TCustomDBGrid. I am trying to change some of the default values for the property Options. The Object inspector shows that the values have changed, but the component itself is not responding appropriately. dgIndicator and dgAlwaysShowSelection work. dgEditing, dgTabs, and dgRowSelect are displayed with the new values in the Object Inspector, but when I run the application with a DataSource set I am allowed to edit the text, the tab key still works, and I can not select a row. It I change the value in the object inspector it works appropriately. This is the logic in the constructor: Options = (Options >> dgEditing); // NOT working Options = (Options >> dgIndicator); // working Options = (Options >> dgTabs); // NOT working Options = (Options << dgRowSelect); // NOT working Options = (Options << dgAlwaysShowSelection); // working My header file contains this line: __property Options ; Any suggestions would be greatly appreciated. Thanks in advance, Joyce
  • 3. How do you tell what type a TVariant holds
    Hi, I was hoping someone could tell me how to tell what type of data is help within a TVariant, it appears there is no method available. Thanks in advance Dean
  • 4. TStringList property
    Why I can't do this? There is any other way to do that? void __fastcall SetProcuraParametros(TStringList value); TStringList __fastcall GetProcuraParametros(); __property TStringList ProcuraParametros = { read=GetProcuraParametros, write=SetProcuraParametros }; I got this: [C++ Error] TDataFrame.h(61): E2459 VCL style classes must be constructed using operator new Thanks Arnaldo Giacomitti Junior
  • 5. Moving selected cell on own inherited TDrawGrid
    Hi, I set in my grid a not visible columns, ex: MyGrid->ColWidths[1]=0, and I like to move the selected cell from Col 0 to the next visible Col 2, without stop in Col 1. I have try throught overrided method DrawCell, but, I think, because the Rect's area of the Selected Cell to be drawed in Col 1 is 0, the DrawCell method isn't called and I can't capture the moment that the Selected Cell goes to be drawed. With SelectCell method I can capture the moment but I can't change to the next Col because generates a Stack Overflow error. Some idea, some way, some light. Thanks in advantage.

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