Solved

Detecting Full Screen

Posted on 2004-09-16
7
334 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
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 is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

15 Experts available now in Live!

Get 1:1 Help Now