Struct MessageBox

Source
pub struct MessageBox<'a, T> { /* private fields */ }
Expand description

A builder for 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 type of the message box is specified by T (See Options for available options).

Implementations§

Source§

impl<'a, T> MessageBox<'a, T>

Source

pub fn new(text: &'a str) -> Self

Creates a new message box with a specified text to be displayed. If the string consists of more than one line, you can separate the lines using a carriage return and/or linefeed character between each line.

Source

pub fn icon(self, icon: Icon) -> Self

The Icon to be displayed in this message box.

Source

pub fn title(self, title: &'a str) -> Self

The dialog box title. If this parameter is null, the default title is Error.

Examples found in repository?
examples/simple.rs (line 5)
3fn main() -> Result<()> {
4    win_msgbox::information::<Okay>("Ferris landed on Mars.")
5        .title("Landing Module")
6        .show()?;
7    Ok(())
8}
More examples
Hide additional examples
examples/topmost.rs (line 8)
3fn main() -> Result<()> {
4    win_msgbox::information::<Okay>(
5        "This is some longer paragraph to demonstrate how\nthe text is right justified.",
6    )
7    .right()
8    .title("Cool Demo App")
9    .show()?;
10    Ok(())
11}
examples/options.rs (line 8)
6fn main() -> Result<()> {
7    let response = win_msgbox::error::<CancelTryAgainContinue>("Couldn't download resource")
8        .title("Download Error")
9        .show()?;
10
11    match response {
12        Cancel => println!("Cancelling downlaod..."),
13        TryAgain => println!("Attempting redownload..."),
14        Continue => println!("Skipping resource"),
15    }
16
17    Ok(())
18}
Source

pub fn hwnd(self, hwnd: HWND) -> Self

A handle to the owner window of the message box to be created. If this parameter is 0, the message box has no owner window (default).

Source

pub fn modal(self, modal: Modal) -> Self

Set the modality of the dialog box. See Modal for options.

Source

pub fn default_button(self, btn: DefaultButton) -> Self

Set the default button of the dialog box. See DefaultButton for options.

Source

pub fn 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, show does not return until the user switches to the default desktop.

Source

pub fn right(self) -> Self

The text is right-justified.

Examples found in repository?
examples/topmost.rs (line 7)
3fn main() -> Result<()> {
4    win_msgbox::information::<Okay>(
5        "This is some longer paragraph to demonstrate how\nthe text is right justified.",
6    )
7    .right()
8    .title("Cool Demo App")
9    .show()?;
10    Ok(())
11}
Source

pub fn rtl_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 topmost(self) -> Self

The message box is created with the WS_EX_TOPMOST window style.

Source

pub fn 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 is called, hwnd must not be called - it must remain 0. his is so that the message box can appear on a desktop other than the desktop corresponding to the hwnd.

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_help(self) -> Self

Adds a Help button to the message box. When the user clicks the Help button or presses F1, the system sends a WM_HELP message to the owner.

Source§

impl<T: Options> MessageBox<'_, T>

Source

pub fn show(self) -> Result<T>

Shows the message box, returning the option the user clicked on.

If a message box has a Cancel button, the function returns the Cancel value if either the ESC key is pressed or the Cancel button is selected.

If the message box has no Cancel button, pressing ESC will no effect - unless an Ok button is present.

If an Ok button is displayed and the user presses ESC, the return value will be Ok.

Examples found in repository?
examples/simple.rs (line 6)
3fn main() -> Result<()> {
4    win_msgbox::information::<Okay>("Ferris landed on Mars.")
5        .title("Landing Module")
6        .show()?;
7    Ok(())
8}
More examples
Hide additional examples
examples/topmost.rs (line 9)
3fn main() -> Result<()> {
4    win_msgbox::information::<Okay>(
5        "This is some longer paragraph to demonstrate how\nthe text is right justified.",
6    )
7    .right()
8    .title("Cool Demo App")
9    .show()?;
10    Ok(())
11}
examples/options.rs (line 9)
6fn main() -> Result<()> {
7    let response = win_msgbox::error::<CancelTryAgainContinue>("Couldn't download resource")
8        .title("Download Error")
9        .show()?;
10
11    match response {
12        Cancel => println!("Cancelling downlaod..."),
13        TryAgain => println!("Attempting redownload..."),
14        Continue => println!("Skipping resource"),
15    }
16
17    Ok(())
18}
Source§

impl<'a, T> MessageBox<'a, T>

Source

pub fn exclamation(text: &'a str) -> Self

Creates a new message box where its icon is set to Exclamation.

Source

pub fn warning(text: &'a str) -> Self

Creates a new message box where its icon is set to Warning.

Source

pub fn information(text: &'a str) -> Self

Creates a new message box where its icon is set to Information.

Source

pub fn asterisk(text: &'a str) -> Self

Creates a new message box where its icon is set to Asterisk.

Source

pub fn question(text: &'a str) -> Self

Creates a new message box where its icon is set to Question.

Source

pub fn stop(text: &'a str) -> Self

Creates a new message box where its icon is set to Stop.

Source

pub fn error(text: &'a str) -> Self

Creates a new message box where its icon is set to Error.

Source

pub fn hand(text: &'a str) -> Self

Creates a new message box where its icon is set to Hand.

Trait Implementations§

Source§

impl<T> Debug for MessageBox<'_, T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for MessageBox<'a, T>

§

impl<'a, T> RefUnwindSafe for MessageBox<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> !Send for MessageBox<'a, T>

§

impl<'a, T> !Sync for MessageBox<'a, T>

§

impl<'a, T> Unpin for MessageBox<'a, T>
where T: Unpin,

§

impl<'a, T> UnwindSafe for MessageBox<'a, T>
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.