Function winsafe::ChooseColor[][src]

pub fn ChooseColor(cc: &mut CHOOSECOLOR<'_>) -> Result<bool, CDERR>
Expand description

ChooseColor function.

Examples

use winsafe::{co, ChooseColor, CHOOSECOLOR};

let parent_hwnd: HWND; // initialized somewhere

let mut cc = CHOOSECOLOR::default();
let mut custom_colors = [COLORREF::new(255, 255, 255); 16];

cc.hwndOwner = parent_hwnd;
cc.Flags = co::CC::ANYCOLOR | co::CC::FULLOPEN | co::CC::RGBINIT;
cc.rgbResult = COLORREF::new(255, 0, 0); // color initially chosen
cc.set_lpCustColors(&mut custom_colors);

if ChooseColor(&mut cc)? {
    println!("The color: {} {} {}",
        cc.rgbResult.GetRValue(),
        cc.rgbResult.GetGValue(),
        cc.rgbResult.GetBValue(),
    );
}