Jump to content

  • Log In with Google      Sign In   
  • Create Account


Full Screen to Windowed - Window loses border and style


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Nexian   Members   -  Reputation: 118

Like
0Likes
Like

Posted 19 August 2012 - 05:45 PM

Hello all,

This is using Directx9 and C++, but since the problem is the window itself I'm posting in general. Also, I really did try searching for this, but everything I found was asking "how to get borderless windows" ><

Basically, I have the following sequence:

1. Game loads in a fixed window
2. I set the game to full screen and reset the d3d device
3. I change the resolution in full screen mode resetting the device again
4. I return to windowed mode resetting the device a final time

Resulting Problem: When returning to windowed mode with a new resolution, the border of the window is "gone". I can still select the border (i.e. clicking the top left will give me the default menu bar (restore, move, size, etc) and when I select it I briefly see it. Also, if I change the resolution a second time, the window re-appears, but it has become the windows default style (i.e. if my window bars are green, this one has reverted back to the default light blue with the default minimize, maximize and close icons).

This is my window:

hWindow = CreateWindowEx(WS_EX_CLIENTEDGE,
	   className,
	   L"Shader Implementations",
	   WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU,
	   CW_USEDEFAULT,
	   CW_USEDEFAULT,
	   SCREEN_WIDTH,
	   SCREEN_HEIGHT,
	   NULL,
	   NULL,
	   hInstance,
	   NULL);

When I exit full screen mode I only access the window with the following:

if (d3dpp.Windowed == true)
{
  RECT rect;
  GetWindowRect(hWindow, &rect);
  MoveWindow(hWindow, rect.left, rect.top, d3dpp.BackBufferWidth, d3dpp.BackBufferHeight, false);
}

I have also tried it without this code (just to be sure).

If I return to windowed mode without changing the resolution it was set to when it went to full screen, it reverts without issue.

I am guessing there is something more I need to do with the window to make sure it retains the style and border when returning to windowed mode?

Edited by Nexian, 19 August 2012 - 05:50 PM.


Sponsor:

#2 ApochPiQ   Moderators   -  Reputation: 12366

Like
2Likes
Like

Posted 19 August 2012 - 05:53 PM

Try this:

RECT clientRect;
clientRect.left = 0;
clientRect.top = 0;
clientRect.right = d3dpp.BackBufferWidth;
clientRect.bottom = d3dpp.BackBufferHeight;
AdjustWindowRect(&clientRect, GetWindowLongPtr(hWindow, GWL_STYLE), FALSE);
MoveWindow(hWindow, clientRect.left, clientRect.top, clientRect.right, clientRect.bottom, false);

This will enlarge the window rectangle to include the border size.

#3 Nexian   Members   -  Reputation: 118

Like
0Likes
Like

Posted 19 August 2012 - 06:19 PM

Try this:

RECT clientRect;
clientRect.left = 0;
clientRect.top = 0;
clientRect.right = d3dpp.BackBufferWidth;
clientRect.bottom = d3dpp.BackBufferHeight;
AdjustWindowRect(&clientRect, GetWindowLongPtr(hWindow, GWL_STYLE), FALSE);
MoveWindow(hWindow, clientRect.left, clientRect.top, clientRect.right, clientRect.bottom, false);

This will enlarge the window rectangle to include the border size.


I had to add 50 to the rectangle when returning at max resolution (border was above the top of the screen) but that seemed to do it very nicely, thank you!

Although it still loses the windows 7 border style. Is there anyway to get that back?

#4 ApochPiQ   Moderators   -  Reputation: 12366

Like
1Likes
Like

Posted 19 August 2012 - 09:32 PM

I think you might have to muck around with DwmSetWindowAttribute but it should be possible.

#5 krippy2k8   Members   -  Reputation: 638

Like
0Likes
Like

Posted 19 August 2012 - 10:11 PM

You may be better off just closing that window and creating a new window after exiting full screen mode.

#6 Endurion   Crossbones+   -  Reputation: 3040

Like
1Likes
Like

Posted 19 August 2012 - 11:54 PM

D3D removes the border styles. You need to reapply them via SetWindowLong. You can store the wanted styles. Just make sure to also manually remove WS_EX_TOPMOST.

Before going fullscreen:
m_WindowedModeStyles = GetWindowLong( hwndViewport, GWL_STYLE );
m_WindowedModeExStyles = GetWindowLong( hwndViewport, GWL_EXSTYLE );
m_WindowedModeExStyles &= ~WS_EX_TOPMOST;

Returning to windowed mode:
SetWindowLong( hwndViewport, GWL_STYLE, m_WindowedModeStyles );
SetWindowLong( hwndViewport, GWL_EXSTYLE, m_WindowedModeExStyles );
SetWindowPos( hwndViewport, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED );
Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS