We help IT Professionals succeed at work.

OnMouseDown event handler problem

Roger Alcindor
on
Medium Priority
153 Views
Last Modified: 2019-06-11
I have not been able to implement an event handler for a StringGrid OnMousedown event when the stringGrid is a multi-platform application with a target of Windows 32.
the compiler (C++ builder Embarcadero XE 10.1Berlin) gives a compile time error where the event handler is assigned in the constructor for the form Form3.

[bcc32 Error] Unit3.cpp(17): E2034 Cannot convert 'void (_fastcall * (_closure )(TObject *,TMouseButton,TShiftState,int,int))(TObject *,TMouseButton,TShiftState,int,int)' to 'TMouseEvent'
  Full parser context
    Unit3.cpp(15): parsing:  _fastcall TForm3::TForm3(TComponent *)

the code is as follows:

__fastcall TForm3::TForm3(TComponent* Owner)
	: TForm(Owner)
{
	StringGrid1->OnMouseDown = StringGrid1MouseDown; // <-----This giver a compile error
}
//---------------------------------------------------------------------------
void __fastcall TForm3::StringGrid1MouseDown(TObject *Sender, TMouseButton Button,
		  TShiftState Shift, int X, int Y)

{
	TStringGrid *g;
	int col, row;
	bool fixedCol, fixedRow;

// ... code to handle mouse-down event
}

Open in new window


Can this be corrected ?
Comment
Watch Question

Author

Commented:
More information.

There is also an error in the first line of code in the event handler

where by the Button parameter can't be checked; I wish to handle only right hand button down events so the first line in the handler is


	if(Button==mbRight)
	{

Open in new window


But there is also an error reporting that mbRight is an undefined symbol ?

So it seems the FMX controls may nor have the functionality of VCL components with regard to mouse actions and attibutes ?
I have decided to move the project to a VCL forms application as I have since found that there is no TStringGrid->MouseToCell function provided the FMX StringGrid control either.
This is the solution that I have decided to adopt so no further comments are needed.