pub struct WindowsWindow(/* private fields */);
Expand description
Represents a window in the Windows platform.
Implementations§
Source§impl WindowsWindow
impl WindowsWindow
Sourcepub fn new(hwnd: HWND) -> Self
pub fn new(hwnd: HWND) -> Self
Creates a new WindowsWindow
from a raw HWND
.
§Warning
You must ensure that the hwnd
is a valid window handle. If you pass an invalid handle,
it may lead to errors on methods.
You can use get_window
to safely retrieve a WindowsWindow
.
Sourcepub fn hwnd(&self) -> HWND
pub fn hwnd(&self) -> HWND
Returns the raw handle to the window.
Examples found in repository?
7fn main() {
8 for window in window_getter::get_windows().unwrap() {
9 let window = window.into_platform_window();
10
11 println!("\n{:?} ({:?})", window.title(), window.hwnd());
12 println!("\tGetWindowRect: {:?}", window.rect());
13 println!(
14 "\tDwmGetWindowAttribute with DWMWA_EXTENDED_FRAME_BOUNDS: {:?}",
15 window.extended_frame_bounds()
16 );
17 }
18}
Sourcepub fn title(&self) -> Result<Option<String>, WindowsError>
pub fn title(&self) -> Result<Option<String>, WindowsError>
Returns the title of the window.
Examples found in repository?
7fn main() {
8 for window in window_getter::get_windows().unwrap() {
9 let window = window.into_platform_window();
10
11 println!("\n{:?} ({:?})", window.title(), window.hwnd());
12 println!("\tGetWindowRect: {:?}", window.rect());
13 println!(
14 "\tDwmGetWindowAttribute with DWMWA_EXTENDED_FRAME_BOUNDS: {:?}",
15 window.extended_frame_bounds()
16 );
17 }
18}
Sourcepub fn rect(&self) -> Result<RECT, WindowsError>
pub fn rect(&self) -> Result<RECT, WindowsError>
Returns the raw rectangle of the window by [GetWindowRect
].
It includes the invisible resize borders. So it may not be the same as the window rectangle that is actually seen.
Examples found in repository?
7fn main() {
8 for window in window_getter::get_windows().unwrap() {
9 let window = window.into_platform_window();
10
11 println!("\n{:?} ({:?})", window.title(), window.hwnd());
12 println!("\tGetWindowRect: {:?}", window.rect());
13 println!(
14 "\tDwmGetWindowAttribute with DWMWA_EXTENDED_FRAME_BOUNDS: {:?}",
15 window.extended_frame_bounds()
16 );
17 }
18}
Sourcepub fn bounds(&self) -> Result<Bounds, WindowsError>
pub fn bounds(&self) -> Result<Bounds, WindowsError>
This will return rect
value wrapped in WindowsBounds
.
Sourcepub fn extended_frame_bounds(&self) -> Result<RECT, WindowsError>
pub fn extended_frame_bounds(&self) -> Result<RECT, WindowsError>
Returns the extended frame bounds of the window
by [DwmGetWindowAttribute
] with [DWMWA_EXTENDED_FRAME_BOUNDS
].
Examples found in repository?
7fn main() {
8 for window in window_getter::get_windows().unwrap() {
9 let window = window.into_platform_window();
10
11 println!("\n{:?} ({:?})", window.title(), window.hwnd());
12 println!("\tGetWindowRect: {:?}", window.rect());
13 println!(
14 "\tDwmGetWindowAttribute with DWMWA_EXTENDED_FRAME_BOUNDS: {:?}",
15 window.extended_frame_bounds()
16 );
17 }
18}
Sourcepub fn visible_bounds(&self) -> Result<Bounds, WindowsError>
pub fn visible_bounds(&self) -> Result<Bounds, WindowsError>
Returns the bounds of the window.
This will return extended_frame_bounds
value wrapped in WindowsBounds
.
Sourcepub fn owner_pid(&self) -> Result<u32, WindowsError>
pub fn owner_pid(&self) -> Result<u32, WindowsError>
Returns the process ID of the owner of this window.
Sourcepub fn owner_process_handle(&self) -> Result<HANDLE, WindowsError>
pub fn owner_process_handle(&self) -> Result<HANDLE, WindowsError>
Returns the handle to the process that owns this window.
Sourcepub fn owner_name(&self) -> Result<String, WindowsError>
pub fn owner_name(&self) -> Result<String, WindowsError>
Returns the file name of the process that owns this window. This will return the name of the executable file.
Sourcepub fn is_foreground(&self) -> bool
pub fn is_foreground(&self) -> bool
Checks if the window is foreground.
Trait Implementations§
Source§impl Clone for WindowsWindow
impl Clone for WindowsWindow
Source§fn clone(&self) -> WindowsWindow
fn clone(&self) -> WindowsWindow
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more