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

问题描述

在我的 STRINGTABLE 中,我有以下内容

enter image description here

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

enter image description here

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

enter image description here

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

enter image description here

对于 TaskDialogIndirect 我正在使用:

sConfig.hInstance = AfxGetInstanceHandle();

我也试过:

sConfig.hInstance = AfxGetResourceHandle();

为什么会这样?

解决方法

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

处理包含由 pszMainIconpszFooterIcon 成员标识的图标资源以及由 pszWindowTitle 标识的字符串资源的模块, pszMainInstructionpszContentpszVerificationTextpszExpandedInformationpszExpandedControlTextpszCollapsedControlText 或 pszFooter 成员。

提示是当它声明pszWindowTitle!当我将 AFX_IDS_APP_TITLE 加载到 CString 时,我没有在结构中分配它。我需要:

sConfig.pszWindowTitle = strTitle.GetString(); 

现在好了:

enter image description here