use core::ptr::null_mut; use fenestroj::*; unsafe extern "system" fn callback( win: HWND, msg: u32, wparam: usize, lparam: isize, ) -> isize { match msg { WM_DESTROY => { post_quit_message(0); 0 } _ => default_window_proc(win, msg, wparam, lparam), } } fn main() { const CLASS_NAME: &str = "demo_class"; unsafe { let _class_atom = register_class(WinClass { menu_name: "", class_name: CLASS_NAME, wnd_proc: Some(callback), cursor: load_cursor(null_mut(), IDC_ARROW).ok(), ..WinClass::default() }) .expect("Couldn't register a class!"); const WINDOW_STYLE: WindowStyle = WindowStyle(0) .with_caption(true) .with_border(true) .with_sys_menu(true) .with_visible(true); let _window = create_window_ex(CreateWindowExRequest { class_name: CLASS_NAME, window_name: "Demo Window", x: CW_USEDEFAULT, y: CW_USEDEFAULT, width: 800, height: 600, style: WINDOW_STYLE, ..CreateWindowExRequest::default() }) .expect("Couldn't create a window!"); let mut msg = MSG::default(); // Note: `get_message` blocks until there's a message, and the Ok side of // the result is a "should you keep going?" bool. while get_message(&mut msg, null_mut(), 0, 0).unwrap() { translate_message(&msg); dispatch_message(&msg); } } }