Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Overriding CreateParams and Child Form Z-Order

287 views
Skip to first unread message

Billy Nice

unread,
Nov 9, 1999, 3:00:00 AM11/9/99
to
Having made the child Windows of my application appear on the taskbar by
overriding the CreateParams method like so:

procedure TChildForm.CreateParams(var Params : TCreateParams);
begin
inherited;
Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
Params.WndParent := GetDesktopWindow;
end;

When I now invoke a modal dialog from the child windows then the main form
is brought to the front and the child window is sent to the back and the
modal dialog appears over the main window. How can I avoid this and still
have the child windows appearing on the taskbar?

Thanks,

Billy

Peter Below (TeamB)

unread,
Nov 9, 1999, 3:00:00 AM11/9/99
to
> Having made the child Windows of my application appear on the taskbar by
> overriding the CreateParams method like so:
> When I now invoke a modal dialog from the child windows then the main form
> is brought to the front and the child window is sent to the back and the
> modal dialog appears over the main window. How can I avoid this and still
> have the child windows appearing on the taskbar?

You have to parent the modal form to the child window, that is: you create
them with child form as owner, not with Application as owner, and then
override their CreateParams method like this:

procedure TForm3.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.ExStyle := Params.ExStyle or WS_POPUP;
Params.WndParent := TWinControl(Owner).handle;
end;

This cannot be done for the standard dialogs from the Dialogs unit, so use
Windows.messageBox instead of ShowMessage or MessageDlg and pass the
childforms handle.

Peter Below (TeamB) 10011...@compuserve.com)
No replies in private e-mail, please, unless explicitly requested!


Billy Nice

unread,
Nov 23, 1999, 3:00:00 AM11/23/99
to

Peter Below (TeamB) <10011...@compuXXserve.com> wrote in message
news:VA.00004080.00bf32cf@noname...

> > Having made the child Windows of my application appear on the taskbar by
> > overriding the CreateParams method like so:
> > When I now invoke a modal dialog from the child windows then the main
form
> > is brought to the front and the child window is sent to the back and the
> > modal dialog appears over the main window. How can I avoid this and
still
> > have the child windows appearing on the taskbar?
>
> You have to parent the modal form to the child window, that is: you create
> them with child form as owner, not with Application as owner, and then
> override their CreateParams method like this:
>
So, do I need to set the Parent property of the modal form, or are we just
talking ownership i.e. TModalForm.Create(MyChildForm)?

> procedure TForm3.CreateParams(var Params: TCreateParams);
> begin
> inherited;
> Params.ExStyle := Params.ExStyle or WS_POPUP;
> Params.WndParent := TWinControl(Owner).handle;
> end;
>

Is the CreateParams for the Child or Modal form?


> This cannot be done for the standard dialogs from the Dialogs unit, so use
> Windows.messageBox instead of ShowMessage or MessageDlg and pass the
> childforms handle.

Okay, I'm now using Windows.MessageBox and its working for MessageBox
dialog. Thanks!
Can you answer my questions about my own modal forms above?

Thanks again,

Billy

Billy Nice

unread,
Dec 7, 1999, 3:00:00 AM12/7/99
to
An ExStyle including WS_POPUP causes an EWin32Error exception on Windows NT
but doesn't on Win98. Can someone tell me if this is a true statement? See
the CreateParams method below:

Peter Below (TeamB) <10011...@compuXXserve.com> wrote in message
news:VA.00004080.00bf32cf@noname...
> > Having made the child Windows of my application appear on the taskbar by
> > overriding the CreateParams method like so:
> > When I now invoke a modal dialog from the child windows then the main
form
> > is brought to the front and the child window is sent to the back and the
> > modal dialog appears over the main window. How can I avoid this and
still
> > have the child windows appearing on the taskbar?
>
> You have to parent the modal form to the child window, that is: you create
> them with child form as owner, not with Application as owner, and then
> override their CreateParams method like this:
>

> procedure TForm3.CreateParams(var Params: TCreateParams);
> begin
> inherited;
> Params.ExStyle := Params.ExStyle or WS_POPUP;
> Params.WndParent := TWinControl(Owner).handle;
> end;
>

> This cannot be done for the standard dialogs from the Dialogs unit, so use
> Windows.messageBox instead of ShowMessage or MessageDlg and pass the
> childforms handle.
>

Bradley Stowers

unread,
Dec 8, 1999, 3:00:00 AM12/8/99
to
On Tue, 7 Dec 1999 16:04:33 -0000, "Billy Nice" <bn...@metastorm.com> wrote:

>An ExStyle including WS_POPUP causes an EWin32Error exception on Windows NT
>but doesn't on Win98. Can someone tell me if this is a true statement? See
>the CreateParams method below:

>Peter Below (TeamB) <10011...@compuXXserve.com> wrote in message
>news:VA.00004080.00bf32cf@noname...

>> procedure TForm3.CreateParams(var Params: TCreateParams);
>> begin
>> inherited;
>> Params.ExStyle := Params.ExStyle or WS_POPUP;
>> Params.WndParent := TWinControl(Owner).handle;
>> end;


It doesn't cause an error on my NT4 SP6 machine. But, I can see where it might
be a problem. WS_POPUP isn't an extended style, so it probably shouldn't be
used in ExStyle, only in Style. I had a quick look at the source and the value
of WS_POPUP ($80000000) doesn't map to any of the WS_EX_xxx values, so it's hard
to say what Windows is interpretting the value to mean.

--Brad

Regards,
Brad Stowers
Delphi Free Stuff -- http://www.delphifreestuff.com/
"If you're a professional Delphi programmer who hasn't read
the Object Pascal Language Guide, then you're not."

Peter Below (TeamB)

unread,
Dec 8, 1999, 3:00:00 AM12/8/99
to
In article <82jaqd$rs...@forums.borland.com>, Billy Nice wrote:
> In ExStyle including WS_POPUP causes an EWin32Error exception on Windows
NT
> but doesn't on Win98. Can someone tell me if this is a true statement?
>

Jesus, that routine contained a wicked error. Of course it should modify
Params.Style, not Params.ExStyle! WS_POPUP = $80000000, there is no matching
WS_EX_* style with the same value. Win9x probably ignores invalid style bits
but NT does not.

0 new messages