Google 网上论坛不再支持新的 Usenet 帖子或订阅项。历史内容仍可供查看。

Overriding CreateParams and Child Form Z-Order

已查看 296 次
跳至第一个未读帖子

Billy Nice

未读,
1999年11月9日 03:00:001999/11/9
收件人
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)

未读,
1999年11月9日 03:00:001999/11/9
收件人
> 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

未读,
1999年11月23日 03:00:001999/11/23
收件人

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

未读,
1999年12月7日 03:00:001999/12/7
收件人
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

未读,
1999年12月8日 03:00:001999/12/8
收件人
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)

未读,
1999年12月8日 03:00:001999/12/8
收件人
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 个新帖子