hwnd/um/winuser/structures/
wndclass.rs1use crate::*;
2use bytemuck::*;
3use std::fmt::{self, Debug, Formatter};
4use std::ptr::*;
5
6
7
8pub type WndProcNonNull = unsafe extern "system" fn (hwnd: HWnd, msg: WM32, wparam: WPARAM, lparam: LPARAM) -> LRESULT;
9pub type WndProc = Option<WndProcNonNull>;
10
11#[derive(Clone, Copy)]
18#[repr(C)] pub struct WndClassA<'a> {
19 pub style: WindowStyle,
20 pub wnd_proc: WndProc,
21 pub cls_extra: i32,
22 pub wnd_extra: i32,
23 pub hinstance: HInstance<'static>,
24 pub hicon: HIcon<'static>,
25 pub hcursor: HCursor<'static>,
26 pub background: HBRUSH, pub menu_name: Option<abistr::CStrNonNull<'a>>, pub class_name: Option<abistr::CStrNonNull<'a>>, }
30
31#[derive(Clone, Copy)]
38#[repr(C)] pub struct WndClassW<'a> {
39 pub style: WindowStyle,
40 pub wnd_proc: WndProc,
41 pub cls_extra: i32,
42 pub wnd_extra: i32,
43 pub hinstance: HInstance<'static>,
44 pub hicon: HIcon<'static>,
45 pub hcursor: HCursor<'static>,
46 pub background: HBRUSH, pub menu_name: Option<abistr::CStrNonNull<'a, u16>>, pub class_name: Option<abistr::CStrNonNull<'a, u16>>, }
50
51#[derive(Clone, Copy)]
58#[repr(C)] pub struct WndClassExA<'a> {
59 pub size: u32,
60 pub style: WindowStyle,
61 pub wnd_proc: WndProc,
62 pub cls_extra: i32,
63 pub wnd_extra: i32,
64 pub hinstance: HInstance<'static>,
65 pub hicon: HIcon<'static>,
66 pub hcursor: HCursor<'static>,
67 pub background: HBRUSH, pub menu_name: Option<abistr::CStrNonNull<'a>>, pub class_name: Option<abistr::CStrNonNull<'a>>, pub hicon_sm: HIcon<'static>,
71}
72
73#[derive(Clone, Copy)]
80#[repr(C)] pub struct WndClassExW<'a> {
81 pub size: u32,
82 pub style: WindowStyle,
83 pub wnd_proc: WndProc,
84 pub cls_extra: i32,
85 pub wnd_extra: i32,
86 pub hinstance: HInstance<'static>,
87 pub hicon: HIcon<'static>,
88 pub hcursor: HCursor<'static>,
89 pub background: HBRUSH, pub menu_name: Option<abistr::CStrNonNull<'a, u16>>, pub class_name: Option<abistr::CStrNonNull<'a, u16>>, pub hicon_sm: HIcon<'static>,
93}
94
95unsafe impl Zeroable for WndClassA<'_> {} unsafe impl Zeroable for WndClassW<'_> {} unsafe impl Zeroable for WndClassExA<'_> {} unsafe impl Zeroable for WndClassExW<'_> {} impl Default for WndClassA<'_> { fn default() -> Self { Self::zeroed() } }
101impl Default for WndClassW<'_> { fn default() -> Self { Self::zeroed() } }
102impl Default for WndClassExA<'_> { fn default() -> Self { Self { size: size_of_32::<Self>(), ..Self::zeroed() } } }
103impl Default for WndClassExW<'_> { fn default() -> Self { Self { size: size_of_32::<Self>(), ..Self::zeroed() } } }
104
105impl Debug for WndClassA<'_> {
106 fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
107 fmt.debug_struct("WndClassA")
108 .field("style", &self.style )
109 .field("wnd_proc", &self.wnd_proc.map_or(null::<()>(), |f| unsafe { std::mem::transmute(f) }))
110 .field("cls_extra", &self.cls_extra )
111 .field("wnd_extra", &self.wnd_extra )
112 .field("hinstance", &self.hinstance )
113 .field("hicon", &self.hicon )
114 .field("hcursor", &self.hcursor )
115 .field("background", &self.background )
116 .field("menu_name", &self.menu_name )
117 .field("class_name", &self.class_name )
118 .finish()
119 }
120}
121
122impl Debug for WndClassW<'_> {
123 fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
124 fmt.debug_struct("WndClassW")
125 .field("style", &self.style )
126 .field("wnd_proc", &self.wnd_proc.map_or(null::<()>(), |f| unsafe { std::mem::transmute(f) }))
127 .field("cls_extra", &self.cls_extra )
128 .field("wnd_extra", &self.wnd_extra )
129 .field("hinstance", &self.hinstance )
130 .field("hicon", &self.hicon )
131 .field("hcursor", &self.hcursor )
132 .field("background", &self.background )
133 .field("menu_name", &self.menu_name )
134 .field("class_name", &self.class_name )
135 .finish()
136 }
137}
138
139impl Debug for WndClassExA<'_> {
140 fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
141 fmt.debug_struct("WndClassExA")
142 .field("size", &self.size )
143 .field("style", &self.style )
144 .field("wnd_proc", &self.wnd_proc.map_or(null::<()>(), |f| unsafe { std::mem::transmute(f) }))
145 .field("cls_extra", &self.cls_extra )
146 .field("wnd_extra", &self.wnd_extra )
147 .field("hinstance", &self.hinstance )
148 .field("hicon", &self.hicon )
149 .field("hcursor", &self.hcursor )
150 .field("background", &self.background )
151 .field("menu_name", &self.menu_name )
152 .field("class_name", &self.class_name )
153 .field("hicon_sm", &self.hicon_sm )
154 .finish()
155 }
156}
157
158impl Debug for WndClassExW<'_> {
159 fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
160 fmt.debug_struct("WndClassExW")
161 .field("size", &self.size )
162 .field("style", &self.style )
163 .field("wnd_proc", &self.wnd_proc.map_or(null::<()>(), |f| unsafe { std::mem::transmute(f) }))
164 .field("cls_extra", &self.cls_extra )
165 .field("wnd_extra", &self.wnd_extra )
166 .field("hinstance", &self.hinstance )
167 .field("hicon", &self.hicon )
168 .field("hcursor", &self.hcursor )
169 .field("background", &self.background )
170 .field("menu_name", &self.menu_name )
171 .field("class_name", &self.class_name )
172 .field("hicon_sm", &self.hicon_sm )
173 .finish()
174 }
175}
176
177convert! {
178 WndClassA<'_> => unsafe { winapi::um::winuser::WNDCLASSA },
179 WndClassW<'_> => unsafe { winapi::um::winuser::WNDCLASSW },
180 WndClassExA<'_> => unsafe { winapi::um::winuser::WNDCLASSEXA },
181 WndClassExW<'_> => unsafe { winapi::um::winuser::WNDCLASSEXW },
182}