Search code examples
visual-c++mfctaskdialog

Title caption (AFX_IDS_APP_TITLE) is not correct when using TaskDialogIndirect with MFC


In my STRINGTABLE I have the following:

enter image description here

In my code where I use TaskDialogIndirect I can hover over AFX_IDS_APP_TITLE:

enter image description here

I understand this much ... if the resource can't be found it defaults to the executable name. At the moment that is what I am getting:

enter image description here

Yet, when I use the CTaskDialog constructor I get the correct caption:

enter image description here

For TaskDialogIndirect I am using:

sConfig.hInstance = AfxGetInstanceHandle();

I have also tried:

sConfig.hInstance = AfxGetResourceHandle();

Why is this happening?


Solution

  • When you look at the definition of HINSTANCE in the TASKDIALOGCONFIG it says:

    Handle to the module that contains the icon resource identified by the pszMainIcon or pszFooterIcon members, and the string resources identified by the pszWindowTitle, pszMainInstruction, pszContent, pszVerificationText, pszExpandedInformation, pszExpandedControlText, pszCollapsedControlText or pszFooter members.

    The hinst was when it stated pszWindowTitle! Whilst I was loading the AFX_IDS_APP_TITLE into a CString I was not assigning it in the structure. I needed:

    sConfig.pszWindowTitle = strTitle.GetString(); 
    

    And now it is fine:

    enter image description here