Solved

Detecting Full Screen

Posted on 2004-09-16
7
330 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
  • 3
  • 2
7 Comments
 
LVL 6

Assisted Solution

by:Sergio_Hdez
Sergio_Hdez earned 200 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Expert Comment

by:cqhall
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now