she3i3i
asked on
Hook Needed
I need a "What did I just left click on?" hook.
Cheers, Chris.
Cheers, Chris.
and yes.... wnd = the handle of the button you pressed....
Here is one way to capture left button clicks:
add this to your class declaration(before all the private/public stuff)
procedure MessageLoop(var Msg:TMsg;var Handled:Boolean);
and here is what the function does
procedure Tmnfrm.MessageLoop(var Msg: TMsg; var Handled: Boolean);
begin
if (Msg.Message = WM_LBUTTONDOWN) or (Msg.Message = WM_LBUTTONUP) then
{do some stuff}
end;
hope I was at least a little helpful
Carl
add this to your class declaration(before all the private/public stuff)
procedure MessageLoop(var Msg:TMsg;var Handled:Boolean);
and here is what the function does
procedure Tmnfrm.MessageLoop(var Msg: TMsg; var Handled: Boolean);
begin
if (Msg.Message = WM_LBUTTONDOWN) or (Msg.Message = WM_LBUTTONUP) then
{do some stuff}
end;
hope I was at least a little helpful
Carl
dont kno about him.... but me, I owe you big time if that code works :) :) :) :) :) :) :)
It means one step close to writing Pcanywhere / Laplink (as if!)
Craig C.
It means one step close to writing Pcanywhere / Laplink (as if!)
Craig C.
Listening
ASKER
Adjusted points to 50
ASKER
Craig, I have tried your code and cannot seem to figure what I must do with wnd in order to find which button was actually clicked.
Carl, my question is...
"WHAT did I just left click on?" and not "DID I just left click?".
Increasing points to 50.
Cheers, Chris.
P.S. I've spent a whole day on the subject and I'm still stuck.
Carl, my question is...
"WHAT did I just left click on?" and not "DID I just left click?".
Increasing points to 50.
Cheers, Chris.
P.S. I've spent a whole day on the subject and I'm still stuck.
well once you got the private declaration to work, which i could not.... its easy, the handle from my code will give you the window once you catch the left mouse click....
Ok Put a timer on your form, then put *3* edit boxes on and set the timer to 1 from 1000 and just copy the code needed, dont copy and paste it all, just copy the bits out of it, so it looks more or less as yours...
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
var
buffer: array[0..50] of char;
p: trect;
n: integer;
result: byte;
x,y,num,num1,num2: integer;
wnd,wnd2: hwnd;
p2: tpoint;
i1 : integer;
s1 : string;
implementation
{$R *.DFM}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
num:=getmessagepos();
num1:=hiword(num);
num2:=loword(num);
p2.y:=num1;
p2.x:=num2;
wnd:=windowfrompoint(p2);
edit1.text:=inttostr(num2) ;
edit2.text:=inttostr(num1) ;
edit3.text:=inttostr(wnd);
end;
end.
Here is one way to capture left button clicks:
add this to your class declaration(before all the private/public stuff)
procedure MessageLoop(var Msg:TMsg;var Handled:Boolean);
and here is what the function does
procedure Tmnfrm.MessageLoop(var Msg: TMsg; var Handled: Boolean);
begin
if (Msg.Message = WM_LBUTTONDOWN) or (Msg.Message = WM_LBUTTONUP) then
{do some stuff}
end;
hope I was at least a little helpful
Carl
That when combined with carl's code, that should be it...... I have not been able to get his code to work yet....
Trying now at work....
Ok Put a timer on your form, then put *3* edit boxes on and set the timer to 1 from 1000 and just copy the code needed, dont copy and paste it all, just copy the bits out of it, so it looks more or less as yours...
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
var
buffer: array[0..50] of char;
p: trect;
n: integer;
result: byte;
x,y,num,num1,num2: integer;
wnd,wnd2: hwnd;
p2: tpoint;
i1 : integer;
s1 : string;
implementation
{$R *.DFM}
procedure TForm1.Timer1Timer(Sender:
begin
num:=getmessagepos();
num1:=hiword(num);
num2:=loword(num);
p2.y:=num1;
p2.x:=num2;
wnd:=windowfrompoint(p2);
edit1.text:=inttostr(num2)
edit2.text:=inttostr(num1)
edit3.text:=inttostr(wnd);
end;
end.
Here is one way to capture left button clicks:
add this to your class declaration(before all the private/public stuff)
procedure MessageLoop(var Msg:TMsg;var Handled:Boolean);
and here is what the function does
procedure Tmnfrm.MessageLoop(var Msg: TMsg; var Handled: Boolean);
begin
if (Msg.Message = WM_LBUTTONDOWN) or (Msg.Message = WM_LBUTTONUP) then
{do some stuff}
end;
hope I was at least a little helpful
Carl
That when combined with carl's code, that should be it...... I have not been able to get his code to work yet....
Trying now at work....
Yeah same problem....
Carl, if you can post all the source code for example, new app then just fill in the code you have shown us... i will get this code to work together... then i will let you have all the points... i will do the hardwork? :)
Cos i am pretty low on points, is that ok?
Carl, if you can post all the source code for example, new app then just fill in the code you have shown us... i will get this code to work together... then i will let you have all the points... i will do the hardwork? :)
Cos i am pretty low on points, is that ok?
left on minor thing out, to get my little code snippet to work, one must add this line in the Create function of the form:
application.OnMessage:=Mes sageLoop;
and I'm working on getting it to do what you want now...
application.OnMessage:=Mes
and I'm working on getting it to do what you want now...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oh, yeah, get rid of that edit3:=inttostr(wnd); line.
ASKER
Right on!
Well, i tried it, but it would only capture the clicks from the Form itself... i use getclassname to get the info you got with findvcl... Yep... major problem, it may be my delphi 4 that does it?...
var
buffer: array[0..50] of char;
p: trect;
n: integer;
result: byte;
x,y,num,num1,num2: integer;
wnd,wnd2: hwnd;
p2: tpoint;
i1 : integer;
s1 : string;
begin
num:=getmessagepos();
num1:=hiword(num);
num2:=loword(num);
p2.y:=num1;
p2.x:=num2;
wnd:=windowfrompoint(p2);
edit1.text:=inttostr(num2)
edit2.text:=inttostr(num1)
end;
sorry for all the vars, i couldent be bothered sorthing them out for this one snippet.....
See if that is what you need... put it in a timer, set to 1 (default 1000)...