Struct native_windows_gui::Notice
source · [−]pub struct Notice {
pub handle: ControlHandle,
}
Expand description
An invisible component that can be triggered by other thread.
A notice object does not send data between threads. Rust has already plenty of way to do this. The notice object only serve to “wake up” the GUI thread.
A notice must have a parent window. If the parent is destroyed before the notice, the notice becomes invalid.
Requires the notice
feature.
Example
use native_windows_gui as nwg;
fn build_notice(notice: &mut nwg::Notice, window: &nwg::Window) {
nwg::Notice::builder()
.parent(window)
.build(notice);
}
use native_windows_gui as nwg;
use std::thread;
use std::time;
fn notice(noticer: &nwg::Notice) {
let sender = noticer.sender();
thread::spawn(move || {
thread::sleep(time::Duration::new(5, 0));
sender.notice();
});
}
Fields
handle: ControlHandle
Implementations
sourceimpl Notice
impl Notice
pub fn builder() -> NoticeBuilder
sourcepub fn create<C: Into<ControlHandle>>(parent: C) -> Result<Notice, NwgError>
pub fn create<C: Into<ControlHandle>>(parent: C) -> Result<Notice, NwgError>
A shortcut over the builder API for the notice object
sourcepub fn valid(&self) -> bool
pub fn valid(&self) -> bool
Checks if the notice is still usable. A notice becomes unusable when the parent window is destroyed. This will also return false if the notice is not initialized.
sourcepub fn window_handle(&self) -> Option<ControlHandle>
pub fn window_handle(&self) -> Option<ControlHandle>
Return an handle to the notice window or None
if the window was destroyed.
sourcepub fn set_window_handle<C: Into<ControlHandle>>(&mut self, window: C)
pub fn set_window_handle<C: Into<ControlHandle>>(&mut self, window: C)
Change the parent window of the notice. This won’t update the NoticeSender already created. Panics if the control is not a window-like control or if the notice was not initialized
sourcepub fn sender(&self) -> NoticeSender
pub fn sender(&self) -> NoticeSender
Create a new NoticeSender
bound to this Notice
Trait Implementations
sourceimpl From<&Notice> for ControlHandle
impl From<&Notice> for ControlHandle
sourceimpl From<&mut Notice> for ControlHandle
impl From<&mut Notice> for ControlHandle
sourceimpl PartialEq<ControlHandle> for Notice
impl PartialEq<ControlHandle> for Notice
sourcefn eq(&self, other: &ControlHandle) -> bool
fn eq(&self, other: &ControlHandle) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl PartialEq<Notice> for ControlHandle
impl PartialEq<Notice> for ControlHandle
sourceimpl PartialEq<Notice> for Notice
impl PartialEq<Notice> for Notice
impl Eq for Notice
impl StructuralEq for Notice
impl StructuralPartialEq for Notice
Auto Trait Implementations
impl RefUnwindSafe for Notice
impl !Send for Notice
impl !Sync for Notice
impl Unpin for Notice
impl UnwindSafe for Notice
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more