Skip to main content

WindowsWindow

Struct WindowsWindow 

Source
pub struct WindowsWindow(/* private fields */);
Expand description

Represents a window in the Windows platform.

Implementations§

Source§

impl WindowsWindow

Source

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.

Source

pub fn hwnd(&self) -> HWND

Returns the raw handle to the window.

Examples found in repository?
examples/windows_various_rect.rs (line 11)
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}
Source

pub fn title(&self) -> Result<Option<String>, WindowsError>

Returns the title of the window.

Examples found in repository?
examples/windows_various_rect.rs (line 11)
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}
Source

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?
examples/windows_various_rect.rs (line 12)
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}
Source

pub fn bounds(&self) -> Result<Bounds, WindowsError>

This will return rect value wrapped in WindowsBounds.

Source

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?
examples/windows_various_rect.rs (line 15)
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}
Source

pub fn visible_bounds(&self) -> Result<Bounds, WindowsError>

Returns the bounds of the window. This will return extended_frame_bounds value wrapped in WindowsBounds.

Source

pub fn owner_pid(&self) -> Result<u32, WindowsError>

Returns the process ID of the owner of this window.

Source

pub fn owner_process_handle(&self) -> Result<HANDLE, WindowsError>

Returns the handle to the process that owns this window.

Source

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.

Source

pub fn is_foreground(&self) -> bool

Checks if the window is foreground.

Trait Implementations§

Source§

impl Clone for WindowsWindow

Source§

fn clone(&self) -> WindowsWindow

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for WindowsWindow

Source§

impl Debug for WindowsWindow

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for WindowsWindow

Source§

impl PartialEq for WindowsWindow

Source§

fn eq(&self, other: &WindowsWindow) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Send for WindowsWindow

Source§

impl StructuralPartialEq for WindowsWindow

Source§

impl Sync for WindowsWindow

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.