Link to home
Start Free TrialLog in
Avatar of Alphomega
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?
Avatar of Stuart_Johnson
Stuart_Johnson

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('TSomeUniqueNameForm','either the forms caption with string quotes or nil without string quotes here');
h := FindWindowEx(h,0,'THelloThereStuartButton',nil);
if h<>0 then
 begin
       {to click the button if found}
  sendmessage(h,WM_LBUTTONDOWN,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
THelloThereMadshiButton.Click;
THelloBarry.Grin;
TG'dayBarry.Mate;
Avatar of Alphomega

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 ...
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help.