|
|
Get Mouse Position: 1. Open Borland C++ Builder. 2. Place a Timer on the form. 3. Place a Label on the form. 4. Place another Label on the for m bellow Label1. 5. Set the Timer1 interval value to 50. 6. Double click Timer1. 7. Type the following red code in the Timer1Timer function: //This is what the Timer1Timer function should look like: void __fastcall TForm1::Timer1Timer(TObject *Sender) { POINT pt; AnsiString posX, posY; posX = "Cursor Position X: "; posY = "Cursor Position Y: "; GetCursorPos(&pt); posX += pt.x; posY += pt.y; Label1->Caption = posX; Label2->Caption = posY; } //--------------------------------------------------------------------------- 8. Run the program. Move the mouse cursor and the position x-axis is dislplayed using Label1 and position y-axis is displayed using Label2. |