![]() |
|
#1
|
|||
|
|||
|
How can I send the Mouse's clik to any control by API? (MouseEvent??)
|
|
#2
|
|||
|
|||
|
Hi,
Firstly you must know the target control handle, you may know that by using the API function : WindowFromPoint (in Windows unit) with a screen-coordinated point as parameter (you may know the mouse position by using the Mouse.CursorPos property). Example: var myhandle: hwnd; begin myhandle:=WindowFromPoint(Mouse.CursorPos); end; After that, you may send a click to this handle. But there is no message dedicated to indicate a click. However you may send a button down message immediately followed by a button up message like that : SendMessage(myhandle, WM_LBUTTONDOWN,0,0); SendMessage(myhandle, WM_LBUTTONUP,0,0); And this works fine in mostly cases ... Sorry for my very bad english, but I'm french ! TeaM. |
|
#3
|
|||
|
|||
|
first i am not sure about your purpose
if you want to capture the mouse down outside your form's window then then you can use the api function described in the first answere to your question but incase you want to capture the mouse click inside your application only then you can simply redirect the click on other controls to the procedure written for your intended that is target control.click lets assume you are looking for second thing that is mouse clicks within your application and your have a visible form with following components a) form1 b) image1; c) animationcontrol1; d) button1; and now you want all the mouse clicks within this form should be directed to button1 to activate the procedure written in procedure TForm1.Button1click(.............etc) begin .... ... end; so to achieve this just link this procedure to other controls/components on click event in their property pallete or in code like in property pallete of form etc click on events look for onclick even and in the right side click on the pulldown menu and select button1click or you can write separetae procedure and call the button1click procedure like procedure TForm1.form1click (.......etc) begin button1click(self); end; i hope this simple and optimized way should solve your problem b) |
|
#4
|
|||
|
|||
|
This example declares one function.
Function TForm1.MouseEvent(AOwner : TControl; Event : DWord) : LongInt; Var dwExtraInfo : DWord; Begin Mouse_Event(Event,AOwner.Left,AOwner.Top,0,dwExtra Info); End; To send an event use : In this case I'm sending the event to Button2 MouseEvent(Button2,MOUSEEVENTF_MOVE); MouseEvent(Button2,MOUSEEVENTF_LEFTDOWN); MouseEvent(Button2,MOUSEEVENTF_LEFTUP); MouseEvent(Button2,MOUSEEVENTF_RIGHTDOWN); MouseEvent(Button2,MOUSEEVENTF_RIGHTUP); Regards /Filip |
![]() |
| Thread Tools | |
| Display Modes | |
|
|