1

I have a C# Windows Forms program, in Windows 7, but I think it applies to any Windows program.

The main form of my program covers the entire screen, and has the Topmost property set. However, when I click the Start key to open the Start menu for example, the taskbar and Start Menu are displayed, on top of my Always on Top form.

Is there a window message (WM_) that is sent to my form/window when this happens and my form/window is no longer the topmost window (or on top of the Z-order)? I'd like to catch it using WndProc.

Thank you

TechAurelian
  • 5,561
  • 5
  • 50
  • 65
  • What are you going to do when you catch the information? Do you want to stop the taskbar and start menu showing or do you just need to know? – David Heffernan Jan 21 '12 at 15:09
  • I want to bring my window to front using BringToFront. The way I'm doing it now is using a Timer every 100 milliseconds to call BringToFront, but I'm afraid I'm wasting resources and maybe slowing down the computer. – TechAurelian Jan 21 '12 at 15:24
  • Doesn't that make it impossible for the user to use the start menu? And it must look dreadful with the taskbar and start menu flicking into view and then being hidden. What's the purpose of all this? – David Heffernan Jan 21 '12 at 15:26
  • After closing my program (that is very easy to do) the user can use the start menu as usual. It's a presentation issue, I want my program to be always on top as long as it is running. – TechAurelian Jan 21 '12 at 15:35
  • You'd better hope the user isn't running another program with the same idea. – David Heffernan Jan 21 '12 at 15:40
  • Make sure the uninstaller works well. – Hans Passant Jan 21 '12 at 16:20
  • @Hans Passant: The program is portable, does not require install/uninstall :) – TechAurelian Jan 21 '12 at 16:26

2 Answers2

2

I think it is wise to consume Raymond Chen his blog post and although it feels like just a fun story, take it very, very serious.

Quote: "When two programs "duke it out" like this, you can't predict which one will win, but you can predict with 100% certainty who will lose: The user. "

rene
  • 41,474
  • 78
  • 114
  • 152
1

As rene said in above post, it is going to be a race condition if more than 1 applications are going to use the same logic, but if you still want to do it, I think having a look at Form.Deactivated will be a good start.

Community
  • 1
  • 1
silverspoon
  • 1,085
  • 1
  • 11
  • 22