From f3337eeb5fd222cc55f9cb912b02e516271a8a38 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 22 Apr 2017 18:31:32 +0200 Subject: Fix initial size of native window on windows. --- plugingui/nativewindow_win32.cc | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'plugingui') diff --git a/plugingui/nativewindow_win32.cc b/plugingui/nativewindow_win32.cc index 9a51fe1..9cf146d 100644 --- a/plugingui/nativewindow_win32.cc +++ b/plugingui/nativewindow_win32.cc @@ -365,17 +365,7 @@ NativeWindowWin32::NativeWindowWin32(void* native_window, Window& window) parent_window = (HWND)native_window; - m_hwnd = CreateWindowEx(0/*ex_style*/, m_className, - "DGBasisWidget", - (native_window?WS_CHILD:WS_OVERLAPPEDWINDOW) | - (native_window?WS_VISIBLE:0), - 0, 0, //window.x(), window.y(), - 1, 1, //window.width(), window.height(), - parent_window, nullptr, - GetModuleHandle(nullptr), nullptr); - - SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this); - + int width = 1, height = 1; if(parent_window) { // Listen in on parent size changes. @@ -386,10 +376,21 @@ NativeWindowWin32::NativeWindowWin32(void* native_window, Window& window) GetClientRect(parent_window, &rect); auto resizeEvent = std::make_shared(); - resizeEvent->width = rect.right - rect.left; - resizeEvent->height = rect.bottom - rect.top; + width = resizeEvent->width = rect.right - rect.left; + height = resizeEvent->height = rect.bottom - rect.top; event_queue.push_back(resizeEvent); } + + m_hwnd = CreateWindowEx(0/*ex_style*/, m_className, + "DGBasisWidget", + (native_window?WS_CHILD:WS_OVERLAPPEDWINDOW) | + (native_window?WS_VISIBLE:0), + 0, 0, + width, height, + parent_window, nullptr, + GetModuleHandle(nullptr), nullptr); + + SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this); } NativeWindowWin32::~NativeWindowWin32() -- cgit v1.2.3