win_msgbox_timeout 1.1.0

Windows message boxes and notification helpers for Rust
Documentation
  • Coverage
  • 64.29%
    9 out of 14 items documented0 out of 0 items with examples
  • Size
  • Source code size: 33.19 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.07 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 59s Average build duration of successful builds.
  • all releases: 54s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Mikachu2333

win_msgbox

A small Rust library for native Windows message boxes and notification popups.

Features

  • Native Win32 message boxes with icon and button presets
  • Optional auto-close timeout for message boxes
  • Standalone popup notification window (bottom-right corner)
  • Balloon tip helper for existing tray icons

Platform

  • Windows only
  • Uses raw Win32 FFI (User32, Shell32, Gdi32)

Installation

Add to your Cargo.toml:

[dependencies]
win_msgbox = "1.1.0"

Quick Start

use win_msgbox::{
    error_msgbox, info_msgbox, notify_msgbox_standalone, quest_msgbox_yesno, wait_notifications,
    warn_msgbox,
};

fn main() {
    info_msgbox("Hello from Rust", "Info", 0);
    warn_msgbox("Careful!", "Warning", 3000);

    let result = quest_msgbox_yesno("Do you want to continue?", "Question", 0);
    if result == 6 {
        info_msgbox("You clicked Yes", "Result", 0);
    } else if result == 7 {
        error_msgbox("You clicked No", "Result", 0);
    }

    notify_msgbox_standalone("Task", "Operation completed", 5000);

    // Wait for standalone notifications before process exit.
    wait_notifications();
}

API Overview

Message Boxes

  • info_msgbox(msg, title, timeout_ms) -> i32
  • error_msgbox(msg, title, timeout_ms) -> i32
  • warn_msgbox(msg, title, timeout_ms) -> i32
  • quest_msgbox_yesno(msg, title, timeout_ms) -> i32
  • quest_msgbox_okcancel(msg, title, timeout_ms) -> i32

Return values follow Win32 MessageBox conventions:

  • 1: OK
  • 2: Cancel
  • 6: Yes
  • 7: No
  • -1: closed by timeout

Standalone Notification Popup

  • notify_msgbox_standalone(title, msg, timeout_ms) -> bool
  • wait_notifications()

Tray Balloon Helper

  • notify_msgbox(hwnd, msg, icon_id) -> i32

Notes:

  • notify_msgbox requires an existing tray icon created with the same icon_id.
  • NotifyIconType enum is exported for future extension.

Publish to crates.io

  1. Create a crates.io account and API token.

  2. Log in from terminal:

    cargo login <YOUR_CRATES_IO_TOKEN>
    
  3. Validate package locally:

    cargo fmt --check
    cargo clippy -- -D warnings
    cargo package
    
  4. Publish:

    cargo publish
    
  5. Verify:

    cargo search win_msgbox
    

Notes Before Publishing

  • Ensure the version in Cargo.toml is new (cannot republish same version).
  • Make sure license, description, and readme are present.
  • Consider adding repository when you have a public Git repository URL.

License

MIT