Original Post
I have some code that switches between fullscreen and windowed mode.It basically changes the window style.Here is the code that makes the window go fullscreen: And this code is for going back to windowed mode : Everything works except for a minor detail.After i come back to windowed mode my applications button at the taskbar looks like it does not have focus.But the application has focus and takes input mouse presses etc.When I alt-tab or click from the taskbar then the taskbar updates itself and it shows my app as focused. Any idea what might be wrong?
//NOte: ChangeDisplaySettings is called before this point with a supported setting.
//change to fullscreen style
SetWindowLongPtr(m_hWnd,GWL_EXSTYLE,WS_EX_APPWINDOW);
SetWindowLongPtr(m_hWnd,GWL_STYLE,WS_POPUP);
//SetWindowPos needs to be called after SetWindowLongPtr to make sure changes are applied
SetWindowPos(m_hWnd,HWND_TOP,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE);
//maximize the window
ShowWindow(m_hWnd,SW_MAXIMIZE);
SetFocus(m_hWnd);
//need to call SW_RESTORE twice for some weird reason
ShowWindow(m_hWnd,SW_RESTORE);
//go back to normal resolution
ChangeDisplaySettings(NULL,0);
//change back to overlapped window style
SetWindowLongPtr(m_hWnd,GWL_EXSTYLE,WS_EX_APPWINDOW | WS_EX_WINDOWEDGE);
SetWindowLongPtr(m_hWnd,GWL_STYLE,WS_OVERLAPPEDWINDOW);
//SetWindowPos needs to be called after SetWindowLongPtr to make sure changes are applied
SetWindowPos(m_hWnd,HWND_TOP,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE);
ShowWindow(m_hWnd,SW_RESTORE);
SetFocus(m_hWnd);
//for some weird(2) reason after coming back from fullscreen mode the icon on the title bar disappears
// so i set it again here
HICON icon = (HICON)GetClassLongPtr(m_hWnd,GCL_HICON);
SendMessage(m_hWnd,WM_SETICON,ICON_BIG,(LPARAM)icon);
SendMessage(m_hWnd,WM_SETICON,ICON_SMALL,(LPARAM)icon);