将 TaskDialogIndirect 与 MFC 一起使用时,标题标题 (AFX_IDS_APP_TITLE) 不正确

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

在我的 STRINGTABLE 中有以下内容:

在我使用 TaskDialogIndirect 的代码中,我可以将鼠标悬停在 AFX_IDS_APP_TITLE:

我明白了......如果找不到资源,它默认为可执行文件名称。目前这就是我得到的:

然而,当我使用 CTaskDialog 构造函数时,我得到了正确的标题:

对于TaskDialogIndirect我正在使用:

sConfig.hInstance = AfxGetInstanceHandle();

我也试过:

sConfig.hInstance = AfxGetResourceHandle();

为什么会这样?

当您查看 TASKDIALOGCONFIGHINSTANCE 的定义时,它说:

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.

hinst 是在它说 pszWindowTitle 的时候!当我将 AFX_IDS_APP_TITLE 加载到 CString 时,我没有在结构中分配它。我需要:

sConfig.pszWindowTitle = strTitle.GetString(); 

现在好了: