Incorrect parameter for custom event handler

c++ builder

    Sponsored Links

    Next

  • 1. OnDrawCell (TStringGrid) requesting constant TRect
    Hi! In the help to C++Builder Personal it is stated that the OnDrawCell event has parameters (TObject*, long, long, TRect, TGridDrawState) but when try to run an application with a grid derived from TStringGrid containing an OnDrawCell event it seems that the compiler wants (TObject*, int, int, const TRect &, TGridDrawState) as parameters. Changing long to int doesn't bother me, since I will avoid anyway to have many entries in my lists at the same time. But as I understood the method TCanvas::TextRect right, I will need to modify the TRect passed through to the OnDrawCell event, but maybe I've misunderstood this: -Does TextRect modify the TRect one passes through, or can I make a copy of the TRect passed through to OnDrawCell, modify this copy and then pass it through to TextRect? -And why does the help say something totally different? Is there a method with different parameters to which I haven't got access in my personal edition or is this just a small "bug"? /Erik
  • 2. TStringGrid - let text go beyond cell?
    Hi! I've been trying to write a class derived from TStringGrid and to make it possible for some rows to be made of just one row (like having a HTML TABLE with e.g. 7 columns and one row with COLSPAN=7), but I can't work it out. I've tried with Canvas and DrawRect according to the examples in the help but this only draws a border around the complete row while the text still is confined to one cell. I want it to cross the cell borders. Is there an easy way to do this? Regards, Erik Doekes Example: [Date] [Transaction ] [Account] [Amount] [Category] [Remaining] [30/6] [Bought some fruit] [P ] [-60 ] ] [51 ] [Comment: ] [Incorrect input: 30/6Bus P-20 | ] [Counted contents of wallet "P": ] [1/7 ] [Bank withdrawal ] [P ] [500 ] [<-> ] [531 ] So, sometimes all columns are used, and sometimes there is only one column and then I of course want the complete text of the column to be shown, instead of it being crowded in the first column and empty in all following columns.
  • 3. inheriting from TDBEdit
    Hi guys, One of my fellow coders at work has created a component that inherits from TDBEdit. The only extra functionality is that the derived component shows the database field's value as a hint whenever the mouse is over that control. It seems to work ok, but she's achieved this by programmatically displaying the hint in the OnMouseMove event of the control. I'm not a huge fan of this method - can anyone think of another way of achieving the same functionality? One other issue - I'd rather that the hint didn't appear unless the text box was not large enough to show all of the text contained in the database field. Any suggestions on how to go about doing this? Cheers, Andrew
  • 4. Converting a delphi line to C++
    Hi, Can somebody convert the following line to CPP. const cOpenIcon: array[boolean] of Cardinal = (0, SHGFI_OPENICON); Thanks

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