Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Detecting Full Screen

Posted on 2004-09-16
7
Medium Priority
?
361 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 400 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 600 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

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.

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…
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…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
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…

916 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