Switching from Fullscreen to Windowed

Started by
3 comments, last by MTclip 18 years, 1 month ago
I can get the my app to switch from windowed to fullscreen and back.. but when i switch from full screen to windowed the window is borderless and stuck in the upper left corner of the screen... but if i start out in windowed mode the window has a border and functions normally until i switch to fullscreen and back... Im sure it just something i am not doing... heres some code.. **initial window creation**

// set style based on windowed type
// WNDCLASSEX m_winClass

if( m_settings.GetWindowed() )
	style = WS_OVERLAPPEDWINDOW|WS_VISIBLE;
else
	style = WS_POPUP|WS_VISIBLE;

// fill out window description
m_winClass.lpszClassName = m_appTitle;
m_winClass.cbSize        = sizeof(WNDCLASSEX);
m_winClass.style         = CS_HREDRAW | CS_VREDRAW; //CS_OWNDC
m_winClass.lpfnWndProc   = SimpleFramework::WndProc;
m_winClass.hInstance     = m_hInstance;
m_winClass.hIconSm		 = LoadIcon(0, IDI_APPLICATION);
m_winClass.hIcon         = LoadIcon(0, IDI_APPLICATION);
m_winClass.hCursor       = LoadCursor(0, IDC_ARROW);
m_winClass.hbrBackground = (HBRUSH)NULL;
m_winClass.lpszMenuName  = NULL;
m_winClass.cbClsExtra    = 0;
m_winClass.cbWndExtra    = 0;

m_hWnd =  CreateWindowEx( 0, m_appTitle, m_appTitle, style,CW_USEDEFAULT, 
				CW_USEDEFAULT,m_settings.GetWidth(), m_settings.GetHeight(), NULL, NULL, m_hInstance, NULL ) ) )


**window update**

DWORD style;
	
// set style based on windowed type
if( m_settings.GetWindowed() )
	style = WS_OVERLAPPEDWINDOW|WS_VISIBLE;
else
	style = WS_POPUP|WS_VISIBLE;

// change the settings
SetWindowLong( m_hWnd, GWL_STYLE, style );

Advertisement
Quote:
Certain window data is cached, so changes you make using SetWindowLong will not take effect until you call the SetWindowPos function. Specifically, if you change any of the frame styles, you must call SetWindowPos with the SWP_FRAMECHANGED flag for the cache to be updated properly.

I.e. Setting GWL_style doesn't take effect until you call SetWindowPos(). You should do:
DWORD style;	// set style based on windowed typeif( m_settings.GetWindowed() )	style = WS_OVERLAPPEDWINDOW|WS_VISIBLE;else	style = WS_POPUP|WS_VISIBLE;// change the settingsSetWindowLong( m_hWnd, GWL_STYLE, style );SetWindowPos( m_hWnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED );
thanks... it worked...

one more question...

if i start in windowed mode the window does not remain on top but,
after i switch to windowed mode the window always remains on top...

i dont like it...

I know that not a complete question.. but i think it implied ;P
I think that if you use SetWindowPos(), don't specify the SWP_NOZORDER flag, and use HWND_NOTOPMOST as the second parameter, that should work. Although I haven't tried it, I've never noticed that problem before...
I have it working correctly when my app is running...but I Just noticed that after my application closes the windows zordering is messed up.. like one window will remains on top even if another window has focus... and stays that way for about 10 seconds... what gives?

-thanks

This topic is closed to new replies.

Advertisement