Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

marcus12024

Changing Windowed to FullScreen and Back - Problem

This topic is 5325 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, so I''ve got my app changing to full-screen and back, using Direct3D9. All is working, all my sprites and textures survive However, when I first start my app using this code for window creation:
	if (windowed)
		g_hWnd = CreateWindow("MY_WINDOWS_CLASS", 
		                     "Direct3D (DX9) - Creating 2D Sprites with D3DXSPRITE",
						     WS_OVERLAPPEDWINDOW | WS_VISIBLE,
					         0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL );
	else // is full-screen

		g_hWnd = CreateWindow("MY_WINDOWS_CLASS", 
		                     "Direct3D (DX9) - Creating 2D Sprites with D3DXSPRITE",
						     WS_POPUP | WS_VISIBLE,
					         0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL );
everything is kosher and I get a nice window with a minimize, maximize, and close button. And if I click outside the window, my window goes to the background, which is what I want. However, if I switch to full screen, and then back again, using this function:
	if (windowed) {
		// set window-mode style

		SetWindowLong( *hWnd, GWL_STYLE, WS_BORDER | WS_CAPTION | WS_VISIBLE | WS_MINIMIZEBOX);
		SetWindowPos( *hWnd , HWND_TOP , 0 , 0 , width , height , SWP_SHOWWINDOW | SWP_FRAMECHANGED  );
		// bc, according to MSDN: if you change any of the frame styles, you must call 

		// SetWindowPos with the SWP_FRAMECHANGED flag for the cache to be updated properly. 

	} else { // changing to full-screen

		// Set fullscreen-mode style

		SetWindowLong( *hWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE);
	}
// now do all d3d reset code...same as in init function

I get a window, that has no minimize, maximize, or close buttons, and when I click on another window, my game window stays on top, but just becomes not-active. Any thoughts? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
FIXED!!

just changed code to...


if (windowed) {
// set window-mode style

SetWindowLong( *hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE);
SetWindowPos( *hWnd , HWND_TOP , 0 , 0 , width , height , SWP_SHOWWINDOW | SWP_FRAMECHANGED );
// bc, according to MSDN: if you change any of the frame styles, you must call

// SetWindowPos with the SWP_FRAMECHANGED flag for the cache to be updated properly.

} else { // changing to full-screen

// Set fullscreen-mode style

SetWindowLong( *hWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE);
}


although I could have swore that I had been using that code originally...weird!

Share this post


Link to post
Share on other sites
I'll take a stab at it. I think this is because you are not setting the window the same as when you created it.

When you made the window (in windowed mode), you specified:
WS_OVERLAPPEDWINDOW | WS_VISIBLE

However, when you switch from fullscreen to windowed mode, you now specify:
WS_BORDER | WS_CAPTION | WS_VISIBLE | WS_MINIMIZEBOX

That's not the same thing. Try using the same flags in your SetWindowLong() function that you used to create it in the first place and see what happens.

Also, there's a comment in the docs on SetWindowPos() about SWP_SHOWWINDOW. "If the SWP_SHOWWINDOW or SWP_HIDEWINDOW flag is set, the window cannot be moved or sized." Not sure if this might be part of your topmost problem or not.

HTH, Ron

[edit: okay, you beat me to it. Glad you got it fixed! ]

[edited by - RonHiler on February 27, 2004 10:09:25 AM]

Share this post


Link to post
Share on other sites
Even after I had fixed the other problem (about the minimize and other buttons going away), I was still having the top-most problem...I solved it temporarily (by doing a Minimize when encountering a deactivate message), but that isn''t really what I wanted to have to do.

I want my game to be open and on the screen at the same time as other apps, so that I can do things like talk on messenger and have my game running on the other part of the screen, simply pausing when it''s not active, but still showing.

And thanks to your advice - you got me looking in the right direction - I figured it out...it was a stupid flag, here:


SetWindowPos( *hWnd , HWND_NOTOPMOST , 0 , 0 , width , height , SWP_SHOWWINDOW | SWP_FRAMECHANGED );


Thank you so much, it''s all working now!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!