Struct win_msgbox::MessageBox

source ·
pub struct MessageBox<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§

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.

The Icon to be displayed in this message box.

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

Examples found in repository?
examples/simple.rs (line 6)
4
5
6
7
8
9
fn main() -> Result<(), WIN32_ERROR> {
    win_msgbox::information::<Okay>(w!("Ferris landed on Mars."))
        .title(w!("Landing Module"))
        .show()?;
    Ok(())
}
More examples
Hide additional examples
examples/options.rs (line 6)
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fn main() -> Result<(), WIN32_ERROR> {
    let response = win_msgbox::error::<CancelTryAgainContinue>(w!("Couldn't download resource"))
        .title(w!("Download Error"))
        .show()?;

    use CancelTryAgainContinue::*;
    match response {
        Cancel => println!("Cancelling downlaod..."),
        TryAgain => println!("Attempting redownload..."),
        Continue => println!("Skipping resource"),
    }

    Ok(())
}

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).

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

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

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.

The text is right-justified.

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

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

The message box is created with the WS_EX_TOPMOST window style.

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.

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.

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 7)
4
5
6
7
8
9
fn main() -> Result<(), WIN32_ERROR> {
    win_msgbox::information::<Okay>(w!("Ferris landed on Mars."))
        .title(w!("Landing Module"))
        .show()?;
    Ok(())
}
More examples
Hide additional examples
examples/options.rs (line 7)
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fn main() -> Result<(), WIN32_ERROR> {
    let response = win_msgbox::error::<CancelTryAgainContinue>(w!("Couldn't download resource"))
        .title(w!("Download Error"))
        .show()?;

    use CancelTryAgainContinue::*;
    match response {
        Cancel => println!("Cancelling downlaod..."),
        TryAgain => println!("Attempting redownload..."),
        Continue => println!("Skipping resource"),
    }

    Ok(())
}

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

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

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

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

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

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

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

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

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.