12 Replies - 2724 Views - Last Post: 11 June 2011 - 07:23 AM Rate Topic: -----

#1 lwstory  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 16
  • Joined: 29-October 07

Prevent Full Screen Applications From Drawing On A Windows Form

Posted 09 June 2011 - 03:58 PM

Hello everyone,

I am working on a project where I need a windows form to be on top of any open application. Since my form is docked, most issues are solved. My only problem I have is when certain full screen applications are started, they draw over top of my form. I would like to reach at least one of the following scenarios:
1.) Be able to notify the user and prompt whether or not the full screen app should go full screen.
2.) The best case scenario would be to allow the Full Screen Application but prevent it from drawing over my form.

If anyone knows of a solution/direction regardless of complexity please let me know. Thanks in advanced!

Is This A Good Question/Topic? 0
  • +

Replies To: Prevent Full Screen Applications From Drawing On A Windows Form

#2 ragingben  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 177
  • View blog
  • Posts: 646
  • Joined: 07-October 08

Re: Prevent Full Screen Applications From Drawing On A Windows Form

Posted 10 June 2011 - 02:12 AM

This may not be pretty, but I think API is the answer. There must be a windows message for when a window is opening. You could catch this by overriding the WndProc method on your main form
protected override void WndProc(ref Message m)
{
    base.WndProc(ref m);
}


Then by using the GetForegroundWindow and SetForegroundWindow methods of the API you can just make your window fullscreen again, which will put it infront of the other window. You may also need the IsWindowVisible method.
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern bool IsWindowVisible(IntPtr hWnd);

[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr GetForegroundWindow();

[DllImport("User32.dll")]
public static extern Int32 SetForegroundWindow(int hWnd);


This is by no means a complete solution, but should get you atleast hgeading in the right direction :)
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6245
  • View blog
  • Posts: 24,013
  • Joined: 23-August 08

Re: Prevent Full Screen Applications From Drawing On A Windows Form

Posted 10 June 2011 - 03:24 AM

Required reading. I know you think your app is the most super-special, but really...it's not. Don't mess with the user's desktop experience.
Was This Post Helpful? 3
  • +
  • -

#4 ragingben  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 177
  • View blog
  • Posts: 646
  • Joined: 07-October 08

Re: Prevent Full Screen Applications From Drawing On A Windows Form

Posted 10 June 2011 - 04:21 AM

View PostJackOfAllTrades, on 10 June 2011 - 11:24 AM, said:

Required reading. I know you think your app is the most super-special, but really...it's not. Don't mess with the user's desktop experience.

Great read
Was This Post Helpful? 0
  • +
  • -

#5 lwstory  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 16
  • Joined: 29-October 07

Re: Prevent Full Screen Applications From Drawing On A Windows Form

Posted 10 June 2011 - 07:12 AM

Interesting, I would think that doing this may cause other applications to fight for who is on top as I recently found in this article. Would it be possible to define the area for the full screen window using user32.dll? Or better yet, could I define the area for all full screen windows that will open? Thanks!
Was This Post Helpful? 0
  • +
  • -

#6 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5101
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: Prevent Full Screen Applications From Drawing On A Windows Form

Posted 10 June 2011 - 07:18 AM

Wow, you took totally the wrong message from that. It's saying to just let it go, and not try to restrict other applications.
Was This Post Helpful? 0
  • +
  • -

#7 ragingben  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 177
  • View blog
  • Posts: 646
  • Joined: 07-October 08

Re: Prevent Full Screen Applications From Drawing On A Windows Form

Posted 10 June 2011 - 07:21 AM

Did you get the point of the article and JackOfAllTrades post? Agreed about not messing with the users desktop experience, why does the app always need to be on top? Is it for a dedicated MCI or something like that?
Was This Post Helpful? 0
  • +
  • -

#8 lwstory  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 16
  • Joined: 29-October 07

Re: Prevent Full Screen Applications From Drawing On A Windows Form

Posted 10 June 2011 - 08:32 AM

