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
52
53
54
55
56
use crate::*;
use *;
/// \[[learn.microsoft.com](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowplacement)\]
/// SetWindowPlacement
///
/// Retrieves the show state and the restored, minimized, and maximized positions of the specified window.
///
/// ### Errors
/// * [ERROR::INVALID_WINDOW_HANDLE] If `hwnd` is invalid
/// * [ERROR::INVALID_PARAMETER] If `wndpl` / `wndpl.length` is invalid
/// * [ERROR::FUNCTION_FAILED] If the function failed without a proper error code (happens when e.g. setting the desktop hwnd placement)
///
/// ### Example
/// ```
/// # use hwnd::*;
/// # use winresult::*;
/// # use std::ptr::*;
/// # let hwnd = unsafe { create_window_ex_w(0, abistr::cstr16!("Message"), (), 0, 0, 0, 0, 0, HWnd::MESSAGE, null_mut(), None, null_mut()) }.unwrap();
/// # let mut p : WindowPlacement = get_window_placement(get_desktop_window()).unwrap();
/// # p.length = 11;
/// # #[cfg(nope)] {
/// let mut p : WindowPlacement = ..;
/// # }
///
/// p.length = std::mem::size_of_val(&p) as _;
/// set_window_placement(hwnd, &p).unwrap();
///
/// assert_eq!(ERROR::INVALID_WINDOW_HANDLE, set_window_placement(HWnd::NULL, &p), "null");
/// assert_eq!(ERROR::INVALID_WINDOW_HANDLE, set_window_placement(!42usize as HWND, &p), "!42");
/// assert_eq!(ERROR::FUNCTION_FAILED, set_window_placement(get_desktop_window(), &p));
///
/// for length in 0 .. 1000 {
/// p.length = length;
/// if p.length == std::mem::size_of_val(&p) as u32 { continue }
/// assert_eq!(ERROR::INVALID_PARAMETER, set_window_placement(hwnd, &p), "length: {length}");
/// }
/// ```
///
/// ### See Also
/// * [WindowPlacement]
/// * [get_window_placement]
/// * [get_window_rect]
/// * [set_window_pos]