3

I want to change my windo style during runtime. I use this code

if (this->fullscreen)
{
    this->style = WS_POPUP|WS_VISIBLE;
}
else 
{
    this->style = WS_OVERLAPPED|WS_SYSMENU|WS_VISIBLE;
}

    SetWindowLongPtr(this->mainWindowHandle, GWL_STYLE, this->style);

        SetWindowPos(this->mainWindowHandle, 
                HWND_TOP, 
                0, 
                0,
                0,    //New Width
                0, //New Height, 
            SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);

But it has no effect... and window is still without border (WS_POPUP)...

Perry
  • 35
  • 1
  • 4

4 Answers4

2

According to MSDN, you can't modify those particular styles after the window is created. If you're going to try to anyway, it also says that WS_SYSMENU requires WS_CAPTION.

Jon
  • 3,065
  • 1
  • 19
  • 29
  • +1. You'll probably need separate windows for full-screen and windowed modes and switch between them as needed (by enabling the right window and making it visible and doing the reverse to the other). – Adrian McCarthy Feb 11 '11 at 18:21
1

Try calling SetWindowPos with the flag SWP_DRAWFRAME and see if it helps.

0

You might need to use CWnd::ModifyStyle. Have a look at example here

Bojan Komazec
  • 9,216
  • 2
  • 41
  • 51
0

You might save the current pos and size from the actual window. Then destroy it an create an new window with the new style, previous pos and size.

Tom Tom
  • 1,127
  • 11
  • 25