3
votes

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)...

4
Full code here: pastie.org/1552396 - Perry
Did you ever get this working? Just curious. - Please treat your mods well.
check out solved answer here Change Win32 Window Style solved - HaseeB Mir

4 Answers

2
votes

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.

1
votes

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

0
votes

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

0
votes

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.