1

I have a winform tool window in C# with TopMost = true, running on XP, being shown from within an Excel add-in. When the form is shown, I hit Alt+Tab, it brings me back to Excel. If I hit Alt+Tab again, I would expect it to bring me back to my form, but it goes to the next window (in this case, Visual Studio). Any subsequent Alt+Tab invocations alternate between Excel and Visual Studio. Additionally, if I Alt+Shift+Tab, it will go back to my form (so it's still part of the order, just the order isn't what I want it to be).

If I simply set TopMost = false, everything works as expected. I just reproduced this with a brand new empty project — literally the only thing I did was make a TopMost form. It appears to be isolated entirely to the TopMost property.

Naturally, I'd like Alt+Tab to work the way I expect it to. Any ideas?

Alex
  • 11,451
  • 6
  • 37
  • 52
Richard Pianka
  • 3,317
  • 2
  • 28
  • 36
  • related: http://stackoverflow.com/questions/357076/best-way-to-hide-a-window-from-the-alt-tab-program-switcher – Reactgular Jun 04 '13 at 14:24
  • Can you set TopMost to False when the form loses focus, or does that defeat the whole purpose. – Reactgular Jun 04 '13 at 14:26
  • Defeats the whole purpose, unfortunately (I want to make the form translucent and floating over Excel). I didn't pick up anything meaningful from the question you linked: in my repro, it doesn't appear specific to anything besides TopMost (and the question looks like it's trying to achieve the precise opposite). – Richard Pianka Jun 04 '13 at 14:32
  • Maybe you could catch the `alt+tab` as a global hot key, and disable `TopMost` on the fly. A hack I know but that's the best I got. http://stackoverflow.com/questions/2450373/set-global-hotkeys-using-c-sharp – Reactgular Jun 04 '13 at 14:37
  • I think this is by design. Alt+Tab may well mean "switch to another window that's not on top right now". You never need help switching to a window that's on top, it is easy to get to. – Hans Passant Jun 05 '13 at 14:19
  • All the problems of this kind can be solved using some low level keyboard hook. the hook works only when our application is activated and the hook is removed when other applications are. At least that's the general solution which can fit many the same problems. v_v – King King Jun 06 '13 at 22:09

1 Answers1

0

The topmost-form of my application is included in the Alt+Tab sequence. But i found, it is not if i set the forms ShowInTaskbar-property to true. Have a look on this property.

termigrator
  • 159
  • 3
  • 11