mirror of
https://github.com/SFML/SFML.git
synced 2025-03-14 01:40:05 +08:00
Fix contentSizeToWindowSize
for windows with a menu or an extended style
This commit is contained in:
parent
3528fcb293
commit
3cf85e6b19
@ -579,9 +579,13 @@ void WindowImplWin32::grabCursor(bool grabbed)
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2i WindowImplWin32::contentSizeToWindowSize(Vector2u size)
|
||||
{
|
||||
// SetWindowPos wants the total size of the window (including title bar and borders) so we have to compute it
|
||||
// SetWindowPos wants the total size of the window (including title bar, borders, and menu) so we have to compute it
|
||||
const auto style = static_cast<DWORD>(GetWindowLongPtr(m_handle, GWL_STYLE));
|
||||
const BOOL hasMenu = ((style & WS_CHILD) == 0) && GetMenu(m_handle) != nullptr;
|
||||
const auto exStyle = static_cast<DWORD>(GetWindowLongPtr(m_handle, GWL_EXSTYLE));
|
||||
|
||||
RECT rectangle = {0, 0, static_cast<long>(size.x), static_cast<long>(size.y)};
|
||||
AdjustWindowRect(&rectangle, static_cast<DWORD>(GetWindowLongPtr(m_handle, GWL_STYLE)), false);
|
||||
AdjustWindowRectEx(&rectangle, style, hasMenu, exStyle);
|
||||
const auto width = rectangle.right - rectangle.left;
|
||||
const auto height = rectangle.bottom - rectangle.top;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user