Struct Window

Source
pub struct Window<S> { /* private fields */ }
Expand description

Owned window handle.

Dropping the handle destroys the window.

Implementations§

Source§

impl<S> Window<S>

Source

pub fn new<F>( window_type: WindowType, state: S, wndproc: F, ) -> Result<Self, WindowCreationError>
where F: Fn(Pin<&S>, WindowMessage) -> Option<LRESULT> + 'static,

Creates a new window with a wndproc closure.

The state parameter will be allocated alongside the closure. It is meant as a convenient alternative to Rc<State> to access to variables from both inside and outside of the closure. A pinned reference to the state is passed as first parameter the closure. Use Window::state() to access the state from the outside.

Source

pub fn new_checked<F>( window_type: WindowType, state: S, wndproc: F, ) -> Result<Self, WindowCreationError>
where F: FnMut(Pin<&S>, WindowMessage) -> Option<LRESULT> + 'static,

Same as Window::new() but allows the closure to be FnMut.

Internally uses a RefCell for the closure to prevent it from being re-entered by nested message loops (e.g., from modal dialogs). Forwards nested messages to the default wndproc procedure.

Source

pub fn hwnd(&self) -> HWND

Returns this windows raw window handle.

Source

pub fn state(&self) -> Pin<&S>

Returns a reference to the state shared with the wndproc closure.

Trait Implementations§

Source§

impl<S: Debug> Debug for Window<S>

Source§

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

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

impl<S> Drop for Window<S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<S> Freeze for Window<S>

§

impl<S> RefUnwindSafe for Window<S>
where S: RefUnwindSafe,

§

impl<S> !Send for Window<S>

§

impl<S> !Sync for Window<S>

§

impl<S> Unpin for Window<S>
where S: Unpin,

§

impl<S> UnwindSafe for Window<S>
where S: UnwindSafe,

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

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.