Struct WinDialog

Source
pub struct WinDialog<T = OkCancel, const DEFAULT_BUTTON: i32 = 0>
where T: DialogStyle,
{ /* private fields */ }
Expand description

A builder struct used for configuring a MessageBox. Uses the MessageBoxA function under the hood.

From the official Windows documentation:

“Displays a modal dialog box that contains a system icon, a set of buttons, and a brief application-specific message, such as status or error information. The message box returns an integer value that indicates which button the user clicked.”

The default button const generic

Implementations§

Source§

impl WinDialog

Source

pub fn new(content: impl Into<String>) -> Self

Create a new dialog with content only. This will wait indefinitely for user input and will have a default windows title. It will display a simple popover with only an Ok button and a close icon in the top right.

Source§

impl<T> WinDialog<T>
where T: Default + DialogStyle,

Source

pub fn with_header(self, header: impl Into<String>) -> Self

Sets custom content for the message box header. Passing nothing results in rendering a default header. Passing an empty string results in no header.

Source

pub fn with_icon(self, icon: impl Into<Icon>) -> Self

Set an Icon for the dialog box.

Source

pub fn set_parent_window( self, handle: impl Into<HWND>, ) -> WinDialogWithParent<T>

A handle to the owner window of the message box to be created. If you don’t call this method and provide a handle to the owner window, the Message Box will have no parent window.

Attaching a parent window will allow you to add an extra ‘help’ button to the message box. See WinDialogWithParent::with_help_button for more information.

Source

pub fn set_modality(self, modality: Modality) -> Self

Indicate the modality of the dialog box. See Modality for the options.

Source

pub fn set_default_desktop_only(self) -> Self

Same as desktop of the interactive window station. For more information, see Window Stations. If the current input desktop is not the default desktop, the Message Box does not return until the user switches to the default desktop.

Source

pub fn set_right_justify(self) -> Self

Set the text to right-justify style.

Source

pub fn set_right_to_left_reading(self) -> Self

Displays message and caption text using right-to-left reading order on Hebrew and Arabic systems.

Source

pub fn set_foreground(self) -> Self

The message box becomes the foreground window. Internally, the system calls the SetForegroundWindow function for the message box.

Source

pub fn set_topmost(self) -> Self

The message box is created with the WS_EX_TOPMOST window style.

Source

pub fn make_service_notification(self) -> Self

The caller is a service notifying the user of an event. The function displays a message box on the current active desktop, even if there is no user logged on to the computer. Terminal Services: If the calling thread has an impersonation token, the function directs the message box to the session specified in the impersonation token.

If this function is set, the window must not have a parent. This is so that the message box can appear on a desktop other than the desktop corresponding to the parent window. For this reason, if you call WinDialog::set_parent_window, this parameter will be unset.

For information on security considerations in regard to using this flag, see Interactive Services. In particular, be aware that this flag can produce interactive content on a locked desktop and should therefore be used for only a very limited set of scenarios, such as resource exhaustion.

Source

pub fn with_style<N>(self, style: N) -> WinDialog<N>
where N: DialogStyle,

Indicate which set of actions that you want the user to have. Check the available options in crate::style.

Source

pub fn show(self) -> Result<<T as DialogStyle>::Return>

Display the dialog and convert results into proper Result type. This is a synchronous action.

Source§

impl WinDialog<OkCancel>

Source

pub fn set_default_cancel(self) -> Self

Make crate::style::OkCancelResponse::Cancel the default response,

Source§

impl WinDialog<AbortRetryIgnore>

Source

pub fn set_default_retry(self) -> Self

Source

pub fn set_default_ignore(self) -> Self

Source§

impl WinDialog<YesNoCancel>

Source

pub fn set_default_no(self) -> Self

Make crate::style::YesNoCancelResponse::No the default response,

Source

pub fn set_default_cancel(self) -> Self

Make crate::style::YesNoCancelResponse::Cancel the default response.

Source§

impl WinDialog<YesNo>

Source

pub fn set_default_no(self) -> Self

Make crate::style::YesNoResponse::No the default response.

Source§

impl WinDialog<RetryCancel>

Source

pub fn set_default_cancel(self) -> Self

Make crate::style::RetryCancelResponse::Cancel the default response.

Source§

impl WinDialog<CancelRetryContinue>

Trait Implementations§

Source§

impl<T, const DEFAULT_BUTTON: i32> Debug for WinDialog<T, DEFAULT_BUTTON>
where T: DialogStyle + Debug,

Source§

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

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

impl<T, const DEFAULT_BUTTON: i32> Default for WinDialog<T, DEFAULT_BUTTON>
where T: DialogStyle + Default,

Source§

fn default() -> WinDialog<T, DEFAULT_BUTTON>

Returns the “default value” for a type. Read more
Source§

impl<T, const DEFAULT_BUTTON: i32> PartialEq for WinDialog<T, DEFAULT_BUTTON>

Source§

fn eq(&self, other: &WinDialog<T, DEFAULT_BUTTON>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, const DEFAULT_BUTTON: i32> StructuralPartialEq for WinDialog<T, DEFAULT_BUTTON>
where T: DialogStyle,

Auto Trait Implementations§

§

impl<T, const DEFAULT_BUTTON: i32> Freeze for WinDialog<T, DEFAULT_BUTTON>
where T: Freeze,

§

impl<T, const DEFAULT_BUTTON: i32> RefUnwindSafe for WinDialog<T, DEFAULT_BUTTON>
where T: RefUnwindSafe,

§

impl<T, const DEFAULT_BUTTON: i32> Send for WinDialog<T, DEFAULT_BUTTON>
where T: Send,

§

impl<T, const DEFAULT_BUTTON: i32> Sync for WinDialog<T, DEFAULT_BUTTON>
where T: Sync,

§

impl<T, const DEFAULT_BUTTON: i32> Unpin for WinDialog<T, DEFAULT_BUTTON>
where T: Unpin,

§

impl<T, const DEFAULT_BUTTON: i32> UnwindSafe for WinDialog<T, DEFAULT_BUTTON>
where T: 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.