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
45
46
47
48
49
50
51
use crate::*;
use Zeroable;
use GetWindowRect;
/// \[[learn.microsoft.com](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowrect)\]
/// GetWindowRect
///
/// Retrieves the dimensions of the bounding rectangle of the specified window.
/// The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
///
/// GetWindowRect is virtualized for DPI.
///
/// In Windows Vista and later, this includes the area occupied by the drop shadow.
///
/// To get the window bounds excluding the drop shadow, use
/// [DwmGetWindowAttribute](https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmgetwindowattribute),
/// specifying DWMWA_EXTENDED_FRAME_BOUNDS.
/// Note that unlike the Window Rect, the DWM Extended Frame Bounds are not adjusted for DPI.
/// Getting the extended frame bounds can only be done after the window has been shown at least once.
///
/// ### Errors
/// * [ERROR::INVALID_WINDOW_HANDLE]
///
/// ### Example
/// ```
/// # use hwnd::*;
/// # use winresult::*;
/// # use std::ptr::*;
/// # let desktop = get_desktop_window();
/// # let hwnd = unsafe { create_window_a(abistr::cstr!("Message"), (), 0, 0, 0, 0, 0, HWnd::MESSAGE, null_mut(), None, null_mut()).unwrap() };
/// #
/// let rect : Rect = get_window_rect(hwnd ).unwrap();
/// let rect : Rect = get_window_rect(get_desktop_window()).unwrap();
///
/// assert_eq!(ERROR::INVALID_WINDOW_HANDLE, get_window_rect(null_mut() ).unwrap_err());
/// assert_eq!(ERROR::INVALID_WINDOW_HANDLE, get_window_rect(HWnd::BROADCAST ).unwrap_err());
/// assert_eq!(ERROR::INVALID_WINDOW_HANDLE, get_window_rect(!42usize as HWND).unwrap_err());
/// ```
///
/// ### See Also
/// * [get_client_rect]
/// * [set_window_pos]