Solved

Detecting Full Screen

Posted on 2004-09-16
7
350 Views
Last Modified: 2010-08-05
I have a Delphi app that has the FormStyle property set to fsStayOnTop. The app needs to be on top of other apps - even when other apps are running in full screen mode (for example IE or Acrobat Reader).

What happens is that when an app goes into full screen mode a black box representing my app is displayed on top of the full screen application. (This can also be reproduced by opening Task Manager and then taking another app to full screen.) I need to detect the fact that another app has entered into full screen mode and then force my app to repaint. And here lies problem #2... Form.Repaint does not work. However, if I do a Form.Hide; Form.Show; all is well (would like to avoid the latter - but this is not critical).

Any ideas?
runebj
0
Comment
Question by:runebj
[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
  • 3
  • 2
7 Comments
 
LVL 6

Assisted Solution

by:Sergio_Hdez
Sergio_Hdez earned 200 total points
ID: 12082981
The task monitor example works fine on my XP (don't get blank).

Have you tried Form.Invalidate instead of Form.repaint?

About knowing if an app enter in full screen, you can trap all messages from windows and detect the desiered messaje, and then force the repainting. I don't really know how to do it (a hook?), but if it helps, here you have a "message trapping" code that only works when your app has the focus:

procedure TMyForm.OnFormCreate(sender);
begin
  AppEvent:= TApplicationEvents.create(AOwner);
  AppEvent.OnMessage:= NewOnMessage;
end;

procedure TMyForm.NewOnMessage(var Msg: TMsg; var Handled: Boolean);
begin
    if (Msg.Message = WM_KEYDOWN) then self.reapint;
end;

Ofcourse you should change WM_KEYDOWN to the exact message number of "full screen", and also trap the messages when your form doesn't have the focus, but... I know notjing about hooks!
0
 
LVL 1

Author Comment

by:runebj
ID: 12083204
Thanks for the feedback.

First of all, my app does not have focus. Also, I don't know which message to monitor. I can write a hook, but I still haven't been able to find any message, flag or other signal that is passed/set when an app goes into full screen mode.

Btw. I've also tried Invalidate. It does nothing. It seems that Windows figures "if one app is in full screen mode, no other app can possibly be visible, so ignore paint messages".

Any more ideas?
runebj
0
 
LVL 2

Accepted Solution

by:
cqhall earned 300 total points
ID: 12088490
I grabbed this code from a Delphi website awhile back.  It was supposed to help when you "really, really" want your form on top.  However, in limited testing it didn't suppress Delphi's Alignment Palette  (AP) when the AP was set to "Stay On Top" (right-click on the AP).  However, it may elevate your form enough for your purpose.  OR maybe you could find some additional parameters to give it more resilience.

Procedure SetFormOnTop(form: tForm);
begin
 with Form do
 begin
  SetWindowPos(Handle, HWND_TOPMOST, Left, Top, Width, Height, SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
 end;
end;

Procedure SetFormNotOnTop(form: tForm);
begin
 with Form do
 begin
  SetWindowPos(Handle, HWND_NOTOPMOST, Left, Top, Width, Height, SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
 end;
end;
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Expert Comment

by:cqhall
ID: 12088547
I looked again at your objective and tested the code with IE in "Full Screen" (F11) and Acrobat Reader 5 (in windows style full screen) and my form remained on top.  I created a simple app with a checkbox containing the following OnClick event handler...

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
 If CheckBox1.checked then
 begin
  SetFormOnTop(self);
 end else
 begin
  SetFormNotOnTop(self);
 end;
end;

I hope it does the job for you!

Chuck
0
 
LVL 1

Author Comment

by:runebj
ID: 12158863
Hi Chuck,

Sorry for not getting back to you sooner, but I've been away for a week. I already use the API call you specify to set the window to stay on top, but reissuing the command does not help. That is - it works for IE, but not for Acrobat reader. It looks like IE simply maximizes itself and removes borders and menus, but it does not really go into full screen mode (the taskbar is still there).

Thank you very much for the effort though...

All the best,
Runebj
0
 
LVL 1

Author Comment

by:runebj
ID: 13343379
Sorry for not finalizing before - must have slipped my mind...

My question was not really answered, but I split the points between the two respondants anyway as the answers given may very well help others and to thank them for their efforts.

All the best,
Runebj
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month6 days, 18 hours left to enroll

622 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