Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Screen Savers and ShowModal

Posted on 1999-07-19
7
Medium Priority
?
279 Views
Last Modified: 2010-04-06
I have an app that detects when a file if changed on disk and pops up a modal dialog when this occurs asking the user if they want to load the new file.  This works fine until the screen saver kicks in.  If the modal dialog pops up after the screen saver kicks in, then the mouse is moved and the main form repaints, the modal dialog is behind the main form but has the focus.

You can get it back to the front with Alt-Tab, but it is confusing for users, as they don't know the pop-up is there and when they click on the main form they get a beep (as the hidden modal form has focus).  They usually end up killing the task or the machine, even though they don't need to.

I've tried BringToFront anf fsStayOnTop.  How can you force a form to the front when its owner is repainted after a screen save?
 

0
Comment
Question by:rossmcm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1389761
You could use a thread that periodically (second or so), forces the modal dialog to the top with ShowWindow...

Cheers,

Raymond.

0
 
LVL 15

Expert Comment

by:simonet
ID: 1389762
You can make the dialog window detect if the screen saver is running before it shows it self. If the screen saver is indeed running, then the dialog closes the SS and shows itself.

You can use SystemParametersInfo for the above.

let me know if this solution works for you and if you need help implementing it. I have some code here (just can't find them now!) that can do what I mentioned above.

Yours,

Alex
0
 
LVL 17

Accepted Solution

by:
inthe earned 400 total points
ID: 1389763
Hi all,
you are forgetting the SetForeGroundWindow api which is for this purpose..
just do this when you call the modal dialog:

var
 Modal_dlg_Wnd : HWND;
begin      
 your_modal_form.showmodal;
  Modal_dlg_Wnd := FindWindow(Nil,'Form1');
              {replace 'Form1' with the modal forms caption}
 SetForeGroundWindow(Modal_dlg_Wnd);
end;

this will show your dialog form as the topmost window and if the screensaver is running it will first stop the screensaver.
Regards Barry

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:rossmcm
ID: 1389764
Hey, not quite the solution, it turns out, because the thread doesn't return from the call to ShowModal until the dialog is closed, so the SetForeGroundWindow doesn't get executed yet.  Am I missing somwthing here ?

Ross.  

var
 Modal_dlg_Wnd : HWND;
begin        
 your_modal_form.showmodal;
  Modal_dlg_Wnd := FindWindow(Nil,'Form1');
              {replace 'Form1' with the modal forms caption}
 SetForeGroundWindow(Modal_dlg_Wnd);
end;



0
 
LVL 17

Expert Comment

by:inthe
ID: 1389765
Hi
2 possible ideas:
1) just call form.show; {not form.showmodal}
2) as above and set formstyle to bsdialog as well.
try them and see wghat turns out.
Regards Barry
0
 

Author Comment

by:rossmcm
ID: 1389766
the form needs to be modal.

I tried adding the SetForegroundWinbdow stuff to the OnShow method instead of after the ShowModal - no change to behaviour.

Ross
0
 
LVL 17

Expert Comment

by:inthe
ID: 1389767
what about SetForegroundWindow on a timer event ,that is how i use it anyway..and how the demo in my winapi book uses it.see if that works instead.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question