From 6b45d1ca25e2d4cafa8b0ca9441eaeeadd5ff37d Mon Sep 17 00:00:00 2001 From: Tomaka17 Date: Fri, 22 Aug 2014 11:19:19 +0200 Subject: [PATCH] Not specifiying dimensions on win32 now results in CW_USEDEFAULT Close #11 --- src/win32/init.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/win32/init.rs b/src/win32/init.rs index 14c61a41..21d9612b 100644 --- a/src/win32/init.rs +++ b/src/win32/init.rs @@ -228,12 +228,18 @@ pub fn new_window(builder: WindowBuilder) -> Result { // creating the real window this time let real_window = unsafe { + let (width, height) = if builder.monitor.is_some() || builder.dimensions.is_some() { + (Some(rect.right - rect.left), Some(rect.bottom - rect.top)) + } else { + (None, None) + }; + let handle = ffi::CreateWindowExW(ex_style, class_name.as_ptr(), title.as_ptr() as ffi::LPCWSTR, style | ffi::WS_VISIBLE | ffi::WS_CLIPSIBLINGS | ffi::WS_CLIPCHILDREN, - if builder.monitor.is_some() { 0 } else { ffi::CW_USEDEFAULT}, - if builder.monitor.is_some() { 0 } else { ffi::CW_USEDEFAULT}, - rect.right - rect.left, rect.bottom - rect.top, + if builder.monitor.is_some() { 0 } else { ffi::CW_USEDEFAULT }, + if builder.monitor.is_some() { 0 } else { ffi::CW_USEDEFAULT }, + width.unwrap_or(ffi::CW_USEDEFAULT), height.unwrap_or(ffi::CW_USEDEFAULT), ptr::mut_null(), ptr::mut_null(), ffi::GetModuleHandleW(ptr::null()), ptr::mut_null());