Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Add sf::Window::setStyle to allow changing style without recreating window  (Read 4734 times)

0 Members and 1 Guest are viewing this topic.

kloffy

  • Newbie
  • *
  • Posts: 21
    • View Profile
There was a thread about this a while ago (not sure where it went, forum search is kind of broken). Basically, it would be really useful to have the ability to change the window style without recreating the window (and with it the OpenGL context). In particular, this allows a very fast "lightweight" fullscreen mode by resizing the window and hiding the border. I posted a working implementation for Windows:

void setStyle(sf::Window& window, sf::Uint32 style)
{
    HWND handle = window.getSystemHandle();
    DWORD win32Style = WS_VISIBLE;

    if (style == sf::Style::None)
    {
        win32Style |= WS_POPUP;
    }
    else
    {
        if (style & sf::Style::Titlebar) win32Style |= WS_CAPTION | WS_MINIMIZEBOX;
        if (style & sf::Style::Resize)   win32Style |= WS_THICKFRAME | WS_MAXIMIZEBOX;
        if (style & sf::Style::Close)    win32Style |= WS_SYSMENU;
    }

    SetWindowLongPtr(handle, GWL_STYLE, win32Style);

    // Force changes to take effect
    SetWindowPos(handle, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_DRAWFRAME);
}

I realize it may be more difficult on other platforms (haven't tried it), but it would be worth looking into. Understandably, Laurent already said that it will not make it into 2.0, so I am crossing my fingers for future versions.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
It is planned for a future version, don't worry.
Laurent Gomila - SFML developer

kloffy

  • Newbie
  • *
  • Posts: 21
    • View Profile
It is planned for a future version, don't worry.
Amazing, I can't wait to be able to do this through the official API.  :D

 

anything