Hello,
I'm making an application in Visual C++ that hides/shows an application window from taskbar by clicking a button.

First problem (googled it) is that I don't know how to retrieve the information about a window state (SW_HIDE,SW_SHOWNORMAL, etc.). Is it hidden, minimized, normal or maximized? I only know how to set them. I want this information to toggle between hide/show states.

Second problem more difficult is that showing back a normal window maximized or normal works fine BUT if that window is used by a game I can't restore directly in the fullscreen video mode - I see only my screen as it is at the moment and no mouse pointer (as it would focus that window but does not retrieve the fullsceen game mode).

Here's my function for hiding from taskbar:

void hide(char* className, char* windowTitle)
{


			HWND hc = FindWindow(className,windowTitle);
			
		
			if(hc == NULL) MessageBoxA(NULL,"Cannot find the window","Error",MB_OK);
			else
			{
				ShowWindow(hc,SW_HIDE);
			    SetForegroundWindow(hc);

				MessageBoxA(NULL,"We retrieve the window to normal state","OK",MB_OK);
				ShowWindow(hc,SW_SHOWNORMAL);
				SetForegroundWindow(hc);

			}
}

Thanks but didn't help because I don't know how to use that WINDOWPLACEMENT variable.

I solved the fullscreen problem in games.

I only want somehow to get the current state of that window - SW_HIDE, SW_NORMAL, SW_MAXIMIZE, SW_MINIMIZE. These are integer values.

Your reply was really helful :) . For that I was searching. Just one problem if you want to help me - hope I don't buzz you too much, I'm little newbie in winapi. This is my function for toggle:

void hide(char* className, char* windowTitle)
{


			HWND hc = FindWindow(className,windowTitle);
			
		
			if(hc == NULL) MessageBoxA(NULL,"Cannot find the window","Error",MB_OK);
			else
			{

				
				WINDOWPLACEMENT wd;
				UINT nCurShow;

				if (GetWindowPlacement( hc, &wd ))
				{
					nCurShow = wd.showCmd;
					if(nCurShow==SW_HIDE)
					{
					    ShowWindow( hc, SW_SHOWMAXIMIZED);
						SetForegroundWindow(hc);
						
						MessageBoxA(NULL,"maximized now","info",MB_OK);
					}
					else if(nCurShow==SW_SHOWMAXIMIZED || nCurShow==SW_SHOWNORMAL || nCurShow==SW_SHOWMINIMIZED)
					{	
						ShowWindow( hc, SW_HIDE );
					    SetForegroundWindow(hc);
				
						MessageBoxA(NULL,"hidden now","info",MB_OK);
					}

				}
				else
				{
						ShowWindow( hc, SW_SHOWMAXIMIZED );
						SetForegroundWindow(hc);
				}
			
			}
}

It's just it always enter this statement:
else if(nCurShow==SW_SHOWMAXIMIZED || nCurShow==SW_SHOWNORMAL || nCurShow==SW_SHOWMINIMIZED) as if it can't detect that the window is currently hidden. (and it really is hidden). Again, thanks.

This article has been dead for over six months. Start a new discussion instead.