Crates.io | win-msgbox |
lib.rs | win-msgbox |
version | 0.2.1 |
source | src |
created_at | 2023-01-05 12:25:40.16435 |
updated_at | 2024-08-05 14:51:41.717014 |
description | This crate provides a fully featured, ergonomic interface to Windows' MessageBox |
homepage | |
repository | https://github.com/Nerixyz/win-msgbox |
max_upload_size | |
id | 751504 |
size | 56,052 |
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.
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 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"),
}
For more examples, take a look at the examples
directory.