![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
Q: Determine the location of the mouse.Answer: Call the API GetCursorPos function. You pass the function a pointer to a windows POINT structure (in BCB, TPoint is the same thing as the windows POINT structure). Here is a code example. To use this code, create a new project, place a TLabel and a TTimer on the form, and place the code inside the OnTimer event of the TTimer control. The program will display the mouse coordinates as you move the mouse. void __fastcall TForm1::Timer1Timer(TObject *Sender) { TPoint pt; GetCursorPos(&pt); Label1->Caption = "(" + IntToStr(pt.x) + ")(" + IntToStr(pt.y) + ")"; } | ||||||
All rights reserved. |