Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-07-2001, 03:30 AM
gpdsoft gpdsoft is offline
Senior Member
 
Join Date: Jan 2001
Posts: 108
Default How can I send the Mouse's clik to any control by API? (MouseEvent??)

How can I send the Mouse's clik to any control by API? (MouseEvent??)
Reply With Quote
  #2  
Old 01-07-2001, 04:06 AM
TiTeaM TiTeaM is offline
Senior Member
 
Join Date: Jan 2001
Posts: 113
Default RE: How can I send the Mouse's clik to any control by API? (MouseEvent??)

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.
Reply With Quote
  #3  
Old 01-07-2001, 09:00 PM
digitiger digitiger is offline
Senior Member
 
Join Date: Jan 2001
Posts: 716
Default RE: How can I send the Mouse's clik to any control by API? (MouseEvent??)

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)
Reply With Quote
  #4  
Old 01-08-2001, 12:45 AM
PoseFant PoseFant is offline
Senior Member
 
Join Date: Jan 2001
Posts: 1,002
Default RE: How can I send the Mouse's clik to any control by API? (MouseEvent??)

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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 03:46 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.