[SOLVED] problem while changing windowed/fullscreen mode

Started by
16 comments, last by fabry 14 years, 10 months ago
Quote:Original post by fabry
Quote:
That's exactly the sort of spec where I'd expect to see a difference between BitBlt and StretchBlt performance. You could also try explicitly specifying a backbuffer size for windowed mode, in case the backbuffer is being created at say 1024x768 when re-entering windowed mode, but then the window is resized to 1024x768 which will make the client area smaller than that

Great!!!!!! The second time i switch to win mode i have the backbuffer at 800x600 and the client area size of 794x575.
Why does it happen if i use the same identical style used in CreateWindow?
If you have a window that is 800x600, then the window will be that size. The client area will be smaller (794x575), since that includes the space for the window borders, menus, etc.

I'd assume this is because when the device is reset, the window style is WS_POPUP, which means the client area is 800x600. You then change the window style to WS_OVERLAPPEDWINDOW, which reduces the client area to 794x575.

I'd use GetClientRect() to get the size of the client area, and manually specify that for the backbuffer width and height in windowed mode, instead of letting D3D handle it.
Advertisement
Great!! The problem was the size of backbuffer that was not equal to the size of the client area.

I've still a problem when going back to window mode from fullscreen. The window remains always on top. I've checked with WInSpy++ and the extended styles has the flag WS_EX_TOPMOST set but after toggling i only changed the style, no change to EX_style. There's no call in my code that set the window EX_style.
Here is my code:

//Change D3D parameters and do Resetif(this->toggling_WinFullScreenMode) { //if true the user press F2 for toggling mode	this->toggling_WinFullScreenMode = false;	DWORD dwStyle;	if(this->full_screen_mode){	//change style for full screen mode		dwStyle = WS_POPUP;		::ShowCursor(FALSE);	}	else{	//change win style for windowed mode		dwStyle = (WS_OVERLAPPEDWINDOW | WS_VISIBLE) & ~WS_THICKFRAME;		::ShowCursor(TRUE);	}	//change the win style and flush changes	::SetWindowLongPtr(this->hWnd, GWL_STYLE, dwStyle);		::SetWindowPos(this->hWnd, NULL, 0, 0, 0, 0,		SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);} //endif(this->toggling_WinFullScreenMode)


I hope you can help, thanks in advance...
You could try changing your SetWindowPos call to:
	::SetWindowPos(this->hWnd, HWND_TOP, 0, 0, 0, 0,		SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
I.e. explicitly move the window to the top of the Z order (and clear the topmost flag) when moving it.
Hi Steve,
I tryed your code:
::SetWindowPos(this->hWnd, HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
but it doesn't work :(

I also try to force off the TOPMOST bit

::SetWindowLongPtr(this->hWnd, GWL_EXSTYLE, (::GetWindowLongPtr(this->hWnd, GWL_EXSTYLE)) & ~ WS_EX_TOPMOST);//Flush the change::SetWindowPos(.....);


But it's always on top

I'm getting the same problem. The dwstyle and dwExstyle flags that I'm trying to set via SetWindowsLongPtr do not agree with the resulting flags that are set after the call to SetWindowPos, which I obtain from GetWindowsLongPtr. Problems start appearing with the window after a switch from fullscreen back to windowed - it's always on top yet I can't click it or do anything with it.
I wanted to let you know that I figured it out.

First, you need to explicitly set HWND_TOPMOST or HWND_NOTOPMOST in the SetWindowPos call, and take away the SWP_NOZORDER flag - you can't rely on the style or exstyle settings when it comes to topmost because it seems SetWindowPos ignores those and uses its own.

Next, to get my window responsive again, I had to call ShowWindow(SW_NORMAL); after calling SetWindowPos. For some reason the window was displaying but could not be clicked, the mouse would bleed right through to whatever was behind. Re-showing the window seems to solve it.
Quote:
First, you need to explicitly set HWND_TOPMOST or HWND_NOTOPMOST in the SetWindowPos call, and take away the SWP_NOZORDER flag - you can't rely on the style or exstyle settings when it comes to topmost because it seems SetWindowPos ignores those and uses its own.

Next, to get my window responsive again, I had to call ShowWindow(SW_NORMAL); after calling SetWindowPos. For some reason the window was displaying but could not be clicked, the mouse would bleed right through to whatever was behind. Re-showing the window seems to solve it.


Hi, thank you very much for your help, i've tryed so many different solution but without having a good result. And the behaviour of the win32 api that set/unset these flags has really no sense!
I'll change my code according to your advices as soon as I can and i'll let you know
Thank you again
Great y2kiah!!!!
It works. Thank you very much for your help.

This topic is closed to new replies.

Advertisement