I have a custom control for which I am trying to define an OnMouseMoveFunction. Essentially, the control functions as a search bar, and is made up of an edit box with a child custom TGrid
control for displaying results. I am handling several mouse events for the TGrid
already, however when trying to implement OnMouseMove I am getting the following error when I try to set the TGrid
OnMouseMove method:
E2034 Cannot convert 'void (_fastcall * (_closure )(TMouseMoveEvent))(TMouseMoveEvent)' to 'TMouseMoveEvent'
Here is the piece of the header file where the function is defined:
void __fastcall GridMouseMove( TMouseMoveEvent * MouseEvent );
Here is the actual function inside the control's CPP file:
void __fastcall TFmSearchBar::GridMouseMove( TMouseMoveEvent * MouseEvent )
{
//handle event here
}
Up to this point everything will compile just fine. However, when I go to assign the TGrid
's OnMouseMoveEvent handler to the method I have assigned, I get the error.
void __fastcall TFmSearchBar::SetGridProperties()
{
FGrid->OnKeyDown = GridKeyDown;
FGrid->OnClick = GridClick;
FGrid->OnMouseEnter = GridMouseEnter;
FGrid->OnMouseLeave = GridMouseLeave;
FGrid->OnMouseMove = GridMouseMove; //This line causes the error
}
What am I missing that is causing this not to build?
Try to use declarations, generated by IDE for TGrid.
Header:
void __fastcall GridMouseMove(TObject *Sender, TShiftState Shift, float X, float Y);
Implementation from cpp:
void __fastcall TFmSearchBar::GridMouseMove(TObject *Sender, TShiftState Shift, float X,
float Y)
{
ShowMessage("123");
}
Assignment (the same):
void __fastcall TFmSearchBar::SetGridProperties()
{
...
FGrid->OnMouseMove = GridMouseMove; //This line causes the error
}