|
| Re: one form influencing another |
 |
Tue, 5 Sep 2006 10:20:43 -0400 |
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
|
| Post Reply
|
| one form influencing another |
 |
Tue, 05 Sep 2006 12:30:07 +020 |
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.)
TIA.
|
| Post Reply
|
| Re: one form influencing another |
 |
Thu, 07 Sep 2006 11:53:35 +020 |
On Tue, 05 Sep 2006 16:20:43 +0200, Wayne Niddery [TeamB]
<wniddery@chaffaci.on.ca> wrote:
> const
> wm_MyCustomMessage = wm_user + 2006;
> // any # is good here as long as it's not used elsewhere in your app
And what is wm_user? It's flagged up as undefined identifier :-(
TIA.
|
| Post Reply
|
| Re: one form influencing another |
 |
Thu, 07 Sep 2006 11:56:25 +020 |
On Tue, 05 Sep 2006 16:20:43 +0200, Wayne Niddery [TeamB]
<wniddery@chaffaci.on.ca> wrote:
> procedure MyCustomMessage(var msg: TMessage); message
> wm_MyCustomMessage;
TMessage is also unknown. What uses clause do I need, please?
TIA.
|
| Post Reply
|
| Re: one form influencing another |
 |
Thu, 7 Sep 2006 12:19:36 -0400 |
Brigitte Spatz wrote:
> On Tue, 05 Sep 2006 16:20:43 +0200, Wayne Niddery [TeamB]
> <wniddery@chaffaci.on.ca> wrote:
>
>> const
>> wm_MyCustomMessage = wm_user + 2006;
>> // any # is good here as long as it's not used elsewhere in your
>> app
>
> And what is wm_user? It's flagged up as undefined identifier :-(
Add Windows to your Uses clause (for all 4 reported problems I see
currently).
--
Wayne Niddery - Winwright, Inc (www.winwright.ca)
"In a tornado, even turkeys can fly." - unknown
|
| Post Reply
|
|
|
|
|
|
|
|
|
|