Incorrect parameter for custom event handler

c++ builder

    Sponsored Links

    Next

  • 1. Catching mouse clicks
    I'm trying to write a component that can catch mouse clicks on any control on *one* panel. At present I'm using a handler set using SetWindowsHookEx() which works....but also catches mouse clicks for context menus etc. Is there any way around this or do I have to check for the window handles being for controls on the panel that I'm using? This seems like a rather dirty method of doing this but if it's the only way so be it. Thanks for any help, Pete
  • 2. Howto create integer-list property?
    Hello, how do I manage to get an plain INTEGER-list (not symbols) pulldown property (modem baudrate) in my self-created (comport) component? I tried TStringList, TList, TStrings and 'enum's, but none of them solved the problem. - TStringList creates the expandable 'TStringList' word in the right object inspector column. - TList creates a expandable list in the left object inspector column. - TStrings acts like TStringList. - Enum symbols only show up in the right object inspector column if corresponding constants are sequential numbered from zero up. Thanks, Henk
  • 3. TImage vs TCustomControl
    Hi, I'm trying to find a way to make a button based on an Image shape. This image doesn't need to be rectangle. I would like to have information about 2 components that could be the class base for my new component. I know that if my component is based on TCustomControl i can place my image on this canvas and use Create region function to make my button "follows" the border of my image. On the other side, if i use TImage or TGraphicControl as class base of my component, i can place my image but my canvas will always be rectangle (like the black rectangle that we can see around image - delimitation zone). 1. Could you tell me if a function exists to do with TImage or TGraphicControl, the same that CreateRegion with TCustomControl ? if not, it means that i will have to use a TCustomControl with createregion to generate my customer button shaped on my image. In case of using TCustomControl, i will have a published property like TImage in which my image will be stored. 2. In this case, how dynamically (under conception) update my shaped button on my form ? thanks a lot. Alain
  • 4. Window procedure subclassing in the VCL
    In my derived TCustomComboBox component I need to handle some messages sent to the protected TCustomCombo's EditWndProc procedure. This procedure is not virtual so I can't override it. I recall that there is a VCL way to do this which allows for my windows procedure to be a member function of my component, rather than the usual SetWindowLong etc. in which my windows procedure is a global/static function, but I don't recall what it is. Could anybody tell me ?
  • 5. How can I create a DCR with more 256 Color?
    Hi! I would like to create a nice DCRs for my components! I saw a DCR with images with more than 256 Color, but I didn't saw any documentation about this! and the Image editor doesn't support it Somebody could help me! thank you, Victor

Incorrect parameter for custom event handler

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

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

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.


Gambit



Similar Threads:

1.Why event handler first parameters are incorrect

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

        Grid.CellValidated+=new 
DataGridViewCellEventHandler(Grid_CellValidated);
...

        void Grid_CellValidated(object sender, DataGridViewCellEventArgs e) 
{
....
}

Why ? Correct signature must be

void Grid_CellValidated(DataGridView sender, DataGridViewCellEventArgs e) {

Andrus. 

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.

Thanks,

Mark


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
FileSystemWatcher,

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

watcher.EnableRaisingEvents = true;





}

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

{

MessageBox.Show("yo");











}


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