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

Modal Forms

56 views
Skip to first unread message

Ed Arthur

unread,
Jun 10, 2005, 9:58:24 PM6/10/05
to
I am using Delphi 7 & XP.

My end users are using xp, 2000, & 98

I previously had a problem that if my app was minimized and restored that
modal messages would be behind the parent.

Now all the sudden it happens all the time....

Any one know why?

Thanks,

Ed Arthur


Peter Below (TeamB)

unread,
Jun 11, 2005, 6:21:03 AM6/11/05
to

In a D7 (and older) app all forms are siblings in the Windows window
hierarchy since they are all owned by the zero-size Application window.
Windows has gotten progressively worse at keeping relative Z order of
siblings. Granted, the root problem is that modal windows in Delphi are not
tied to their callers in Z order like modal dialogs in Windows are supposed
to be, but there were little problems with this design in Win9x and Win2K.

Delphi 2005 addresses this problem with the PopupMode and PopupParent
properties, but in older versions you have to deal with this yourself.

For your own forms you need to show modally override the CreateParams method
as follows:

public
{ Public declarations }
Procedure CreateParams( Var params: TCreateParams ); override;

procedure TFormX.CreateParams(var params: TCreateParams);
begin
inherited;
if owner is tform then
params.WndParent := (Owner as twincontrol).Handle
else if Assigned(Screen.ActiveForm) then
params.WndParent := Screen.ActiveForm.Handle;
end;

Unfortunately you cannot do the same for the dialogs from the Dialogs unit
without modifying the source for that unit, which only works if you do not
need to build your application with run-time packages. The easiest
alternative is to just use Windows.MessageBox instead of ShowMessage and
MessageDlg, it allows you to specify the handle of the owner window.


--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be


0 new messages