Struct winsafe::gui::WindowModal
source · pub struct WindowModal(/* private fields */);
gui
only.Expand description
An user modal window, which can handle events. Can be programmatically
created or load a dialog resource from a .res
file.
Implementations§
source§impl WindowModal
impl WindowModal
sourcepub fn new(parent: &impl GuiParent, opts: WindowModalOpts) -> Self
pub fn new(parent: &impl GuiParent, opts: WindowModalOpts) -> Self
Instantiates a new WindowModal
object, to be created internally with
HWND::CreateWindowEx
.
sourcepub fn new_dlg(parent: &impl GuiParent, dialog_id: u16) -> Self
pub fn new_dlg(parent: &impl GuiParent, dialog_id: u16) -> Self
Instantiates a new WindowModal
object, to be loaded from a dialog
resource with
HINSTANCE::DialogBoxParam
.
sourcepub fn show_modal(&self) -> AnyResult<i32>
pub fn show_modal(&self) -> AnyResult<i32>
Physically creates the window, then runs the modal loop. This method will block until the window is closed.
For a modal created with
WindowModal::new
, the returned i32
is always zero.
For a modal created with
WindowModal::new_dlg
, the returned
i32
is the value passed to
HWND::EndDialog
. Note that, if
the user clicks the “X” to close the modal, the default behavior is to
call EndDialog(0)
. To override this behavior, handle the
modal’s wm_close
yourself.
§Panics
Panics if the window is already created.
Trait Implementations§
source§impl Clone for WindowModal
impl Clone for WindowModal
source§fn clone(&self) -> WindowModal
fn clone(&self) -> WindowModal
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl GuiParent for WindowModal
impl GuiParent for WindowModal
source§fn on(&self) -> &WindowEvents
fn on(&self) -> &WindowEvents
source§fn spawn_new_thread<F>(&self, func: F)
fn spawn_new_thread<F>(&self, func: F)
std::thread::spawn
, but it allows the returning of
an error value. This error value will be forwarded to the original UI
thread, allowing it to be caught at
WindowMain::run_main
. Read moresource§impl GuiParentPopup for WindowModal
impl GuiParentPopup for WindowModal
source§impl GuiWindow for WindowModal
impl GuiWindow for WindowModal
source§impl GuiWindowText for WindowModal
impl GuiWindowText for WindowModal
source§fn set_text(&self, text: &str)
fn set_text(&self, text: &str)
HWND::SetWindowText
.source§fn text(&self) -> String
fn text(&self) -> String
HWND::GetWindowText
.