1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate::*;
use *;
use GetClientRect;
/// \[[learn.microsoft.com](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclientrect)\]
/// GetClientRect
///
/// Retrieves the coordinates of a window's client area.
/// The client coordinates specify the upper-left and lower-right corners of the client area.
/// Because client coordinates are relative to the upper-left corner of a window's client area, the coordinates of the upper-left corner are (0,0).
///
/// ### Errors
/// * [ERROR::INVALID_WINDOW_HANDLE]
///
/// ### Example
/// ```rust
/// # use hwnd::*;
/// # use winresult::*;
/// # use std::ptr::*;
/// let rect = get_client_rect(get_desktop_window()).unwrap();
/// assert_eq!(0, rect.left);
/// assert_eq!(0, rect.top);
/// assert!(0 != rect.right);
/// assert!(0 != rect.bottom);
///
/// assert_eq!(
/// ERROR::INVALID_WINDOW_HANDLE,
/// get_client_rect(null_mut()).unwrap_err(),
/// );
/// # for p in 0 .. 8 * std::mem::size_of::<HWND>() {
/// # if let Err(e) = get_client_rect((1usize << p) as HWND) { // shouldn't crash
/// # assert_eq!(ERROR::INVALID_WINDOW_HANDLE, e);
/// # }
/// # }
/// ```