Struct windows_win::Window

source ·
pub struct Window { /* private fields */ }
Expand description

Convenient wrapper over Window.

Note that while you can use it with any window. It makes no sense in taking ownership of not created by you windows.

This struct destroys window on drop and it is bad idea to do it for not your own window. If lucky, it fails but still not great idea.

Implementations§

source§

impl Window

source

pub fn from_hwnd(window: HWND) -> Self

Creates new instance by taking ownership over provided window.

source

pub fn from_builder(builder: &mut Builder) -> Result<Self>

Creates window from instance of window builder.

source

pub fn inner(&self) -> HWND

Returns underlying window.

Ownership is not passed.

source

pub fn into_inner(self) -> HWND

Transfers ownership of underlying window.

source

pub fn show(&self) -> bool

Shows window.

Returns true if previously it wasn’t visible

source

pub fn hide(&self) -> bool

Hide window.

Returns true if previously it was visible

source

pub fn is_visible(&self) -> bool

Returns whether window is visible.

source

pub fn class(&self) -> Result<String>

Retrieves window’s class.

source

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

Retrieves window’s title.

source

pub fn thread_pid(&self) -> (u32, u32)

Retrieves tuple of thread and process ids.

source

pub fn send_message( &self, msg_type: UINT, w_param: WPARAM, l_param: LPARAM, timeout: Option<UINT> ) -> Result<LRESULT>

Sends message to underlying window.

For more information refer to send_message()

source

pub fn send_push_button(&self, timeout: Option<UINT>) -> Result<LRESULT>

Sends BM_CLICK message to underlying window.

For mores information refer to send_push_button()

source

pub fn send_set_text<T: AsRef<OsStr>>(&self, text: T) -> bool

Sends WM_SETTEXT message to underlying window with new text.

For more information refer to send_set_text()

source

pub fn send_get_text(&self) -> Option<String>

Sends WM_GETTEXT message to underlying window and returns, if possible, corresponding text.

For more information refer to send_get_text()

source

pub fn send_sys_command(&self, cmd_type: WPARAM, l_param: LPARAM) -> bool

Sends WM_SYSCOMMAND message to underlying window and returns, if possible, corresponding text.

For more information refer to send_sys_command()

source

pub fn destroy(self)

Destroys underlying window and drops self.

Trait Implementations§

source§

impl Drop for Window

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl From<*mut c_void> for Window

source§

fn from(window: HWND) -> Window

Converts to this type from the input type.
source§

impl Into<*mut c_void> for Window

source§

fn into(self) -> HWND

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

§

impl RefUnwindSafe for Window

§

impl !Send for Window

§

impl !Sync for Window

§

impl Unpin for Window

§

impl UnwindSafe for Window

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.