我一直在通过我的应用程序添加OnHelpInfo
消息处理程序。这不是因为我的应用程序将支持上下文帮助。相反,我想拦截 F1 键,然后简单地调用现有的“帮助”代码,当按下对话框按钮或菜单项时触发该代码。例子:
#pragma warning (suppress : 26434)
BOOL CBrotherExcludeDlg::OnHelpInfo(HELPINFO* pHelpInfo)
{
OnButtonHelp();
// return CResizingDialog::OnHelpInfo(pHelpInfo);
return TRUE;
}
我的问题是属性页。他们使用不同的机制来处理帮助主题的显示。例子:
void CCalendarSettingsGooglePage::OnPsnHelp(NMHDR* hdr, LRESULT* res)
{
theApp.DisplayHelpTopic(_T("msa-options-calendars.html"));
}
它使用PSN_HELP
处理程序。当我添加OnHelpInfo
到属性页面时,我现在不确定如何简单地运行该OnPsnHelp
事件。我试图避免有两个我打电话的地方DisplayHelpTopic
。
我们如何直接调用OnPsnHelp
(就像我调用帮助按钮单击处理函数)或通过消息调用它?
这是样板代码:
BOOL CPropertyPage::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
ASSERT(pResult != NULL);
NMHDR* pNMHDR = (NMHDR*)lParam;
// allow message map to override
if (CDialog::OnNotify(wParam, lParam, pResult))
return TRUE;
// don't handle messages not from the page/sheet itself
if (pNMHDR->hwndFrom != m_hWnd && pNMHDR->hwndFrom != ::GetParent(m_hWnd))
return FALSE;
// handle default
switch (pNMHDR->code)
{
case PSN_SETACTIVE:
{
CPropertySheet* pSheet = GetParentSheet();
if (pSheet != NULL && !(pSheet->m_nFlags & WF_CONTINUEMODAL) && !(pSheet->m_bModeless) && !(pSheet->m_psh.dwFlags & PSH_AEROWIZARD))
*pResult = -1;
else
*pResult = OnSetActive() ? 0 : -1;
}
break;
case PSN_KILLACTIVE:
*pResult = !OnKillActive();
break;
case PSN_APPLY:
*pResult = OnApply() ? PSNRET_NOERROR : PSNRET_INVALID_NOCHANGEPAGE;
break;
case PSN_RESET:
OnReset();
break;
case PSN_QUERYCANCEL:
*pResult = !OnQueryCancel();
break;
case PSN_WIZNEXT:
*pResult = MapWizardResult(OnWizardNext());
break;
case PSN_WIZBACK:
*pResult = MapWizardResult(OnWizardBack());
break;
case PSN_WIZFINISH:
*pResult = reinterpret_cast<LRESULT>(OnWizardFinishEx());
break;
case PSN_HELP:
SendMessage(WM_COMMAND, ID_HELP);
break;
default:
return FALSE; // not handled
}
return TRUE; // handled
}
所以我不明白。如果我使用SendMessage(WM_COMMAND, ID_HELP);
软件中的响应是一个弹窗Failed to launch help
。