Function winsafe::TaskDialogIndirect

source ·
pub fn TaskDialogIndirect(
    task_config: &TASKDIALOGCONFIG<'_, '_, '_, '_, '_, '_, '_, '_, '_, '_>,
    verification_flag_checked: Option<&mut bool>
) -> HrResult<(DLGID, u16)>
Available on crate feature comctl only.
Expand description

TaskDialogIndirect function.

Returns:

  • the selected co::DLGID button;
  • if pRadioButtons of TASKDIALOGCONFIG struct was set, the u16 control ID of one of the specified radio buttons; otherwise zero.

If you don’t need all customizations, consider the HWND::TaskDialog method.

§Examples

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

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

let mut tdc = w::TASKDIALOGCONFIG::default();
tdc.hwndParent = hwnd;
tdc.dwCommonButtons = co::TDCBF::YES | co::TDCBF::NO;
tdc.set_pszMainIcon(w::IconIdTdicon::Tdicon(co::TD_ICON::INFORMATION));

let mut title = w::WString::from_str("Title");
tdc.set_pszWindowTitle(Some(&mut title));

let mut header = w::WString::from_str("Header");
tdc.set_pszMainInstruction(Some(&mut header));

let mut body = w::WString::from_str("Body");
tdc.set_pszContent(Some(&mut body));

// A custom button to appear before Yes and No.
let mut btn1 = w::TASKDIALOG_BUTTON::default();
let mut btn1_text = w::WString::from_str("Hello");
btn1.set_pszButtonText(Some(&mut btn1_text));
btn1.set_nButtonID(333); // this ID is returned if user clicks this button
let btns_slice = &mut [btn1];
tdc.set_pButtons(Some(btns_slice));

w::TaskDialogIndirect(&tdc, None)?;