We help IT Professionals succeed at work.

Help button on PropertySheet.

lonicekm
lonicekm asked
on
I have some PropertySheet in my DLL. How can I remove help button from it? "m_psh.dwFlags &= ~(PSH_HASHELP);" doesn't work there (in DLL)! Is there only one possibility - remove it and change other buttons' position and dialog size manually?
Comment
Watch Question

Commented:
Try this:

CWnd* pHelpButton = GetDescendantWindow(IDHELP);
if ( pHelpButton  )
   pHelpButton->ShowWindow(SW_HIDE);

Leave rest of the buttons where they are because it is there standard position
Commented:
BTW "Help" button is not shown by default so you must be adding it somewhere.

Commented:
Hi lonicekm,
Have you tried:

GetDlgItem(ID_HELP)->ShowWindow(SW_HIDE);

from inside of your CYourPropertySheet class, e.g. during OnInitDialog ?
m.

Commented:
I found it. MFC adds that button for you if you have "ID_HELP" handler enabled. You will have to disable that handler and handle that message in OnCmd() manually or something like that. See MFC source

void CPropertyPage::CommonConstruct(LPCTSTR lpszTemplateName, UINT nIDCaption)
{
        .....
     if (AfxHelpEnabled())
          m_psp.dwFlags |= PSP_HASHELP;
        .....
}

BOOL AFXAPI AfxHelpEnabled()
{
     if (AfxGetApp() == NULL)
          return FALSE;

     // help is enabled if the app has a handler for ID_HELP
     AFX_CMDHANDLERINFO info;

     // check main window first
     CWnd* pWnd = AfxGetMainWnd();
     if (pWnd != NULL && pWnd->OnCmdMsg(ID_HELP, CN_COMMAND, NULL, &info))
          return TRUE;

     // check app last
     return AfxGetApp()->OnCmdMsg(ID_HELP, CN_COMMAND, NULL, &info);
}

Commented:
And do not forget to remove PSH_HASHELP on property sheet

Author

Commented:
Yes, that's right. When I use property sheet from DLL it shows only OK and Cancel button, but when I use property sheet from application (declared in app) it shows Apply and Help buttons too! I didn't expect this difference in behaviour of sheet. And when I wanted to use code for hiding of these buttons in DLL like in app it shows me help button! So no own code is necessary in DLL.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.