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
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!
> 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
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.
>
>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."
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.