Alphomega
asked on
component handle in other process
Hi,
I create 2 applications A and B.
In A, I want to get the handle of a component (TEdit for example) on B.
What's the way to do that please?
I create 2 applications A and B.
In A, I want to get the handle of a component (TEdit for example) on B.
What's the way to do that please?
Listening...
I think, you don't need the Delphi component's handle, but instead you want to get a component's window handle to use it within PostMessage/SendMessage functions. Am I right ?
Alphomega, what do you know of the TEdit component? Do you have it's window handle? Or what do you have?
Hi,
there are a few ways i see to help this one i use ,in app b give the form a unique name as in "SomeUniqueNameForm" and give your components unique names also as in "HelloThereStuartButton".
this then gives a classname of "TSomeUniqueNameForm" and the button a classname of "THelloThereStuartButton"
so now in app1 you can do
var
h : thandle;
begin
h := findwindow('TSomeUniqueNam eForm','ei ther the forms caption with string quotes or nil without string quotes here');
h := FindWindowEx(h,0,'THelloTh ereStuartB utton',nil );
if h<>0 then
begin
{to click the button if found}
sendmessage(h,WM_LBUTTONDO WN,0,0);
sendmessage(h,WM_LBUTTONUP ,0,0);
end
else showmessage('couldnt find button');
end;
there are other ways using callbacks but as long as the classnames are unique and you are creating app1 and app2 above should be just fine..
Regards Barry
there are a few ways i see to help this one i use ,in app b give the form a unique name as in "SomeUniqueNameForm" and give your components unique names also as in "HelloThereStuartButton".
this then gives a classname of "TSomeUniqueNameForm" and the button a classname of "THelloThereStuartButton"
so now in app1 you can do
var
h : thandle;
begin
h := findwindow('TSomeUniqueNam
h := FindWindowEx(h,0,'THelloTh
if h<>0 then
begin
{to click the button if found}
sendmessage(h,WM_LBUTTONDO
sendmessage(h,WM_LBUTTONUP
end
else showmessage('couldnt find button');
end;
there are other ways using callbacks but as long as the classnames are unique and you are creating app1 and app2 above should be just fine..
Regards Barry
THelloThereMadshiButton.Cl ick;
THelloBarry.Grin;
TG'dayBarry.Mate;
ASKER
InThe is right.
In fact, I want to create a component to send and to receive different informations as integer, single, pointer, string, etc.
So, I can create a procedure message in a form and send data with WM_COPYDATA. But If I want to create a component to realize this and reuse in many apps, I need to know the handle component in the receiving app.So FindWindowEx is the good solution. Like this I do the work one tume only.
I accept his good response.
Thanks to all ...
In fact, I want to create a component to send and to receive different informations as integer, single, pointer, string, etc.
So, I can create a procedure message in a form and send data with WM_COPYDATA. But If I want to create a component to realize this and reuse in many apps, I need to know the handle component in the receiving app.So FindWindowEx is the good solution. Like this I do the work one tume only.
I accept his good response.
Thanks to all ...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help.