Jump to content
  • Advertisement
Sign in to follow this  
sipickles

Window styles and toggling fullscreen[MSVC2003]

This topic is 4439 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
Advertisement
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
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!