我在msdn中只查到如何去处HELP按钮,本想依样画葫芦去除应用按扭
  dlg.m_psh.dwFlags &= PSH_NOAPPLYNOW;
  可是程序运行时出错,请大侠指点

解决方案 »

  1.   

    http://www.vckbase.com/study/article/vc_chap/chap5_5.htm
    SetModified(TRUE); //使Apply按钮允许或者
    This is the code showing how I did mine for a test app.BOOL CLearnerAppSheet::OnInitDialog()
    {
    CPropertySheet::OnInitDialog();

    CButton* button; // Remove the "Apply" button... button = (CButton*) GetDlgItem(ID_APPLY_NOW);
    button->DestroyWindow(); // Remove the "OK" button... button = (CButton*) GetDlgItem(IDOK);
    button->DestroyWindow(); // Remove the "Cancel" button... button = (CButton*) GetDlgItem(IDCANCEL);
    button->DestroyWindow(); // Set the dialog icons... SetIcon(m_hIcon, TRUE); return TRUE;
    }I removed three of the four buttons this way... I think
    that HELP is nice where it is at if you are making an app
    that has the app on one page and the controls on the next 
    page.Using this method to DestroyWindow() HELP button causes
    errors.
      

  2.   

    简单的说:在相关的类中
    CWnd *p=GetDlgItem (IDOK);
    p->DestroyWindow ();//隐藏OK
      

  3.   

    没有楼上说得那么麻烦,楼主马虎了不是
    dlg.m_psh.dwFlags &= PSH_NOAPPLYNOW而是dlg.m_psh.dwFlags |= PSH_NOAPPLYNOW
      

  4.   

    楼上说得对。MSDN里也说是|=HOWTO: How to Hide the Apply Button in CPropertySheet --------------------------------------------------------------------------------
    The information in this article applies to:The Microsoft Foundation Classes (MFC), used with:
    Microsoft Visual C++ for Windows, 16-bit edition, version 1.52 
    Microsoft Visual C++, 32-bit Editions, versions 2.0, 2.1, 2.2, 4.0--------------------------------------------------------------------------------
    SUMMARY
    A modal CPropertySheet will automatically create an Apply button. To hide this button, you need to use different methods for different versions of MFC. In Visual C++ 2.2 and earlier (MFC 3.2 and earlier), you can derive a class from CPropertySheet, override OnCreate(), call GetDlgItem(ID_APPLY_NOW), and finally call ShowWindow(SW_HIDE) to hide the Apply button. In Visual C++ 4.0 (MFC 4.0), CPropertySheet has a public member called m_psh. m_psh is a PROPSHEETHEADER structure with a dwFlags member. One of the possible values of m_psh.dwFlags is PSH_NOAPPLYNOW. Setting this value before the call to DoModal() hides the Apply button. Another option in Visual C++ 4.0 is to call GetDlgItem()/ShowWindow(), but you should do it in OnInitDialog() instead of OnCreate(). MORE INFORMATION
    In Visual C++ 2.2 and earlier, CPropertySheet was implemented internally by MFC. Starting with Visual C++ 4.0, the CPropertySheet uses the Windows 95 PropertySheet control, so the method for hiding the Apply button changed. You can hide any of the default buttons in a modal property sheet by using the methods in this article. The IDs for each button are IDOK (OK button), IDCANCEL (Cancel button), ID_APPLY_NOW (Apply button), and IDHELP (Help button). Note that the Apply button is disabled by default until you call SetModified(). In addition, in Visual C++ 4.0, the Help button is not shown by default. To show it, you can set m_psh.dwFlags |= PSH_HASHELP. Sample Code/***** this code applies to Visual C++ 4.0 and later *****/ 
    void CMyView::OnDisplayModalSheet()
    {
       CMySheet sheet ("Set Properties");
       // this hides the Apply button
       sheet.m_psh.dwFlags |= PSH_NOAPPLYNOW;
       sheet.DoModal ();
    }/* You can also do the following to hide the Apply button */ BOOL CMySheet::OnInitDialog()
    {
       CPropertySheet::OnInitDialog();   // this hides the Apply button
       CWnd* pApplyButton = GetDlgItem (ID_APPLY_NOW);
       ASSERT (pApplyButton);
       pApplyButton->ShowWindow (SW_HIDE);   return TRUE;
    }
    /*********************************************************/ /***** this code applies to Visual C++ 2.2 and earlier *****/ 
    int CMySheet::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
       if (CPropertySheet::OnCreate(lpCreateStruct) == -1)
          return -1;   // this hides the Apply button
       CWnd* pApplyButton = GetDlgItem (ID_APPLY_NOW);
       ASSERT (pApplyButton);
       pApplyButton->ShowWindow (SW_HIDE);   return 0;
    }
    /*********************************************************/  Additional query words: kbinf 1.52 2.00 2.10 2.20 4.00 Keywords : kbcode kbMFC kbPropSheet KbUIDesign kbVC152 kbVC200 kbVC210 kbVC220 kbVC400 kbGrpMFCATL 
    Version : winnt:2.0,2.1,2.2,4.0 
    Platform : winnt 
    Issue type : kbhowto 
    Technology : kbvc 
    Last Reviewed: March 13, 2000
    © 2000 Microsoft Corporation. All rights reserved. Terms of Use.
     --------------------------------------------------------------------------------
    Send feedback to MSDN.Look here for MSDN Online resources.