在属性表中使用帮助:CPropertySheet 和 CPropertyPage CPropertySheet 类的对象表示属性表,也称为选项卡对话框。每个属性表由一个 CPropertySheet 对象和一个以上的 CPropertyPage 对象组成。属性表被框架显示为带有一组选项卡索引的窗口。用户使用这组索引选择当前页和当前选定页的某区域。 CPropertySheet 中的帮助只受 F1 键和“帮助”按钮的支持。默认情况下“帮助”按钮出现在应用程序的框架中。用户不需要进行干预。在用户为属性表中的各页添加帮助信息时,单击“帮助”按钮,帮助机制就会自动显示该页的帮助。 若要从属性表中移除“帮助”按钮,请修改属性表和其中的所有页,
如下所示: mySheet.m_psh.dwFlags &= ~PSH_HASHELP;
page1.m_psp.dwFlags &= ~PSP_HASHELP;
page2.m_psp.dwFlags &= ~PSP_HASHELP;
mySheet.AddPage( &page1 );
mySheet.AddPage( &page2 );
mySheet.DoModal();
m_psh 变量为 PROPSHEETHEADER 类型。
m_psp 变量为 PROPSHEETPAGE 类型。如果清除了所有的 HASHELP 标志(PSH_HASHELP 表示属性表对象)
上面是隐藏帮助按钮的操作代码;
如果不隐藏如何调用自己的帮助文档;
解决方法如下:
WM_HELP Message
Indicates that the user pressed the F1 key. If a menu is active when F1 is pressed, WM_HELP is sent to the window associated with the menu; otherwise, WM_HELP is sent to the window that has the keyboard focus. If no window has the keyboard focus, WM_HELP is sent to the currently active window.
Parameters
-
wParam
- Must be zero. lphi
-
The address of a HELPINFO structure that contains information about the menu item, control, dialog box, or window for which Help is requested.
Return Value
Returns TRUE.
//===假如你的项目是基于对话框的,那种**App类中,增加virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT);重载这个虚函数;
代码如下:
void CMyApp::WinHelp(DWORD dwData,UINT nCmd)
{
CString str_path = _T("");
GetModuleFileName(NULL,str_path.GetBufferLength(MAX_PATH+1),MAX_PATH);
str_path.ReleaseBuffer();
int i_pos = str_path.ReleaseFind('//');
str_path = str_path.Left(i_pos);
str_path = str_path + _T("//Help//Manual.chm");
ShellExecute(NULL,"open",str_path,NULL,NULL);
//CMyApp::WinHelp();
}
这样就可以调用自己的帮助文档了。