How to delete the default Help button in CPropertySheet in MFC?

4.5k views Asked by At

I am using CPropertySheet class for my design in MFC application, normally in CPropertySheet there would be 4 default buttons. I want to hide/delete the HELP button. I tried the following, but it's not working/neither responding. I had this written in my CPropertyPage class is there any other way...

m_psh.dwFlags &= ~PSH_HASHELP;
5

There are 5 answers

3
Priyank Bolia On BEST ANSWER
// Destroy the Help button
CButton *btnHelp;

btnHelp = reinterpret_cast<CButton *>(GetDlgItem(IDHELP));
btnHelp->DestroyWindow();
1
Paddy On

This should work out :

Override the OnNotify method of the class derived from PropertySheet ,write the following code into it

CWnd *hwnd = GetDlgItem(IDHELP); hwnd->ShowWindow(SW_HIDE);

0
nobser On

http://msdn.microsoft.com/de-de/library/37k4h0bh(v=vs.80).aspx

You have to remove the flag from the sheet and all pages...

mySheet.m_psh.dwFlags &= ~PSH_HASHELP;
page1.m_psp.dwFlags &= ~PSP_HASHELP;
page2.m_psp.dwFlags &= ~PSP_HASHELP;

...

Take care of the difference: m_psh vs. m_psp and PSH_HASHELP vs. PSP_HASHELP

1
Aditya Palanki On

Go to your project's main cpp file (where theApp is defined).
Remove this line: ON_COMMAND(ID_HELP, CWinApp::OnHelp)

Aditya Palanki

2
Olaf Mandel On

The property pages also have a HASHELP flag that needs to be cleared. The following code in the constructor of the property sheet should work:

// After the last AddPage() call:
m_psh.dwFlags &= ~PSH_HASHELP;
for(int i=0; i<GetPageCount(); ++i)
    GetPage(i)->m_psp.dwFlags &= ~PSP_HASHELP;

Alternatively, one can also modify the m_psp flag for each individual page before calling AddPage():

m_psh.dwFlags &= ~PSH_HASHELP;
page1.m_psp.dwFlags &= ~PSP_HASHELP;
AddPage(&page1);
// ...