Jump to content
  • Advertisement
Sign in to follow this  
RealMarkP

Win32: Changing styles on the fly.

This topic is 4137 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, I am writing an OpenGL based application in which I need to change the styles of the window when it goes from full screen to windowed mode. The problem is that when I change the style, the window does not accept any type of move or resize input from the user. When I hover my mouse over the border, the cursor should change to a resize cursor, rather it doesn't and just passes the input of a click into my Game. The two styles I have are shown in the code below:
	if (windowMode)
	{
		// Create a bordered window
		SetWindowLong(windowHwnd, GWL_STYLE, GetWindowLong(windowHwnd, GWL_STYLE) | WS_OVERLAPPEDWINDOW);

		// Refresh it by repainting
		winWidth -= 100;
		winHeight -= 100;
		SetWindowPos(windowHwnd, 0, 50, 50, winWidth, winHeight, SWP_SHOWWINDOW);

	}else{

		// New Values for the Window size
		SystemParametersInfo(SPI_GETWORKAREA, 0, &size, 0);
		winWidth = size.right;
		winHeight = size.bottom;

		// Restore it back to Users area size, without borders
		SetWindowLong(windowHwnd, GWL_STYLE, WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU);
		SetWindowPos(windowHwnd, 0, 0, 0, winWidth, winHeight, SWP_SHOWWINDOW);
	}

The top part of the If statement changes the window into a regular Window with a border and title bar, and the bottom portion makes the window borderless. So basically once I turn the window's borders on, doesn't matter how many times I click on the title bar or any of the buttons (close, minimize, maximize), they do not work and just pass the clicks into my game, as if the window was still borderless.

Share this post


Link to post
Share on other sites
Advertisement
After you make the window fullscreen the window has the WS_POPUP style. Then, when you make it bordered, the window still has WS_POPUP and now ALSO has WS_OVERLAPPEDWINDOW. Try removing WS_POPUP before added WS_OVERLAPPEDWINDOW.

Share this post


Link to post
Share on other sites
I tried removing the WS_POPUP value form the styles and then applying the WS_OVERLAPPEDWINDOW flag and it did not work. One thing that I noticed is that once I put it into windowed mode and initiate a context menu through the task bar or within my program (I have an ContextMenu implementation in my code), the title bar and borders kick in and and I can actually use them.

Share this post


Link to post
Share on other sites
As mentioned on MSDN you have to tell the window the style has been updated by calling SetWindowPos with the SWP_FRAMECHANGED flag.

I suggest you read the MSDN page on the function to get the details...

Share this post


Link to post
Share on other sites
I have tried that approach as well as forcing messages into the window to force it to refresh and act upon the changed positions. Neither approach worked. Any suggestions?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!