WinSafe
Win32 GUI and related APIs in safe, idiomatic Rust.
WinSafe has:
- high-level structs to build native Win32 GUI applications;
- low-level Win32 API constants, functions and structs related to GUI.
If you're looking for a comprehensive Win32 coverage, take a look at winapi or windows crates, which are unsafe, but have everything.
WinSafe documentation:
- stable release: docs.rs/winsafe
- master branch: rodrigocfd.github.io/winsafe/winsafe
Current status
This crate is still in alpha stage. Below is an estimated progress of feature groups:
Feature group | Estimated progress |
---|---|
User windows (main, modal and control) | |
Native controls | |
Window messages | |
Overall Win32 APIs |
Usage
Add the dependency in your Cargo.toml
:
[]
= "0.0.7"
The COM modules are disabled by default, and can be enabled when needed:
Module | Cargo.toml [dependencies] |
---|---|
Automation | winsafe = { version = "0.0.7", features = ["autom"] } |
DirectShow | winsafe = { version = "0.0.7", features = ["dshow"] } |
IDL | winsafe = { version = "0.0.7", features = ["idl"] } |
Shell | winsafe = { version = "0.0.7", features = ["shell"] } |
Example
Note: You can find several examples in the dedicated repo: github.com/rodrigocfd/winsafe-examples
WinSafe allows you to create windows in two ways:
- programmatically defining parameters; or
- loading dialogs from a
.res
file created with a WYSIWYG resource editor.
The example below creates a window with a button programmatically. Note how the click event is handled with a closure:
use *;
use ;
License
Licensed under MIT license, see LICENSE.md for details.