#message-box #dialog #windows #dialog-box

win-msgbox

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

6 releases

0.2.1 Aug 5, 2024
0.2.0 Jun 22, 2024
0.1.3 Feb 25, 2024
0.1.2 Feb 7, 2023
0.1.1 Jan 5, 2023

#275 in GUI

Download history 4/week @ 2024-08-17 9/week @ 2024-09-07 13/week @ 2024-09-14 16/week @ 2024-09-21 32/week @ 2024-09-28 9/week @ 2024-10-05 17/week @ 2024-10-19 21/week @ 2024-10-26 36/week @ 2024-11-02 26/week @ 2024-11-09 23/week @ 2024-11-16 14/week @ 2024-11-23 18/week @ 2024-11-30

93 downloads per month

MIT/Apache

34KB
496 lines

win-msgbox

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.

message and title will be converted to UTF-16 when calling show on the fly, if this isn't desired, use the structs and functions exported in the raw module. However, note that these are unsafe, as they assume the passed pointers point to valid, null-terminated UTF-16 strings.

Examples

Show a minimal message box with an OK button:

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

Image of the resulting message box

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

use win_msgbox::{w, CancelTryAgainContinue::{self, *}};

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"),
}

Image of the resulting message box

For more examples, take a look at the examples directory.

Dependencies

~12–19MB
~235K SLoC