Sign in to follow this  

Window styles and toggling fullscreen[MSVC2003]

This topic is 4225 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

Hello, I am tidying my app up, and getting the fullscreen/windowed toggle to work correctly. Here's how I create a window; m_displaySettings->m_hWnd = CreateWindow( "WindowClass", m_displaySettings->m_windowText, m_displaySettings->m_windowed ? WS_OVERLAPPED|WS_SYSMENU : WS_POPUP, 0, 0, m_displaySettings->m_screenWidth, m_displaySettings->m_screenHeight, NULL, NULL, hInst, NULL ); This works well at first. If windowed it has a titlebar with close button, and switching to full screen seems fine. However if I start in fullscreen mode then switch to windowed, it is like i have used WS_OVERLAPPED and no WS_SYSMENU, ie there is no title bar anymore! How do i preserve the title bar when coming out of fullscreen? Its a directx window by the way. Thanks Simon EDIT: Also, when starting in windowed, other windows can go on top of my app, but after being in fullscreen and switching back, the app is always on top... :(

Share this post


Link to post
Share on other sites
Direct3D changes the window class. If you're going from fullscreen to windowed, you need to use SetWindowLong() to chaneg the frame style, then call SetWindowPos() to update the frame.

From some of my code:

// Move window and change style if needed
if(m_theDevice.GetPresentParams().Windowed)
{
RECT rc;
rc.top = 0; rc.left = 0;
rc.right = m_theDevice.GetPresentParams().BackBufferWidth;
rc.bottom = m_theDevice.GetPresentParams().BackBufferHeight;
AdjustWindowRect(&rc,WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME,FALSE);
rc.right -= rc.left;
rc.bottom -= rc.top;

SetWindowLong(m_hWnd,GWL_STYLE,WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME);
SetWindowPos(m_hWnd,NULL,(GetSystemMetrics(SM_CXSCREEN)-m_theDevice.GetPresentParams().BackBufferWidth)/2,
(GetSystemMetrics(SM_CYSCREEN)-m_theDevice.GetPresentParams().BackBufferHeight)/2,rc.right,rc.bottom,
SWP_FRAMECHANGED|SWP_NOZORDER);
ShowWindow(m_hWnd,SW_SHOW);
}



EDIT: If you use SetWindowPos(), you can change the Z-order of your window too. D3D is probably setting to to HWND_TOPMOST, you can set it to HWND_TOP:
SetWindowPos(m_hWnd, HWND_TOP, (GetSystemMetrics(SM_CXSCREEN)-m_theDevice.GetPresentParams().BackBufferWidth)/2, (GetSystemMetrics(SM_CYSCREEN)-m_theDevice.GetPresentParams().BackBufferHeight)/2, rc.right, rc.bottom, SWP_FRAMECHANGED);

Share this post


Link to post
Share on other sites

This topic is 4225 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.

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