Jump to content

Window::setStyle & System::GetCurrentMonitorResolution


NightQuest
 Share

Recommended Posts

We have Window::setLayout which is awesome for resizing.. but what if we want borderless window? smile.png

 

Right now, I'm using this platform-specific code for that:

if( window->KeyHit(Key::F11) )

{

int screenWidth = GetSystemMetrics(SM_CXSCREEN);

int screenHeight = GetSystemMetrics(SM_CYSCREEN);

 

if( fullscreen )

{

long style = reinterpret_cast<long>(window->GetUserData());

SetWindowLongPtr(window->hwnd, GWL_STYLE, style);

 

int width = stoi(System::GetProperty("width", "1280"));

int height = stoi(System::GetProperty("height", "720"));

 

window->SetLayout((screenWidth - width) / 2, (screenHeight - height) / 2, width, height);

}

else

{

long style = GetWindowLongPtr(window->hwnd, GWL_STYLE);

window->SetUserData(reinterpret_cast<void*>(style));

SetWindowLongPtr(window->hwnd, GWL_STYLE, style & ~(WS_BORDER | WS_OVERLAPPEDWINDOW));

window->SetLayout(0, 0, screenWidth, screenHeight);

}

fullscreen = !fullscreen;

}

 

 

This would allow us to simply do:

 

if( window->KeyHit(Key::F11) )

{

fullscreen = !fullscreen;

 

int width = fullscreen ? GetSystemMetrics(SM_CXSCREEN) : stoi(System::GetProperty("width", "1280"));

int height = fullscreen ? GetSystemMetrics(SM_CYSCREEN) : stoi(System::GetProperty("height", "720"));

 

int style = Window::Center;

if( fullscreen )

style &= ~Window::Titlebar;

else

style |= Window::Titlebar;

 

window->setStyle(style);

window->setLayout(0, 0, width, height);

}

 

 

And maybe we could get a

Vec2 System::GetCurrentMonitorResolution();

 

or something to retrieve the current monitors display resolution?

While I don't mind the Win32API, I'd like to be able to easily do these things on both platforms.

 

GTK+ has gtk-window-set-decorated, and X11 has DefaultScreenOfDisplay.

  • Upvote 1
Link to comment
Share on other sites

Yeah, this would be nice to see. Definitely the idea of a simple GetCurrentMonitorResolution function as it will make fullscreen mode properly set, and it will always look right with no need for config files. It would also be really great to have for lua games as well.

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...