Board index » delphi » How Can I Access Delphi Form Objects With Windows Handle

How Can I Access Delphi Form Objects With Windows Handle

Hi to all.

I have a need to change a property on a Delphi Form (MyLabel.Caption)
running independently to my application with only the PID and HNDL as
identity of this form object.

var
  MyHandle: HWND;

//  (Handle as TForm).MyLabel.Caption:= 'Hi';
    MyHandle:= Handle;
    with MyHandle as TForm begin
      MyLabel.Caption:= 'Hi';
    end;

Please advise the best way to do this

Thanks In Advance

Andrew Hill

 

Re:How Can I Access Delphi Form Objects With Windows Handle


Quote
Andrew Hill wrote:
> I have a need to change a property on a Delphi Form (MyLabel.Caption)
> running independently to my application with only the PID and HNDL as
> identity of this form object.

> var
>   MyHandle: HWND;

> //  (Handle as TForm).MyLabel.Caption:= 'Hi';
>     MyHandle:= Handle;
>     with MyHandle as TForm begin
>       MyLabel.Caption:= 'Hi';
>     end;

> Please advise the best way to do this

Add a feature to the other program so that it can accept an external
command to change the caption of one of its controls.

There are a few ways to send a string from one process to another. One
way is to use the wm_CopyData message. You can also use DDE, or named pipes.

--
Rob

Re:How Can I Access Delphi Form Objects With Windows Handle


Thanks Rob, I was hoping not to build message listening logic into the other
application.

I guess I wanted a magic generic solution.

Quote
"Rob Kennedy" <m...@privacy.net> wrote in message

news:45660d48$1@newsgroups.borland.com...
Quote
> Andrew Hill wrote:
>> I have a need to change a property on a Delphi Form (MyLabel.Caption)
>> running independently to my application with only the PID and HNDL as
>> identity of this form object.

>> var
>>   MyHandle: HWND;

>> //  (Handle as TForm).MyLabel.Caption:= 'Hi';
>>     MyHandle:= Handle;
>>     with MyHandle as TForm begin
>>       MyLabel.Caption:= 'Hi';
>>     end;

>> Please advise the best way to do this

> Add a feature to the other program so that it can accept an external
> command to change the caption of one of its controls.

> There are a few ways to send a string from one process to another. One way
> is to use the wm_CopyData message. You can also use DDE, or named pipes.

> --
> Rob

Re:How Can I Access Delphi Form Objects With Windows Handle


Quote
Andrew Hill wrote:
> Thanks Rob, I was hoping not to build message listening logic into
> the other application.

> I guess I wanted a magic generic solution.

There is none since a VCL TLabel is not a TWinControl. So it has no
window handle and cannot be remote-controlled through messages.

If you need that you have to use a TStaticText instead of TLabel, that
does have a window handle. But that is still a worse solution than
building a remote-control mechanism into the app like Rob suggested.
You see, there is nothing available to the outside app that would allow
you to figure out the window handle of the static control in a robust
manner...

--
Peter Below (TeamB)  
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Other Threads