Perry
Perry

Reputation: 35

WinApi - change Window Style

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

Upvotes: 3

Views: 6140

Answers (4)

Tom Tom
Tom Tom

Reputation: 1209

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.

Upvotes: 0

Jon
Jon

Reputation: 3065

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.

Upvotes: 2

Bojan Komazec
Bojan Komazec

Reputation: 9536

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

Upvotes: 0

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

Upvotes: 1

Related Questions