Function winsafe::ChooseColor

source ·
pub fn ChooseColor(cc: &mut CHOOSECOLOR<'_>) -> Result<bool, CDERR>
Available on crate feature user only.
Expand description

ChooseColor function.

§Examples

use winsafe::{self as w, prelude::*, co};

let parent_hwnd: w::HWND; // initialized somewhere

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

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

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