@@ -61,9 +61,9 @@ impl NativeWindowHandle {
6161 0 ,
6262 0 ,
6363 0 ,
64- main,
64+ Some ( main) ,
65+ None ,
6566 None ,
66- HINSTANCE ( std:: ptr:: null_mut ( ) ) ,
6767 // Pass the main window's HWND to WM_NCCREATE so the helper can store it.
6868 Some ( & main as * const _ as _ ) ,
6969 )
@@ -103,18 +103,36 @@ impl NativeWindowHandle {
103103 } ;
104104 let _ = unsafe { DwmExtendFrameIntoClientArea ( main, & margins) } ;
105105
106- let hinst = unsafe { GetModuleHandleW ( None ) } . unwrap ( ) ;
106+ let hinst: HINSTANCE = unsafe { GetModuleHandleW ( None ) } . unwrap ( ) . into ( ) ;
107107
108108 // Set taskbar icon
109- if let Ok ( big) = unsafe { LoadImageW ( hinst, PCWSTR ( 1usize as * const u16 ) , IMAGE_ICON , GetSystemMetrics ( SM_CXICON ) , GetSystemMetrics ( SM_CYICON ) , LR_SHARED ) } {
109+ if let Ok ( big) = unsafe {
110+ LoadImageW (
111+ Some ( hinst) ,
112+ PCWSTR ( 1usize as * const u16 ) ,
113+ IMAGE_ICON ,
114+ GetSystemMetrics ( SM_CXICON ) ,
115+ GetSystemMetrics ( SM_CYICON ) ,
116+ LR_SHARED ,
117+ )
118+ } {
110119 unsafe { SetClassLongPtrW ( main, GCLP_HICON , big. 0 as isize ) } ;
111- unsafe { SendMessageW ( main, WM_SETICON , WPARAM ( ICON_BIG as usize ) , LPARAM ( big. 0 as isize ) ) } ;
120+ unsafe { SendMessageW ( main, WM_SETICON , Some ( WPARAM ( ICON_BIG as usize ) ) , Some ( LPARAM ( big. 0 as isize ) ) ) } ;
112121 }
113122
114123 // Set window icon
115- if let Ok ( small) = unsafe { LoadImageW ( hinst, PCWSTR ( 1usize as * const u16 ) , IMAGE_ICON , GetSystemMetrics ( SM_CXSMICON ) , GetSystemMetrics ( SM_CYSMICON ) , LR_SHARED ) } {
124+ if let Ok ( small) = unsafe {
125+ LoadImageW (
126+ Some ( hinst) ,
127+ PCWSTR ( 1usize as * const u16 ) ,
128+ IMAGE_ICON ,
129+ GetSystemMetrics ( SM_CXSMICON ) ,
130+ GetSystemMetrics ( SM_CYSMICON ) ,
131+ LR_SHARED ,
132+ )
133+ } {
116134 unsafe { SetClassLongPtrW ( main, GCLP_HICONSM , small. 0 as isize ) } ;
117- unsafe { SendMessageW ( main, WM_SETICON , WPARAM ( ICON_SMALL as usize ) , LPARAM ( small. 0 as isize ) ) } ;
135+ unsafe { SendMessageW ( main, WM_SETICON , Some ( WPARAM ( ICON_SMALL as usize ) ) , Some ( LPARAM ( small. 0 as isize ) ) ) } ;
118136 }
119137
120138 // Force window update
@@ -197,7 +215,7 @@ unsafe fn ensure_helper_class() {
197215 lpfnWndProc : Some ( helper_window_handle_message) ,
198216 hInstance : unsafe { GetModuleHandleW ( None ) . unwrap ( ) . into ( ) } ,
199217 hIcon : HICON :: default ( ) ,
200- hCursor : unsafe { LoadCursorW ( HINSTANCE ( std :: ptr :: null_mut ( ) ) , IDC_ARROW ) . unwrap ( ) } ,
218+ hCursor : unsafe { LoadCursorW ( None , IDC_ARROW ) . unwrap ( ) } ,
201219 // No painting; the ring is invisible.
202220 hbrBackground : HBRUSH :: default ( ) ,
203221 lpszClassName : PCWSTR ( class_name. as_ptr ( ) ) ,
@@ -292,7 +310,7 @@ unsafe extern "system" fn helper_window_handle_message(hwnd: HWND, msg: u32, wpa
292310 // Extract the main window's HWND from GWLP_USERDATA that we saved earlier.
293311 let main_ptr = unsafe { GetWindowLongPtrW ( hwnd, GWLP_USERDATA ) } as * mut std:: ffi:: c_void ;
294312 let main = HWND ( main_ptr) ;
295- if unsafe { IsWindow ( main) . as_bool ( ) } {
313+ if unsafe { IsWindow ( Some ( main) ) . as_bool ( ) } {
296314 let Some ( wmsz) = ( unsafe { calculate_resize_direction ( hwnd, lparam) } ) else {
297315 return LRESULT ( 0 ) ;
298316 } ;
@@ -301,7 +319,7 @@ unsafe extern "system" fn helper_window_handle_message(hwnd: HWND, msg: u32, wpa
301319 let _ = unsafe { SetForegroundWindow ( main) } ;
302320
303321 // Start sizing on the main window in the calculated direction. (SC_SIZE + WMSZ_*)
304- let _ = unsafe { PostMessageW ( main, WM_SYSCOMMAND , WPARAM ( ( SC_SIZE + wmsz) as usize ) , lparam) } ;
322+ let _ = unsafe { PostMessageW ( Some ( main) , WM_SYSCOMMAND , WPARAM ( ( SC_SIZE + wmsz) as usize ) , lparam) } ;
305323 }
306324 return LRESULT ( 0 ) ;
307325 }
@@ -325,7 +343,7 @@ unsafe fn position_helper(main: HWND, helper: HWND) {
325343 let w = ( r. right - r. left ) + RESIZE_BAND_THICKNESS * 2 ;
326344 let h = ( r. bottom - r. top ) + RESIZE_BAND_THICKNESS * 2 ;
327345
328- let _ = unsafe { SetWindowPos ( helper, main, x, y, w, h, SWP_NOACTIVATE | SWP_NOSENDCHANGING ) } ;
346+ let _ = unsafe { SetWindowPos ( helper, Some ( main) , x, y, w, h, SWP_NOACTIVATE | SWP_NOSENDCHANGING ) } ;
329347}
330348
331349unsafe fn calculate_hit ( helper : HWND , lparam : LPARAM ) -> u32 {
0 commit comments