Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to get rid of Help button in MFC Wizard?

Posted on 1999-08-03
10
Medium Priority
?
800 Views
Last Modified: 2013-11-20
Hi

I have created a dialog-box based application.... And I have also employed CPropertyPage & CPropertySheet to create wizard....

However, when I use it, there is always a Help button which is not intended.... And I have never set any  mySheet.m_psh.dwFlags |= PSH_HASHELP or anything!

So how to get ride of that Help button?
0
Comment
Question by:ymw1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 4

Expert Comment

by:nil_dib
ID: 1312459
did you try:
mySheet.m_psh.dwFlags |= ~(PSH_HASHELP)
?
0
 
LVL 2

Expert Comment

by:vbk_bgm
ID: 1312460
TRY:
mySheet.m_psh.dwFlags &=  ~(PSH_HASHELP)

0
 
LVL 7

Expert Comment

by:psdavis
ID: 1312461
Remove the OnHelp function in your application code.
0
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 

Author Comment

by:ymw1
ID: 1312462
In fact, I have already place that statement on my every property pages & sheet.... :(

Furthermore, according to the MSDN, the statement merely disable the Help button.... It will NOT get rid of it....

Strangely, even when I have placed that statement, the Help button is not disabled!
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1312463
Seriously, remove the OnHelp function in your override of the CWinApp.
0
 
LVL 30

Accepted Solution

by:
SteveGTR earned 150 total points
ID: 1312464
I tried clearing the PSH_HASHELP flag with no success. Very strange, there has to be a better way then the code I propose below...

Derive a class from CPropertySheet and override the OnInitDialog() virtual function like so:

static int rgiButtons[] =
  { IDOK, IDCANCEL, ID_APPLY_NOW /* IDHELP */ };

BOOL CMyPropSheet::OnInitDialog()
{
  HWND hWndHelp = (HWND) ::GetDlgItem(m_hWnd, IDHELP);

  if (hWndHelp)
    {
    HWND hWnd;
    CRect rectHelp, rectNext(0, 0, 0, 0), rect;

    ::GetWindowRect(hWndHelp, rectHelp);
    ScreenToClient(rectHelp);

    // Find button that is closed to help on the right side
    for (int i=0; i < (sizeof(rgiButtons) / sizeof(int)); i++)
      {
      hWnd = ::GetDlgItem(m_hWnd, rgiButtons[i]);

      if (hWnd != hWndHelp)
        {
        ::GetWindowRect(hWnd, rect);
        ScreenToClient(rect);

        if (rect.left < rectHelp.left &&
            (rectNext.IsRectNull() || rectNext.right < rect.right))
          rectNext = rect;
        }
      }

    if (!rectNext.IsRectNull())
      {
      int nDiff = rectHelp.right - rectNext.right;

      for (int i=0; i < (sizeof(rgiButtons) / sizeof(int)); i++)
        {
        hWnd = ::GetDlgItem(m_hWnd, rgiButtons[i]);

        if (hWnd != hWndHelp)
          {
          ::GetWindowRect(hWnd, rect);
          ScreenToClient(rect);

          if (rect.left < rectHelp.left)
            ::SetWindowPos(hWnd, NULL,
              rect.left + nDiff, rect.top, 0, 0,
              SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
          }
        }
      }

    ::DestroyWindow(hWndHelp);
    }

  return CPropertySheet::OnInitDialog();
}

Good Luck,
Steve
0
 

Author Comment

by:ymw1
ID: 1312465
Thanks Steve!
Ur code has inspired me another better version.... Much simpler, just hide the help button as shown... :)

BOOL CWizPropertySheet::OnInitDialog()
{      
      BOOL bResult = CPropertySheet::OnInitDialog();
 
      CWnd* pWnd = GetDlgItem( IDHELP );
      pWnd->ShowWindow( SW_HIDE );

      return bResult;
}

0
 
LVL 7

Expert Comment

by:psdavis
ID: 1312466
Did you ever try my suggestion?  I know it doesn't sound right, but it is the correct answer.  Your solution puts all your buttons moved over strangely.
0
 
LVL 1

Expert Comment

by:bradak
ID: 4909530
The correct way to do this is to &= ~PSH_HAHELP the property sheet and each
property page before you add them to the property sheet.  You only did the property sheet, not the pages.

mySheet.m_psh.dwFlags &= ~PSH_HASHELP;

CPropertyPage page1;
page1.m_psh.dwFlags &= ~PSH_HASHELP;
mySheet.AddPage(page1);

....thought you might want to know.
0
 
LVL 30

Expert Comment

by:Axter
ID: 13704057
Just to make this PAQ complete, the above comment is very close to the correct answer.

However the page object should be calling the m_psp member instead of m_psh, and it should be using PSP_HASHELP instead of PSH_HASHELP.
Example code:
      Prop1 My__Prop1;
      Prop2 My__Prop2;
      Prop3 My__Prop3;
      CPropertySheet sheet("this is a test", this);
      sheet.m_psh.dwFlags &= ~PSH_HASHELP;
      My__Prop1.m_psp.dwFlags &= ~PSP_HASHELP; //**** this is not the same as PSH_HASHELP!!!!!
      My__Prop2.m_psp.dwFlags &= ~PSP_HASHELP;
      My__Prop3.m_psp.dwFlags &= ~PSP_HASHELP;

      sheet.AddPage(&My__Prop1);
      sheet.AddPage(&My__Prop2);
      sheet.AddPage(&My__Prop3);
      if (sheet.DoModal() == IDOK)
      {
            MessageBox("Good");
      }
      else
            MessageBox("Not Good");
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question