From abd64adb168c91e064711984f759b8563b059790 Mon Sep 17 00:00:00 2001 From: Mirko Covizzi Date: Fri, 29 May 2020 22:29:49 +0200 Subject: [PATCH] Make code more idiomatic --- src/win/window.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/win/window.rs b/src/win/window.rs index 24bff21..f13322a 100644 --- a/src/win/window.rs +++ b/src/win/window.rs @@ -4,10 +4,10 @@ use std::ffi::CString; use std::ptr::null_mut; use self::winapi::shared::guiddef::GUID; -use self::winapi::shared::minwindef::{LPARAM, LPVOID, LRESULT, UINT, WPARAM}; -use self::winapi::shared::windef::{HBRUSH, HGLRC, HICON, HMENU, HWND}; +use self::winapi::shared::minwindef::{LPARAM, LRESULT, UINT, WPARAM}; +use self::winapi::shared::windef::{HGLRC, HWND}; use self::winapi::um::combaseapi::CoCreateGuid; -use self::winapi::um::libloaderapi::{GetModuleHandleA, GetProcAddress, LoadLibraryA}; +use self::winapi::um::libloaderapi::{GetProcAddress, LoadLibraryA}; use self::winapi::um::wingdi::{ wglCreateContext, wglMakeCurrent, ChoosePixelFormat, SetPixelFormat, SwapBuffers, PFD_DOUBLEBUFFER, PFD_DRAW_TO_WINDOW, PFD_MAIN_PLANE, PFD_SUPPORT_OPENGL, PFD_TYPE_RGBA, @@ -45,18 +45,17 @@ impl Window { guid.Data4[7] ); - let hinstance = GetModuleHandleA(std::ptr::null::()); let wnd_class = WNDCLASSA { // todo: for OpenGL, will use it later style: CS_OWNDC | CS_HREDRAW | CS_VREDRAW, lpfnWndProc: Some(wnd_proc), - hInstance: hinstance, + hInstance: null_mut(), lpszClassName: class_name.as_ptr() as *const i8, cbClsExtra: 0, cbWndExtra: 0, - hIcon: 0 as HICON, - hCursor: 0 as HICON, - hbrBackground: 0 as HBRUSH, + hIcon: null_mut(), + hCursor: null_mut(), + hbrBackground: null_mut(), lpszMenuName: std::ptr::null::(), }; RegisterClassA(&wnd_class); @@ -72,10 +71,10 @@ impl Window { // todo: check if usize fits into i32 options.width as i32, options.height as i32, - 0 as HWND, - 0 as HMENU, - hinstance, - 0 as LPVOID, + null_mut(), + null_mut(), + null_mut(), + null_mut(), ); let hdc = GetDC(hwnd);