All Projects → rodrigocfd → winsafe

rodrigocfd / winsafe

Licence: MIT License
Windows API and GUI in safe, idiomatic Rust.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to winsafe

windigo
Windows API and GUI in idiomatic Go.
Stars: ✭ 187 (+70%)
Mutual labels:  native, ffi, win32
Win32
Build Win32 apps with Dart!
Stars: ✭ 256 (+132.73%)
Mutual labels:  ffi, win32
PointerScript
Scripting language with pointers and native library access.
Stars: ✭ 26 (-76.36%)
Mutual labels:  native, ffi
renderdoc-rs
RenderDoc application bindings for Rust
Stars: ✭ 28 (-74.55%)
Mutual labels:  directx, ffi
Android Luajit Launcher
Android NativeActivity based launcher for LuaJIT, implementing the main loop within Lua land via FFI
Stars: ✭ 87 (-20.91%)
Mutual labels:  native, ffi
Dart native
Write iOS&Android Code using Dart. This package liberates you from redundant glue code and low performance of Flutter Channel.
Stars: ✭ 564 (+412.73%)
Mutual labels:  native, ffi
Node Win32 Api
win32 api
Stars: ✭ 214 (+94.55%)
Mutual labels:  ffi, win32
Xtd forms
Modern c++17 library to create native gui for Microsoft Windows, Apple macOS and Linux.
Stars: ✭ 25 (-77.27%)
Mutual labels:  native, win32
Arcgis Appstudio Samples
Collection of samples available in AppStudio for ArcGIS desktop to learn and help build your next app.
Stars: ✭ 78 (-29.09%)
Mutual labels:  native, win32
sqlite3
The fastest and correct module for SQLite3 in Deno.
Stars: ✭ 143 (+30%)
Mutual labels:  native, ffi
rust-flutter-reactive
This is a sample app to improve consistency over Mobile App Development.
Stars: ✭ 25 (-77.27%)
Mutual labels:  native, ffi
basgo
basgo compiles BASIC-lang to Golang. Then 'go build' can translate code to native executable binary.
Stars: ✭ 31 (-71.82%)
Mutual labels:  native
AppRopio.Mobile
AppRopio - mobile apps builder for iOS/Android based on Xamarin
Stars: ✭ 16 (-85.45%)
Mutual labels:  native
appbuilders18app
The App Builders 2018 iOS and Android app built as an experiment in React Native.
Stars: ✭ 29 (-73.64%)
Mutual labels:  native
SplinesGPU
various spline algorithms computed on the GPU
Stars: ✭ 15 (-86.36%)
Mutual labels:  directx
php-rdkafka-ffi
PHP Kafka client - binding librdkafka via FFI
Stars: ✭ 49 (-55.45%)
Mutual labels:  ffi
RainbowTaskbar
Customizable Windows taskbar effects.
Stars: ✭ 39 (-64.55%)
Mutual labels:  win32
react-tinder-card
A npm react module for making react elements swipeable like in the dating app tinder.
Stars: ✭ 184 (+67.27%)
Mutual labels:  native
xDL
🔥 xDL is an enhanced implementation of the Android DL series functions.
Stars: ✭ 117 (+6.36%)
Mutual labels:  native
libdmusic
Free DirectMusic file formats loading utilities
Stars: ✭ 20 (-81.82%)
Mutual labels:  directx

WinSafe

Crates.io Docs.rs Lines of code License: MIT

Windows API and GUI 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:

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) Progress
Native controls Progress
Window messages Progress
Overall Win32 APIs Progress

Usage

Add the dependency in your Cargo.toml:

[dependencies]
winsafe = { version = "0.0.9", features = [] }

Then you must enable the Cargo features you want to be included – these modules are named after native Windows DLL and library names, mostly.

The following Cargo features are available so far:

Feature Description
advapi Advapi32.dll, for Windows Registry
comctl ComCtl32.dll, for Common Controls
comdlg ComDlg32.dll, for the old Common Dialogs
dshow DirectShow
gdi Gdi32.dll, the Windows GDI
gui The WinSafe high-level GUI structs
kernel Kernel32.dll, all others will include it
msimg Msimg32.dll
ole OLE and basic COM support
oleaut OLE Automation
shell Shell32.dll, the COM-based Windows Shell
shlwapi Shlwapi.dll, for some Shell functions
user User32.dll, the basic Windows GUI support
uxtheme UxTheme.dll, extended window theming
version Version.dll, to manipulate *.exe version info

Note that a Cargo feature may depend on other features, which will be enabled automatically.

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:

Example 01

[dependencies]
winsafe = { version = "0.0.9", features = ["gui"] }
#![windows_subsystem = "windows"]

use winsafe::prelude::*;
use winsafe::{gui, POINT, SIZE};

fn main() {
    let my = MyWindow::new(); // instantiate our main window
    if let Err(e) = my.wnd.run_main(None) { // ... and run it
        eprintln!("{}", e);
    }
}


#[derive(Clone)]
pub struct MyWindow {
    wnd:       gui::WindowMain, // responsible for managing the window
    btn_hello: gui::Button,     // a button
}

impl MyWindow {
    pub fn new() -> Self {
        let wnd = gui::WindowMain::new( // instantiate the window manager
            gui::WindowMainOpts {
                title: "My window title".to_owned(),
                size: SIZE::new(300, 150),
                ..Default::default() // leave all other options as default
            },
        );

        let btn_hello = gui::Button::new(
            &wnd, // the window manager is the parent of our button
            gui::ButtonOpts {
                text: "&Click me".to_owned(),
                position: POINT::new(20, 20),
                ..Default::default()
            },
        );

        let new_self = Self { wnd, btn_hello };
        new_self.events(); // attach our events
        new_self
    }

    fn events(&self) {
        self.btn_hello.on().bn_clicked({
            let wnd = self.wnd.clone(); // clone so it can be passed into the closure
            move || {
                wnd.hwnd().SetWindowText("Hello, world!")?;
                Ok(())
            }
        });
    }
}

License

Licensed under MIT license, see LICENSE.md for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].