6

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 its not working/nither responding..I had this written in my CPropertyPage class is there any other way...

m_psh.dwFlags &= ~PSH_HASHELP;

kiddo
  • 1,596
  • 7
  • 31
  • 60

5 Answers5

13

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);
// ...
Olaf Mandel
  • 787
  • 7
  • 20
  • 1
    Notice the difference between `PS`**H`**`_HASHELP` and `PS`**P**`_HASHELP`. I was trying this with a `CMFCPropertySheet`, this code only turned the Help button disabled because I mistyped. But it is now hiding the button as it is supposed. – sergiol Aug 17 '15 at 11:13
  • Just for the sake of completeness: If you want to remove the Apply button, just add `m_psh.dwFlags |= PSH_NOAPPLYNOW;` . The pages do not have this flag, so there is nothing to do on them. – sergiol Aug 17 '15 at 11:32
4

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

sergiol
  • 4,122
  • 4
  • 47
  • 81
nobser
  • 41
  • 1
3
// Destroy the Help button
CButton *btnHelp;

btnHelp = reinterpret_cast<CButton *>(GetDlgItem(IDHELP));
btnHelp->DestroyWindow();
Priyank Bolia
  • 14,077
  • 14
  • 61
  • 82
  • tanx 4 ur reply...its not a normal button that u can delete using the above coding...I am using CPropertySheet -its an object which holds your Property Page...it will not work..some other way – kiddo Dec 02 '09 at 11:59
  • I know you are using the CPropertySheet, and a button is a button. You Can try ((CWnd*)GetDlgItem(IDHELP))->ShowWindow(SW_HIDE); or can looks at the various samples on internet: http://www.functionx.com/visualc/articles/propsheetbtn.htm – Priyank Bolia Dec 02 '09 at 13:13
  • Hi Priyank, your solution is giving 'Debug Assertion Failed' in debug and 'Access Violation' error in release mode. I saw everywhere it is working for others but me .. why? What could be the difference? – Rick2047 Jan 07 '11 at 05:25
2

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

Aditya Palanki

Christian Specht
  • 35,843
  • 15
  • 128
  • 182
  • This does not hide nor deletes the Help button. Only disconnects the button from its handler function. And worse ... it removes the handler in other places were you need it. – sergiol Aug 17 '15 at 10:56
0

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);

Paddy
  • 11
  • 2