Crate win_msgbox

source ·
Expand description

This crate provides a fully featured, ergonomic interface to Windows’ MessageBox.

All possible options are usable and return values are Rust enums (or structs if only one option is available).

All configuration is done through MessageBox and available buttons are configured via Options.

This crate uses wide strings. To create a wide string use the w! macro from windows or windows_sys.

Examples

Show a minimal message box with an OK button:

win_msgbox::show::<Okay>(w!("Hello World"));

Show a message box with an error icon, and match on the return value:

use CancelTryAgainContinue::*;
let response = win_msgbox::error::<CancelTryAgainContinue>(w!("Couldn't download resource"))
    .title(w!("Download Error"))
    .show()?;

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

Structs

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 message box contains one push button: OK.

Enums

The message box contains three push buttons: Abort, Retry, and Ignore.
The message box contains three push buttons: Cancel, Try Again, Continue. Use this message box type instead of AbortRetryIgnore.
Specifies the default button of the dialog box.
The icon to be displayed in a message box.
Specifies the modality of the dialog box.
The message box contains two push buttons: OK and Cancel.
The message box contains two push buttons: Retry and Cancel.
The message box contains two push buttons: Yes and No.
The message box contains three push buttons: Yes, No, and Cancel.

Traits

This trait is implemented for all possible options.

Functions

Creates a new message box where its icon is set to Asterisk.
Creates a new message box where its icon is set to Error.
Creates a new message box where its icon is set to Exclamation.
Creates a new message box where its icon is set to Hand.
Creates a new message box where its icon is set to Information.
Creates a new message box where its icon is set to Question.
Shows a message box with a specified text to be displayed.
Creates a new message box where its icon is set to Stop.
Creates a new message box where its icon is set to Warning.