VCL.TMouseEvent (C++)
Description
This example shows how to use the TMouseEvent function type.
To build and test this example, create a VCL Forms Application - C++ Builder, and add the following on the form:
- Two TButton objects that trigger the Vcl.Controls.TMouseEvent.
Code
Before writing the code, add a Vcl.Controls.TControl.OnMouseDown event handler for the first button and a Vcl.Controls.TControl.OnMouseUp event handler for the second button.
void __fastcall TForm4::Button1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
int X, int Y)
{
TPoint* aPoint = new TPoint(X,Y); //Takes the coordinates of the current mouse position
*aPoint = Vcl::Controls::TControl::ClientToScreen(*aPoint); //Translates the coordinates to global screen coordinates
ShowMessage(UnicodeString(aPoint->X)+" "+UnicodeString(aPoint->Y));
}
//---------------------------------------------------------------------------
void __fastcall TForm4::Button2MouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift,
int X, int Y)
{
TPoint* aPoint = new TPoint(X,Y);
ShowMessage(UnicodeString(aPoint->X)+" "+UnicodeString(aPoint->Y));
}