The application is used to allow people that are unable to use a mouse and keyboard the ability to use the computer with a single switch device. The way they navigate the computer is in this form. So, when a full screen application launches, obviously things become problematic. The user wont be able to see their navigation options.

This post has been edited by lwstory: 10 June 2011 - 08:46 AM

Was This Post Helpful? 0
  • +
  • -

#9 ragingben  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 177
  • View blog
  • Posts: 646
  • Joined: 07-October 08

Re: Prevent Full Screen Applications From Drawing On A Windows Form

Posted 10 June 2011 - 08:44 AM

As I see, I guess things kind of change when it is a specialist app such as that.

In that case, and at the risk of being a complete cowboy, I would always force the app to be on top by using the API, but I would have four arrowed buttons that snap the app to any side of the screen, so that it is easily moveable if they need to see what is beneath, if you get what I mean? I wouldn't interfere with any other app other than your own for this though. Just always call topmost on yours when another app opens.

Incidently here is a link for detecting when another app opens
Was This Post Helpful? 0
  • +
  • -

#10 lwstory  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 16
  • Joined: 29-October 07

Re: Prevent Full Screen Applications From Drawing On A Windows Form

Posted 10 June 2011 - 08:47 AM

As for what I said earlier:

View Postlwstory, on 10 June 2011 - 08:12 AM, said:

I would think that doing this may cause other applications to fight for who is on top as I recently found in this article

I was talking about what ragingben had to say. I actually missed the two posts after him which led to some confusion. Ironically I found the same article before it was posted. I will make sure I quote next time.
Was This Post Helpful? 0
  • +
  • -

#11 lwstory  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 16
  • Joined: 29-October 07

Re: Prevent Full Screen Applications From Drawing On A Windows Form

Posted 10 June 2011 - 10:05 AM

View Postragingben, on 10 June 2011 - 09:44 AM, said:

As I see, I guess things kind of change when it is a specialist app such as that.

In that case, and at the risk of being a complete cowboy, I would always force the app to be on top by using the API, but I would have four arrowed buttons that snap the app to any side of the screen, so that it is easily moveable if they need to see what is beneath, if you get what I mean? I wouldn't interfere with any other app other than your own for this though. Just always call topmost on yours when another app opens.

Incidently here is a link for detecting when another app opens


Thanks, I will look into trying this.
Was This Post Helpful? 0
  • +
  • -

#12 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon


Reputation: 6979
  • View blog
  • Posts: 14,601
  • Joined: 16-October 07

Re: Prevent Full Screen Applications From Drawing On A Windows Form

Posted 10 June 2011 - 10:31 AM

View Postlwstory, on 10 June 2011 - 11:32 AM, said:

when a full screen application launches, obviously things become problematic. The user wont be able to see their navigation options.


There is a difference between "always on top" and "always accessible." In a Windows environment, I'd put such an application in the system tray. A normal full screen application wouldn't clobber that, so you'd always have access.

Even applications like Media Player and games, that take the whole screen, can usually be configured to run in a window. If they're in a window, they can't block the system tray.
Was This Post Helpful? 0
  • +
  • -

#13 lwstory  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 16
  • Joined: 29-October 07

Re: Prevent Full Screen Applications From Drawing On A Windows Form

Posted 11 June 2011 - 07:23 AM

View Postbaavgai, on 10 June 2011 - 11:31 AM, said:

I'd put such an application in the system tray. A normal full screen application wouldn't clobber that, so you'd always have access.


I'm not quite sure what you mean here. Are you saying that if I put the application in the system tray, the user would then be able to operate the application at any time? If so, that issue is taken care of. The application listens to events even if it is not focused. Our issue is just the matter of having the application displayed for the user to choose what to do next. Worse case scenario, we will have to warn the user not to run full screen applications and to run them in a windowed mode.

View Postragingben, on 10 June 2011 - 09:44 AM, said:

I wouldn't interfere with any other app other than your own for this though. Just always call topmost on yours when another app opens.

Incidently here is a link for detecting when another app opens


Thanks again! I will look into this.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1