#platform #stub #window #api #dpi #scale #would

windows_dpi

Provides an API for marking a process as DPI-aware on windows systems. Works for Windows 7+, using the newer API when available. Also provides a method for getting the DPI appropriate for an HWND. Methods are currently stubs for other platforms, if anybody would like to contribute to support other platforms I'm happy to help!

5 unstable releases

Uses old Rust 2015

0.3.0 Mar 18, 2018
0.2.0 Mar 18, 2018
0.1.4 Aug 14, 2017

#686 in Operating systems


Used in dxgi

MIT license

10KB
142 lines

windows_dpi windows_dpi on crates.io Build Status

[dependencies]
windows_dpi = "0.1"
extern crate windows_dpi;

fn main() {
    // Make sure the OS knows you're paying attention to DPI so it won't scale your window
    windows_dpi::enable_dpi();

    // Get the basic scaling factor so you can know how big to make your windows
    let mut scaling_factor = windows_dpi::desktop_dpi();

    let window = create_window(scaling_factor);
    // Now that you have your window, check what its real scaling factor is
    scaling_factor = unsafe { windows_dpi::get_dpi_for(window.platform_handle()) };

    // Do some drawing stuff
    draw_graphics(&window, scaling_factor);
}

Dependencies

~6–415KB