3

我有一个简单的 MFC 应用程序,我想在其中自定义应用程序提供的帮助按钮功能。单击 F1 或帮助按钮时,默认会打开一个 Windows 帮助支持页面。如何禁用此默认行为并让它什么都不显示?

什么都不显示,我的意思是不显示默认的 Windows 支持页面。理想情况下,当我按 F1 或单击帮助按钮时,它应该不打开任何窗口。

4

2 回答 2

2
//Free the string allocated by MFC at CWinApp startup. 
//m_pszHelpFilePath is the member variable of CWinApp that stores the 
//location to default help window.
//initialize it to an empty string just to be extra sure that default windows 
//support page location is never found.
//This needs to be set before CWinApp::InitInstance() is called.

free((void*)m_pszHelpFilePath);
m_pszHelpFilePath = _tcsdup(_T(""))

在 MainFrame.cpp 中,声明 MessageMap:

BEGIN_MESSAGE_MAP(MainFrame, CWinApp)
ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
END_MESSAGE_MAP()

然后,调用OnCommandHelp()这是一个消息处理程序,在禁用模式下将用于处理 F1。

LRESULT  MainFrame::OnCommandHelp(WPARAM wParam, LPARAM lParam)
{
    CWnd *pWnd = GetFocus();
    if (pWnd != NULL)
    {
        CWinApp* theApp = AfxGetApp();
        CString helpFilePath = theApp->m_pszHelpFilePath;
        // we have a control with the focus, quit help display
        ::WinHelp(m_hWnd, helpFilePath, HELP_QUIT, NULL);
        return TRUE;
    }
    return FALSE;        // let default handling process it
}

在这里,调用WinHelp()启动 Windows 帮助 (Winhelp.exe) 并传递指示应用程序请求的帮助性质的附加数据。HELP_QUIT作为其参数之一,关闭请求的默认窗口帮助支持页面。

另外,不要忘记OnCommandHelp()在 MainFrame.h 中声明:

afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
于 2017-10-11T21:07:08.073 回答
2

2006 年 3 月 15 日 — MS 宣布 WinHelp 将被弃用。在与 MVP 讨论期间,Microsoft 帮助团队今天宣布 WinHelp 将被弃用(逐步淘汰)。WinHelp 的架构方式是我们必须从头开始重写它以满足 Vista 代码标准。鉴于我们在 Vista 中还有另外两个帮助系统,这种方法没有意义。

如需更多信息,另请参阅满足您的需求:

以下文字引用自:

Windows Vista 和 Windows Server 2008 开发者故事:应用程序兼容性指南

帮助引擎支持

Microsoft 致力于在 Windows 平台中提供帮助和支持技术,并将继续为软件开发人员研究新的解决方案。以下信息阐明了 Windows Vista 和 Windows Server 代号“Longhorn”对四种 Microsoft 帮助技术的支持:Windows 帮助、HTML 帮助 1.x、帮助和支持中心以及协助平台客户端。

Windows 帮助—WinHlp32.exe

Windows 帮助 WinHlp32.exe 是一个帮助程序,它包含在从 Microsoft Windows 3.1 操作系统开始的 Microsoft Windows 版本中。Windows 帮助程序 (WinHlp32.exe) 需要显示具有“.HLP”文件扩展名的 32 位帮助内容文件。对于 Windows Vista 和 Windows Server 代号“Longhorn”,不推荐使用 Windows 帮助。要在 Windows Vista 和 Windows Server 代号“Longhorn”中查看带有 .HLP 文件扩展名的 32 位帮助文件,您需要从 Microsoft 下载中心下载并安装 WinHlp32.exe。Microsoft 强烈建议软件开发人员停止在 Vista 中使用 Windows 帮助应用程序。发布依赖 . 鼓励 HLP 文件将其帮助体验转换为其他帮助文件格式,例如 CHM、HTML 或 XML。您还需要将调用从 WinHelp() API 更改为新的内容源。一些第三方工具可用于帮助作者将内容从一种格式转换为另一种格式。

HTML 帮助 1.x (HH.exe)

Microsoft HTML Help 1.x (HH.exe) 是包含在从 Windows 98 开始的 Windows 版本中的帮助系统。需要 HTML 帮助来显示带有 .CHM 文件扩展名的已编译帮助文件。HTML 帮助将在 Windows Vista 和 Windows Server 代号“Longhorn”中提供。但是,只会对引擎进行关键更新。不会将任何新功能或功能改进添加到 Windows Vista 和 Windows Server 代号“Longhorn”或未来 Windows 版本的 HTML 帮助引擎。

于 2017-10-12T17:28:16.003 回答