Article View: borland.public.delphi.winforms.controls.using
Article #241Re: one form influencing another
From: Wayne Niddery [TeamB]
Date: Tue, 05 Sep 2006 14:20
Date: Tue, 05 Sep 2006 14:20
43 lines
2511 bytes
2511 bytes
Brigitte Spatz wrote:
> When a certain event happens on one of my forms (non-MDI), I want
> something else to happen on the main form (which is an MDI parent and
> I want all children to close). How do I do this? (I know how to close
> all MDI children from the MDI parent but I don't know how to do this
> from another form. Simply calling the MDI parent's Close_All
> procedure gives an error message along the lines of "only allowed for
> class methods" but I can't make Close_All a class method as it needs
> to refer to itself.)
Post a message to the main form. In the main form, define a custom message
and matching method:
const
wm_MyCustomMessage = wm_user + 2006;
// any # is good here as long as it's not used elsewhere in your app
type
TForm1 = class(TForm)
{...}
protected
procedure MyCustomMessage(var msg: TMessage); message
wm_MyCustomMessage;
{...}
procedure TForm1.MyCustomMessage(var msg: TMessage);
begin
// close MDI kids here
end;
Now in your other form, you need to have the main form unit in the Uses
clause, then you can just do:
PostMessage(Application.Mainform.Handle, wm_MyCustomMessage, 0, 0);
If you need to have the MDI kids closed before the other form can proceed
further, then use SendMessage instead of PostMessage.
--
Wayne Niddery - Winwright, Inc (www.winwright.ca)
"Reality is that which, when you stop believing in it, doesn't go
away." - Philip K. Dick
Technical Details
Message-ID:
<44fd87b9$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!ecngs!feeder.ecngs.de!newsfeed.freenet.de!news.albasani.net!reader.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mailReferences:
<op.tfeh4mb0i0jcwv@acer>Show Full Headers
Complete Article Headers
X-Google-Thread: 1eff29,bdf5a6ead14cc213 X-Google-Attributes: gid1eff29,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Wayne Niddery [TeamB]" <wniddery@chaffaci.on.ca> From: "Wayne Niddery [TeamB]" <wniddery@chaffaci.on.ca> Newsgroups: borland.public.delphi.winforms.controls.using References: <op.tfeh4mb0i0jcwv@acer> Subject: Re: one form influencing another Date: Tue, 5 Sep 2006 10:20:43 -0400 Lines: 45 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 69.17.150.141 Message-ID: <44fd87b9$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1157466041 69.17.150.141 (5 Sep 2006 07:20:41 -0700) X-Authenticated-User: wniddery Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!ecngs!feeder.ecngs.de!newsfeed.freenet.de!news.albasani.net!reader.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail