Sign in to follow this  
MTclip

Switching from Fullscreen to Windowed

Recommended Posts

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

Share this post


Link to post
Share on other sites
Evil Steve    2017
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 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 );
SetWindowPos( m_hWnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED );


Share this post


Link to post
Share on other sites
MTclip    242
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

Share this post


Link to post
Share on other sites
Evil Steve    2017
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...

Share this post


Link to post
Share on other sites
MTclip    242
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this