#dialog #winapi #message #interface #message-box #c-style #idiomatic

bin+lib win_dialog

An idiomatic wrapper around windows MessageBox function for providing message dialogs in Windows

16 releases (2 stable)

1.0.1 Jun 2, 2024
1.0.0 Jun 1, 2024
0.5.6 Jun 1, 2024
0.4.0 Jun 1, 2024
0.1.3 May 30, 2024

#2 in #c-style

Download history 1/week @ 2024-09-17 42/week @ 2024-09-24 5/week @ 2024-10-01

692 downloads per month

MIT/Apache

41KB
669 lines

Win-Dialog

An idiomatic Rust interface for the Windows message box API.

Motivation

One can simply use the windows crate to invoke this api, but the api is a rather old-fashioned C-style API, so its rather unintuitive for a Rust developer without C programming experience to use. This create wraps the raw API with a familiar interface and provides more complete documentation about how to use it than the official crate documentation does.

Message Box Appearance

A Windows message box looks like this:

example message box

You have the ability to make the following changes:

  • Change the header (or display a default header)
  • Change the body text
  • Choose the available buttons from among a fixed set. You cannot edit button text
  • Change the icon (or display no icon)

Usage

use win_dialog::{style, Icon, WinDialog};

fn main() {
    let res =
        WinDialog::new("We encountered an error during installation. What would you like to do?")
            .with_style(style::AbortRetryIgnore)
            .with_icon(Icon::Hand)
            .show()
            .unwrap();
    println!("{res:?}");
}

Possible Future Features

  • Dialog timeouts
  • Async interface

Dependencies

~128MB
~2M SLoC