hyperlinkmfctaskdialog

Hyperlinks in CTaskDialog footer


I have read this article:

Article

Sample

It clearly shows hyperlinks are supported in the footer. I can’t work out how to do it. I don’t want a literal URL in the text but other text that hyperlinks to a help article in the program.


Solution

  • This works:

    #include "stdafx.h"
    #include "CMyTaskDialog.h"
    
    IMPLEMENT_DYNAMIC(CMyTaskDialog, CTaskDialog)
    
    
    CMyTaskDialog::CMyTaskDialog(_In_ const CString& strContent, 
                                 _In_ const CString& strMainInstruction, 
                                 _In_ const CString& strTitle,
                                 _In_ int nCommonButtons,
                                 _In_ int nTaskDialogOptions, _In_ const CString& strFooter)
        : CTaskDialog(strContent, strMainInstruction, strTitle, nCommonButtons, nTaskDialogOptions, strFooter)
    {
    }
    
    
    CMyTaskDialog::~CMyTaskDialog()
    {
    }
    
    
    
    
    HRESULT CMyTaskDialog::OnHyperlinkClick(const CString& strHref)
    {
        HWND hwnd =
            HtmlHelp(
                GetDesktopWindow(),
                _T("d:\\MeetSchedAssist.chm::/") + strHref,
                HH_DISPLAY_TOPIC,
                NULL);
    
        return S_OK;
    }
    

    However, there are two issues still:

    1. CTaskDialog does not have a GetSafeHWnd API call so I don't know how to set it as the parent.

    2. The OnHyperlinkClick is generic so if you have multiple links on the task dialog you might have to test the phrase to decide how you want to handle it.