4

I have a fullscreen window with the Topmost property set to true. Whenever an application changes its WindowState property, my window is automatically minimized even though it has the active focus. For example, the code below exemplifies the problem. 3 seconds after the window is deactivated, it changes from Minimized to Normal, minimizing the other fullscreen application.

// Topmost = false
private void Form1_Deactivate(object sender, EventArgs e)
{
    System.Threading.Thread.Sleep(3000);
    this.WindowState = FormWindowState.Normal;
}

Is there a way to preserve the fullscreen window's WindowState property in such a case? I want the user to choose to minimize the fullscreen app, so I want to stop other programs from stealing the focus.

user246392
  • 2,661
  • 11
  • 54
  • 96
  • 6
    As a user, I really don't want apps doing that. FWIW. – T.J. Crowder Jan 18 '10 at 14:06
  • 2
    Please dont steal my focus: http://www.codinghorror.com/blog/archives/001011.html – SwDevMan81 Jan 18 '10 at 14:19
  • 5
    And the next StackOverflow question will be "how do I take focus even from a window that is actively preventing me from doing so?" You really want to start an arms race? – Eric Lippert Jan 18 '10 at 15:04
  • Thanks for your input, but my intention is not to start a competition. The link above you explains the annoyance users get from losing their focus. I also found out there are ways to display windows without stealing focus from others, so I believe applications should not have the right to steal focus. – user246392 Jan 18 '10 at 15:39
  • And how are you going to differentiate their having done so from (say) Alt+Tab? Ctrl+Esc? Task Manager? Frankly, it's the other apps that are misbehaving, changing their window state without the user's direct action. Your app should just leave things alone (IMHO). – T.J. Crowder Jan 18 '10 at 17:24
  • I would be extremely unhappy if I was doing something important (like dictating what my Ops manager is saying, for example) and stole my currently-focused app's focus - resulting in about half a sentence being inputted into your app. _However_, IMHO, that's still no reason to just not steal focus. Some apps might require your immediate attention, or action, so there are some very good use cases for this. I'm not against it so long as it's for a _very_ good reason - or if this is an expected behavior of your app (from the point of view of the user). – jay_t55 Jun 17 '13 at 11:01

3 Answers3

2

You may want to investigate "Kiosk Mode".

H H
  • 263,252
  • 30
  • 330
  • 514
0

Perhaps this is what you want: Windows Form in Full Screen "Kiosk Mode".

Otherwise I'll second Henk's recomendation.

Svish
  • 152,914
  • 173
  • 462
  • 620
El Padrino
  • 1,141
  • 1
  • 11
  • 26
0

If this is a kiosk application and you are the only program running on the computer then fine. Otherwise this is a really bad idea and that's why there is not a documented way of doing it. As Raymund Chen says this kind of question should be followed with the thought experiment "what if two programs did this?":

http://blogs.msdn.com/oldnewthing/archive/2005/06/07/426294.aspx

Phill
  • 1,302
  • 1
  • 9
  • 18