Link to home
Start Free TrialLog in
Avatar of rossmcm
rossmcmFlag for New Zealand

asked on

Screen Savers and ShowModal

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?
 

Avatar of rwilson032697
rwilson032697

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

Cheers,

Raymond.

Avatar of simonet
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
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rossmcm

ASKER

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;



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
Avatar of rossmcm

ASKER

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