(C++/win32) Hide a window so that the user cannot

2019-07-17 15:45发布

问题:

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.

回答1:

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);