dirkil2
asked on
Delphi 7 modal form hides behind window on a Windows 7 box
When we run our application that is written in Delph7 on a Windows 7 box, some modal forms hide behind the calling window and then the user can't do anything except killing the process. We will switch in a few months to Delphi 2010 and I heard that this problem will be gone then. But it's not acceptable for our WIndows 7 users to wait until then.
Do you have any idea how we can get around this situation? How can we make sure that the z-order of the forms is correct?
Or is there a way for the user to make the modal form come to the top? Alt-TAB doesn't help.
Any help is very much appreciated.
Regards,
Dirk.
Do you have any idea how we can get around this situation? How can we make sure that the z-order of the forms is correct?
Or is there a way for the user to make the modal form come to the top? Alt-TAB doesn't help.
Any help is very much appreciated.
Regards,
Dirk.
for the user, a possible solution
Alt-Tab 2x
this doesn't allways help
aflarin's --> that's a little vague isn't it ?
i'll set up a sample, give me a minute
Alt-Tab 2x
this doesn't allways help
aflarin's --> that's a little vague isn't it ?
i'll set up a sample, give me a minute
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
nice code Geert_Gruwez :)
ok. The issue may happen if the last created non-modal form overlaps modal form too.
But it doesn't reject my solution.
ok. The issue may happen if the last created non-modal form overlaps modal form too.
But it doesn't reject my solution.
Just trying to help...
I once made the mistake of calling modal forms which called modal forms which called modal forms, and some of them were formstyle fsStayOnTop. If you intend to call forms as modal you don't need them to be fsStayOnTop -- ideally you should make all your forms fsNormal or whatever, stayOnTop I think is nice for MDI applications.
I once made the mistake of calling modal forms which called modal forms which called modal forms, and some of them were formstyle fsStayOnTop. If you intend to call forms as modal you don't need them to be fsStayOnTop -- ideally you should make all your forms fsNormal or whatever, stayOnTop I think is nice for MDI applications.
>>aflarin
i didn't mean reject, i meant you had a typo : it's YourLastModalForm
but i was interested in your implementation of that variable/function ...
i didn't mean reject, i meant you had a typo : it's YourLastModalForm
but i was interested in your implementation of that variable/function ...
@Geert_Gruwez
You won't believe me, but I haven't ever got overlapped forms in my apps. But maybe our users keep that secret :-)
But if that happened, I would get the last modal in Screen too... or define my own ShowModal procedure where the form would be stored in my own LastModal variable... or (that's more probable) would try to get rid of superfluous forms.
You won't believe me, but I haven't ever got overlapped forms in my apps. But maybe our users keep that secret :-)
But if that happened, I would get the last modal in Screen too... or define my own ShowModal procedure where the form would be stored in my own LastModal variable... or (that's more probable) would try to get rid of superfluous forms.
Application has onModalBegin event, but unfortunately there isn't a way to get Form variable there :(
BTW, it a good idea to inherit all project forms from your own TForm descendant.
BTW, it a good idea to inherit all project forms from your own TForm descendant.
ASKER
Hi guys!
Many thanks for your thoughts and your great sample! I can't test it in my environment but I prepared a test version of our software with it that we will try on the client's side that reported the problem. I will keep you posted.
Many thanks for your thoughts and your great sample! I can't test it in my environment but I prepared a test version of our software with it that we will try on the client's side that reported the problem. I will keep you posted.
ASKER
We found a workaround: after creating the form object and just before ShowModal we call BringToFron on the form. Inside the form we added a timer that fires after 1000ms and calls BringToFront again. This seems to do the trick.
I award Geert_Gruwe the points since he put me on the right track with his timer idea.
I award Geert_Gruwe the points since he put me on the right track with his timer idea.
I checked all proposed soulutions in this (and othew newsgroups too) and none of them solved my problem.
I have several forms which I activate from main form and from other forms, i.e cascaded form activation. Only one form among others has been hided while rest of them worked well. At the end I found a solution which might be helpfull.
It seems to me, that Delphi7 has some troubles in saving form declaration (.dfm). Before this workaround I deleted .dsm file but with no success.
Then I opened new form, copied into it all components and all code from this hiding form to the new one. Voila! Things are working!
I have several forms which I activate from main form and from other forms, i.e cascaded form activation. Only one form among others has been hided while rest of them worked well. At the end I found a solution which might be helpfull.
It seems to me, that Delphi7 has some troubles in saving form declaration (.dfm). Before this workaround I deleted .dsm file but with no success.
Then I opened new form, copied into it all components and all code from this hiding form to the new one. Voila! Things are working!
Application.OnActivate:= ApplicationActivate;
procedure TMyObject.ApplicationActiv
begin
SetForegroundWindow( YouLastModalForm );
end;