Solved

Detecting Full Screen

Posted on 2004-09-16
7
337 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
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

810 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