Function TaskDialogIndirect

Source
pub fn TaskDialogIndirect(
    config: &TASKDIALOGCONFIG<'_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_>,
) -> HrResult<(DLGID, u16, bool)>
Available on crate feature comctl only.
Expand description

TaskDialogIndirect function.

Fill the TASKDIALOGCONFIG fields you need, and leave the others as default. The needed flags will be automatically set.

Returns:

  1. the ID of the button clicked by the user. If you passed custom buttons in the buttons field, the corresponding ID will be wrapped in a co::DLGID constant, whose u16 can be retrieved by calling co::DLGID::raw method;
  2. the ID of the radio button selected by the user, if you used the radio_buttons field;
  3. true if the custom check box is checked, if you used the verification_text field.

HWND::TaskDialog is a simpler version of this function.

ยงExamples

Simple information dialog:

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

w::TaskDialogIndirect(&w::TASKDIALOGCONFIG {
    common_buttons: co::TDCBF::OK,
    main_icon:      w::IconIdTd::Td(co::TD_ICON::INFORMATION),
    flags:          co::TDF::ALLOW_DIALOG_CANCELLATION,
    window_title:   Some("Title"),
    content:        Some("Content"),
    ..Default::default()
})?;

OK/Cancel confirmation:

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

let (ret, _, _) = w::TaskDialogIndirect(&w::TASKDIALOGCONFIG {
    common_buttons: co::TDCBF::OK | co::TDCBF::CANCEL,
    main_icon:      w::IconIdTd::Td(co::TD_ICON::WARNING),
    flags:          co::TDF::ALLOW_DIALOG_CANCELLATION,
    window_title:   Some("Title"),
    content:        Some("Do you want?"),
    ..Default::default()
})?;

if ret == co::DLGID::OK {
   println!("Yes.");
}

Callback handling:

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

w::TaskDialogIndirect(&w::TASKDIALOGCONFIG {
    common_buttons: co::TDCBF::OK,
    window_title:   Some("Title"),
    content:        Some("Content"),
    callback:       Some(Box::new(
        |hwnd: &w::HWND, tdn: w::Tdn| -> co::HRESULT {
            match tdn {
                w::Tdn::Created => println!("created"),
                _ => {},
            }
            co::HRESULT::S_OK
        },
    )),
    ..Default::default()
})?;