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
use ;
use crate::*;
/// Creates a new `GraphicsCaptureItem` from a monitor handle.
///
/// This function uses the Windows Runtime interop interface to create a graphics capture item
/// that represents the specified monitor. This is commonly used for screen capture scenarios
/// where you want to capture the entire contents of a specific monitor.
///
/// # Arguments
///
/// * `monitor` - An `HMONITOR` handle representing the monitor to create a capture item for.
///
/// # Returns
///
/// * `Ok(GraphicsCaptureItem)` - A successfully created graphics capture item for the monitor.
/// * `Err(WgcError)` - An error occurred during the creation process, such as:
/// - The interop factory could not be obtained.
/// - The `CreateForMonitor` call failed (e.g., invalid monitor handle).
///
/// # Safety
///
/// This function uses unsafe code to call the `CreateForMonitor` method. The caller must ensure
/// that the provided `HMONITOR` handle is valid.
///
/// # Example
///
/// ```ignore
/// use windows::Win32::Graphics::Gdi::HMONITOR;
/// let monitor = /* obtain HMONITOR handle */;
/// let capture_item = new_item_from_monitor(monitor)?;
/// ```