问题描述
在我使用 TaskDialogIndirect
的代码中,我可以将鼠标悬停在 AFX_IDS_APP_TITLE
上:
我明白这么多……如果找不到资源,它默认为可执行文件名称。目前这就是我得到的:
然而,当我使用 CTaskDialog
构造函数时,我得到了正确的标题:
对于 TaskDialogIndirect
我正在使用:
sConfig.hInstance = AfxGetInstanceHandle();
我也试过:
sConfig.hInstance = AfxGetResourceHandle();
为什么会这样?
解决方法
当您查看 TASKDIALOGCONFIG
中 HINSTANCE
的定义时,它说:
处理包含由 pszMainIcon 或 pszFooterIcon 成员标识的图标资源以及由 pszWindowTitle 标识的字符串资源的模块, pszMainInstruction、pszContent、pszVerificationText、pszExpandedInformation、pszExpandedControlText、pszCollapsedControlText 或 pszFooter 成员。
提示是当它声明pszWindowTitle!当我将 AFX_IDS_APP_TITLE
加载到 CString
时,我没有在结构中分配它。我需要:
sConfig.pszWindowTitle = strTitle.GetString();
现在好了: