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?
AlphomegaAsked:
Who is Participating?
 
intheConnect With a Mentor Commented:
cheers ;-)
0
 
Stuart_JohnsonCommented:
Listening...
0
 
kserCommented:
 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 ?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
MadshiCommented:
Alphomega, what do you know of the TEdit component? Do you have it's window handle? Or what do you have?
0
 
intheCommented:
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
0
 
intheCommented:
THelloThereMadshiButton.Click;
0
 
MadshiCommented:
THelloBarry.Grin;
0
 
Stuart_JohnsonCommented:
TG'dayBarry.Mate;
0
 
AlphomegaAuthor Commented:
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 ...
0
 
AlphomegaAuthor Commented:
Thanks for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.