Skip to main content

finestre_sys/user32/
mod.rs

1mod consts;
2pub use consts::*;
3use crate::typedefs::*;
4
5
6#[link(name = "User32")]
7unsafe extern "system" {
8    pub unsafe fn FindWindowExW(
9        parent_window: HWND,
10        child_window_after: HWND,
11        window_class: LPCWSTR,
12        window_name: LPCWSTR,
13    ) -> HWND;
14
15    pub unsafe fn RegisterWindowMessageW(
16        message: LPCWSTR,
17    ) -> UINT;
18
19    pub unsafe fn SendMessageTimeoutW(
20        window: HWND,
21        message: UINT,
22        w_param: WPARAM,
23        l_param: LPARAM,
24        flags: UINT,
25        timeout: UINT,
26        result: *mut DWORD_PTR
27    ) -> LRESULT;
28
29    pub unsafe fn MessageBoxW(
30        window: HWND,
31        text: LPCWSTR,
32        caption: LPCWSTR,
33        message_box_type: UINT
34    ) -> INT;
35
36    pub unsafe fn GetSysColor(
37        index: INT
38    ) -> DWORD;
39    
40    pub unsafe fn LoadImageW(
41        instance: HINSTANCE,
42        name: LPCWSTR,
43        image_type: UINT,
44        width: INT,
45        height: INT,
46        load_options: UINT
47    ) -> HANDLE;
48
49    pub unsafe fn RegisterClassExW(
50        window_class: *const WndClassExW
51    ) -> ATOM;
52
53    pub unsafe fn CreateWindowExW(
54        extended_style: DWORD,
55        class_name: LPCWSTR,
56        window_name: LPCWSTR,
57        style: DWORD,
58        x: INT,
59        y: INT,
60        width: INT,
61        height: INT,
62        parent_window: HWND,
63        menu: HMENU,
64        instance: HINSTANCE,
65        user_data_pointer: LPVOID
66    ) -> HWND;
67
68    pub unsafe fn DestroyWindow(
69        window: HWND
70    ) -> BOOL;
71
72    pub unsafe fn GetMessageW(
73        message: *mut Msg,
74        window: HWND,
75        message_filter_min: UINT,
76        message_filter_max: UINT
77    ) -> BOOL;
78
79    pub unsafe fn PeekMessageW(
80        message: *mut Msg,
81        window: HWND,
82        message_filter_min: UINT,
83        message_filter_max: UINT,
84        remove_message: UINT
85    ) -> BOOL;
86
87    pub unsafe fn SendMessageW(
88        window: HWND,
89        message: UINT,
90        w_param: WPARAM,
91        l_param: LPARAM
92    ) -> LRESULT;
93
94    pub unsafe fn TranslateMessage(
95        message: *const Msg
96    ) -> BOOL;
97
98    pub unsafe fn DispatchMessageW(
99        message: *const Msg
100    ) -> LRESULT;
101
102    pub unsafe fn PostQuitMessage(
103        exit_code: INT
104    );
105
106    pub unsafe fn SetTimer(
107        window: HWND,
108        event_id: UINT_PTR,
109        time_out_ms: UINT,
110        timer_proc: TIMERPROC
111    ) -> UINT_PTR;
112
113    pub unsafe fn GetSystemMetrics(
114        index: INT
115    ) -> INT;
116
117    pub unsafe fn GetClientRect(
118        window: HWND,
119        rect: *mut Rect
120    ) -> BOOL;
121
122    pub unsafe fn GetWindowLongPtrW(
123        window: HWND,
124        index: INT
125    ) -> LONG_PTR;
126
127    pub unsafe fn SetWindowLongPtrW(
128        window: HWND,
129        index: INT,
130        new_pointer: LONG_PTR
131    ) -> LONG_PTR;
132
133    pub unsafe fn DefWindowProcW(
134        window: HWND,
135        message: UINT,
136        w_param: WPARAM,
137        l_param: LPARAM
138    ) -> LRESULT;
139}
140
141
142
143#[repr(C)]
144#[derive(finestre_init_with_size_derive::InitWithSize)]
145pub struct WndClassExW {
146    pub size: UINT,
147    pub style: UINT,
148    pub window_proc: WNDPROC,
149    pub class_extra_bytes: INT,
150    pub window_extra_bytes: INT,
151    pub instance: HINSTANCE,
152    pub icon: HICON,
153    pub cursor: HCURSOR,
154    pub background_brush: HBRUSH,
155    pub menu_name: LPCWSTR,
156    pub class_name: LPCWSTR,
157    pub icon_small: HICON
158}
159
160#[repr(C)]
161pub struct Point {
162    pub x: LONG,
163    pub y: LONG
164}
165
166#[repr(C)]
167pub struct Rect {
168    pub left: LONG,
169    pub top: LONG,
170    pub right: LONG,
171    pub bottom: LONG
172}
173
174#[repr(C)]
175pub struct Msg {
176    pub window: HWND,
177    pub message: UINT,
178    pub w_param: WPARAM,
179    pub l_param: LPARAM,
180    pub time: DWORD,
181    pub point: Point,
182    private: DWORD
183}
184
185
186#[repr(C)]
187pub struct CreateStructW {
188    pub user_data_pointer: LPVOID,
189    pub instance: HINSTANCE,
190    pub menu: HMENU,
191    pub parent_window: HWND,
192    pub height: INT,
193    pub width: INT,
194    pub y: INT,
195    pub x: INT,
196    pub style: LONG,
197    pub window_name: LPCWSTR,
198    pub class_name: LPCWSTR,
199    pub extended_style: DWORD
200}