Question

Is it possible to show the TaskDialog with no buttons? I would like to be able to show just a progress bar (with a message), and then close the TaskDialog window when when my processing is complete (from the Timer event). Right now, I can show a disabled button and then call ButtonClick to close the window, but showing no buttons and having a CloseDialog method would be ideal.

Thanks.

Was it helpful?

Solution

Both TaskDialog() and TaskDialogIndirect() force a default button if you do not specify any buttons, but you do have control over what kind of buttons are used, so I would place an Abort button in the dialog to cancel whatever operation you are displaying status of. Or maybe a Hide button if the user does not want to see the progress anymore without stopping the operation that is in progress.

You have to use TaskDialogIndirect() in order to activate the progress bar feature. You can also use its callback feature to obtain the HWND of the dialog so you can close it programmably when needed.

Otherwise, don't use the TaskDialog API. Just create your own window with your own UI, then you can do whatever you want with it.

OTHER TIPS

Derive your own class from CTaskDialog

class CTaskDlg : public CTaskDialog
{
in CTaskDlg.h declare:
    public:
        void CloseTaskDlg(void);
protected:
    HWND m_TaskDlgHwnd;
    virtual HRESULT OnInit();
};

in CTaskDialog.cpp:

void CTaskDlg::CloseTaskDlg(void)
{
    ::SendMessage(m_TaskDlgHwnd, TDM_CLICK_BUTTON, static_cast<WPARAM>(TDCBF_OK_BUTTON), 0);
}

HRESULT CTaskDlg::OnInit()
{
    m_TaskDlgHwnd = ::GetActiveWindow();
    return S_OK;
}

CTaskDlg dlg;
dlg.CloseTaskDlg();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top