2

I'm currently using ShowWindow( hwnd, SW_HIDE ), but AltTab still seems to be able to switch to it after it's hidden.

Is there a way to completely hide a window without destroying it?

EDIT: I should add that using the WS_EX_TOOLBOX style doesn't help. With enough AltTab and ShowWindow(SW_SHOW), some strange things happen.

Joshua
  • 1,148
  • 3
  • 17
  • 34
  • SW_HIDE should work. Are you sure your message gets delivered? Is your main GUI thread still pumping messages after your call SW_HIDE? – Ivan Shcherbakov Jul 08 '12 at 10:42
  • @IvanShcherbakov Yes the messages are getting delivered...Also, I tried handling WM_ACTIVATE instead, but Alt-Tab just stops sending WM_ACTIVATE messages after a few Alt-Tabs. – Joshua Jul 08 '12 at 11:18
  • How exactly are you handling them? If you start returning DefWindowProc() for every message, just for a simple experiment, will SW_HIDE work as intended? – Ivan Shcherbakov Jul 08 '12 at 18:07
  • @IvanShcherbakov I return DefWindowProc() for every message (I don't `return 0`, I just `break;` and `return DefWindowProc()` at the end). The SW_HIDE does work but it seems that it cannot evade Alt-Tab. – Joshua Jul 08 '12 at 18:31

1 Answers1

0

Try this code to hide window
I have try this code and hidden window will be not appear while you pressing Alt + Tab [ I am using win-xp]
To show window press Tab + Esc

HWND hwnd_win = GetForegroundWindow();
ShowWindow(hwnd_win,SW_HIDE);
while(1)
{
    Sleep(1000);
    if(GetAsyncKeyState(VK_ESCAPE|VK_TAB ))
        break;
}   
ShowWindow(hwnd_win,SW_SHOW);
Mahesh Meniya
  • 2,627
  • 3
  • 18
  • 17
  • =/ I'm using Windows 7 and can confirm that `SW_HIDE` does not fully evade Alt+Tab if you Alt+Tab enough times. – Joshua Jul 08 '12 at 08:16
  • Ok I am working with Win-XP and it is working fine.. http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548%28v=vs.85%29.aspx – Mahesh Meniya Jul 08 '12 at 08:22