Board index » delphi » ShowModal Form Hidden behind Parent Form

ShowModal Form Hidden behind Parent Form


2005-07-28 01:09:43 AM
delphi239
Sometimes when calling Form.ShowModal it will fall behind the parent form.
Sometimes it works fine. It seems to be that it has been occurring more
often on Windows XP SP2 though.
Has anyone else experienced this behavior? Is there a way to make sure that
the Modal form is shown on top by searching for the form handle?
-Shaq
 
 

Re:ShowModal Form Hidden behind Parent Form

Shaq writes:
Quote
Has anyone else experienced this behavior? Is there a way to make
sure that the Modal form is shown on top by searching for the form
handle?
Should be fixed in D2005.
--
Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
Delphi/InterBase Weblog : blogs.teamb.com/craigstuntz
IB 6 versions prior to 6.0.1.6 are pre-release and may corrupt
your DBs! Open Edition users, get 6.0.1.6 from mers.com
 

Re:ShowModal Form Hidden behind Parent Form

I am using Delphi 7. Is this a know problem with Delphi? I was trying to
blame it on Windows :-).
-Shaq
"Craig Stuntz [TeamB]" <XXXX@XXXXX.COM [a.k.a. acm.org]>wrote
in message news:42e7c30d$XXXX@XXXXX.COM...
Quote
Shaq writes:

>Has anyone else experienced this behavior? Is there a way to make
>sure that the Modal form is shown on top by searching for the form
>handle?

Should be fixed in D2005.

--
Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
Delphi/InterBase Weblog : blogs.teamb.com/craigstuntz
IB 6 versions prior to 6.0.1.6 are pre-release and may corrupt
your DBs! Open Edition users, get 6.0.1.6 from mers.com
 

Re:ShowModal Form Hidden behind Parent Form

Shaq writes:
Quote
I am using Delphi 7. Is this a know problem with Delphi? I was
trying to blame it on Windows :-).
It's a combination of Delphi and Windows issues. XP has a feature
called ghosting which will cause this behavior *if* the WndParent isn't
set to the calling window's handle in CreateParams. Delphi's VCL
doesn't do this until D2005. A workaround is to override CreateParams
in your modal dialog and assign it to the Handle of the calling window.
--
Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
Delphi/InterBase Weblog : blogs.teamb.com/craigstuntz
All the great TeamB service you've come to expect plus (New!)
Irish Tin Whistle tips: learningtowhistle.blogspot.com
 

Re:ShowModal Form Hidden behind Parent Form

Are we to understand that Borland know there is a severe problem for
those of us using D7, but they do not care to solve that problem and
want us to buy D2005 for our applications to work correctly on WinXP.
JONN
On 27 Jul 2005 13:16:39 -0700, "Craig Stuntz [TeamB]"
<XXXX@XXXXX.COM [a.k.a. acm.org]>writes:
Quote
Shaq writes:

>I am using Delphi 7. Is this a know problem with Delphi? I was
>trying to blame it on Windows :-).

It's a combination of Delphi and Windows issues. XP has a feature
called ghosting which will cause this behavior *if* the WndParent isn't
set to the calling window's handle in CreateParams. Delphi's VCL
doesn't do this until D2005. A workaround is to override CreateParams
in your modal dialog and assign it to the Handle of the calling window.
 

Re:ShowModal Form Hidden behind Parent Form

J-O Nyboe Nielsen writes:
Quote
Are we to understand that Borland know there is a severe problem for
those of us using D7, but they do not care to solve that problem and
want us to buy D2005 for our applications to work correctly on WinXP.
I told you what the workaround is. Do you not understand what I wrote?
You don't have to buy D2005 to use the workaround.
--
Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
Delphi/InterBase Weblog : blogs.teamb.com/craigstuntz
 

Re:ShowModal Form Hidden behind Parent Form

Hey Craig
I did not quite understand the workaraound.
So please tell me more.
TIA
JONN
On 3 Aug 2005 07:19:53 -0700, "Craig Stuntz [TeamB]"
<XXXX@XXXXX.COM [a.k.a. acm.org]>writes:
Quote
J-O Nyboe Nielsen writes:

>Are we to understand that Borland know there is a severe problem for
>those of us using D7, but they do not care to solve that problem and
>want us to buy D2005 for our applications to work correctly on WinXP.

I told you what the workaround is. Do you not understand what I wrote?
You don't have to buy D2005 to use the workaround.
 

Re:ShowModal Form Hidden behind Parent Form

In your form you have to override TCustomForm.CreateParams. Call
inherited, then assign the Handle property of the next lowest form in
the Z-order to Params.WndParent. If your main form opens a modal
dialog, for example, you will want to assign main form's Handle to
Params.WndParent in an overridden CreateParams for the modal dialog. If
that dialog opens another modal dialog, you then need to assign the
first dialog's handle to the Params.WndParent for the second dialog.
And so on and so forth.
This tells Windows the correct Z-order.
--
Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
Delphi/InterBase Weblog : blogs.teamb.com/craigstuntz
How to ask questions the smart way:
www.catb.org/~esr/faqs/smart-questions.html