winsafe\user\handles/
hmonitor.rs

1#![allow(non_camel_case_types, non_snake_case)]
2
3use crate::co;
4use crate::decl::*;
5use crate::kernel::privs::*;
6use crate::user::ffi;
7
8handle! { HMONITOR;
9	/// Handle to a
10	/// [display monitor](https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types#hmonitor).
11}
12
13impl HMONITOR {
14	/// [`GetMonitorInfo`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmonitorinfow)
15	/// function.
16	pub fn GetMonitorInfo(&self) -> SysResult<MONITORINFOEX> {
17		let mut mi = MONITORINFOEX::default();
18		BoolRet(unsafe { ffi::GetMonitorInfoW(self.ptr(), pvoid(&mut mi)) })
19			.to_sysresult()
20			.map(|_| mi)
21	}
22
23	/// [`MonitorFromPoint`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-monitorfrompoint)
24	/// function.
25	#[must_use]
26	pub fn MonitorFromPoint(pt: POINT, flags: co::MONITOR) -> HMONITOR {
27		unsafe { HMONITOR::from_ptr(ffi::MonitorFromPoint(pt.x, pt.y, flags.raw())) }
28	}
29
30	/// [`MonitorFromRect`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-monitorfromrect)
31	/// function.
32	#[must_use]
33	pub fn MonitorFromRect(rc: RECT, flags: co::MONITOR) -> HMONITOR {
34		unsafe { HMONITOR::from_ptr(ffi::MonitorFromRect(pcvoid(&rc), flags.raw())) }
35	}
36}