BOOL CCSHPropertySheet::OnInitDialog() { CPropertySheet::OnInitDialog(); if(0==HelpID(IDOK)){ // Dynamically add/remove the question mark button to the title bar of the dialog box: ModifyStyleEx(WS_EX_CONTEXTHELP,0,0); } else { ModifyStyleEx(0,WS_EX_CONTEXTHELP,0); } if(CSHFile().IsEmpty()){ // All of the following mess happens because Microsoft decided to show a help button by // default to every Property sheet constructed by Visual C++ 6.In the following lines, // I hide the help button and move the other three buttons to where they should be. CWnd *pwndHelpButton=GetDlgItem(IDHELP); if(pwndHelpButton){ static const int _afxPropSheetButtons[] = { IDOK, IDCANCEL, ID_APPLY_NOW, IDHELP }; for (int i = 0; i < sizeof _afxPropSheetButtons/sizeof _afxPropSheetButtons[0] - 1; i++){ // Shunt button CRect rect; GetDlgItem(_afxPropSheetButtons[i+1])->GetWindowRect(&rect); ScreenToClient(&rect); GetDlgItem(_afxPropSheetButtons[i])->MoveWindow(&rect); } pwndHelpButton->DestroyWindow(); } } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL CCSHDialog::OnInitDialog() { CDialog::OnInitDialog(); if(0==HelpID(IDOK)){ // Dynamically add/remove the question mark button to the title bar of the dialog box: ModifyStyleEx(WS_EX_CONTEXTHELP,0,0); } else { ModifyStyleEx(0,WS_EX_CONTEXTHELP,0); } CWnd *pHelpButton=GetDlgItem(IDHELP); if(NULL!=pHelpButton){ pHelpButton->EnableWindow(!CSHFile().IsEmpty()); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
CString CeCosDialog::CSHFile() const { return CSHFile((UINT)m_lpszTemplateName); }
void CCSHPropertySheet::OnHelp() { if(!CSHFile().IsEmpty()){ HtmlHelp(NULL,GetCSHFilePath()+CSHFile(),HH_DISPLAY_TOPIC,0); } }
void CCSHDialog::OnHelp() { if(!CSHFile().IsEmpty()){ HtmlHelp(NULL,GetCSHFilePath()+CSHFile(),HH_DISPLAY_TOPIC,0); } }