CPropertySheet 和 CPropertyPage (幫助文檔的調用問題)

在屬性表中使用幫助: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();
}

這樣就可以調用自己的幫助文檔了。

發佈了84 篇原創文章 · 獲贊 14 · 訪問量 30萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章