Board index » delphi » Access a form's control via that form's handle?

Access a form's control via that form's handle?

Can I use a form's handle to somehow reference that form so as to
change the status of a control on that form? If so , how?

ash

 

Re:Access a form's control via that form's handle?


Quote
Smitherbee wrote:

> Can I use a form's handle to somehow reference that form so as to
> change the status of a control on that form? If so , how?

> ash

Not having the IDE open, from memory...

Define in your form holding the control

const
 cm_MyMessage = wm_user+100; // or any +ve number < 32k-ish

procedure foobar(aMessage:TMessage); message cm_MyMessage;
...

begin
  with aMessage do begin

    // your action goes in here!    

    case wParam of        // could be if then else or whatever
      55 : do_something;  // if needed choose your actions
    end

  end;
end;

in your main form  send the command

 ...
 PostMessage(ChildForm.Handle,cm_MyMessage,55,0); // arbitary value 55
 ...

Check out "message" in the on-line help for more info!

BTW you can use windows messages in exactly the same way
to control the object if you know the controls handle and
you know the wm_xxxxxx message constant and parameters.

Happy Hunting

Railton....

Re:Access a form's control via that form's handle?


Quote
Smitherbee wrote...

|Can I use a form's handle to somehow reference that form so as to
|change the status of a control on that form? If so , how?
|
Why would you use the handle?
Just do SomeForm.SomeComponent.SomeProperty = SomeValue.
(and put  <name of unit that defines TSomeForm> in the uses clause of
the calling form.

Regards,
Dirk Claessens
______________________________________________
Home   : <dirk.claess...@village.uunet.be>
Office : <dirk.claessens...@belgium.agfa.com>
"All programming is done with the glands.
 Logic is added later to tidy things up."
______________________________________________

Other Threads