sheet下面有确定、取消、应用、帮助几个按钮,
我用GetDlgItem()->ShowWindow()这样可以隐藏前面三个按钮,但是帮助按钮不能隐藏,原因是我不知道帮助按钮的ID(不是ID_HELP,这个我试过了)。有谁知道这个按钮的ID是什么?
我还有个担心,这总是治标不治本的方法,因为只是隐藏仍然要占据一定的地方,我在考虑如何直接在这个类创建的时候不创建这几个按钮,不知道能不能实现。
????????????

解决方案 »

  1.   

    GetDlgItem (IDHELP)->ShowWindow (FALSE);
      

  2.   

    http://www.vckbase.com/document/viewdoc/?id=427
      

  3.   

    CPropertySheet dlgPropertySheet("Simple PropertySheet");
    dlgPropertySheet.m_psh->dwFlags  |= PSH_NOAPPLYNOW;
    dlgPropertySheet.m_psh->dwFlags &= ~PSH_HASHELP;
      

  4.   

    如果使用GetDlgItem(IDHELP)取得CWnd *,再设置EnableWindow(FALSE), 开始可以, 但切换到其他TAB后, HELP button 又变成Enabled了
      

  5.   

    CWnd *applyWnd = GetDlgItem(IDHELP);
    applyWnd->ShowWindow(0);
      

  6.   

    got it,thank you,everybody!
    只是还有一个小问题,我设的字体稍大,然后头部就不整齐了。
    不知道这个问题怎么解决!
      

  7.   

    我曾经碰到到Wizard页面如果设计字体偏大,那么最后exe文件中界面不能和我设计时界面保持
    一致。采用自己编写的CMyPropertyPage和在CPropertySheet中添加处理函数解决了问题#include <..\SRC\AFXIMPL.H>
    void CMyPropertyPage::PreProcessPageTemplate(PROPSHEETPAGE& psp, BOOL bWizard)
    {
    const DLGTEMPLATE* pTemplate; if (psp.dwFlags & PSP_DLGINDIRECT)
    {
    pTemplate = psp.pResource;
    }
    else
    {
    HRSRC hResource = ::FindResource(psp.hInstance,
    psp.pszTemplate, RT_DIALOG);
    HGLOBAL hTemplate = LoadResource(psp.hInstance,
    hResource);
    pTemplate = (LPCDLGTEMPLATE)LockResource(hTemplate);
    } ASSERT(pTemplate != NULL);#ifdef _DEBUG
    // WINBUG: Windows currently does not support DIALOGEX resources!
    // Assert that the template is *not* a DIALOGEX template.
    // DIALOGEX templates are not supported by the PropertySheet API. // To change a DIALOGEX template back to a DIALOG template,
    // remove the following:
    //  1. Extended styles on the dialog
    //  2. Help IDs on any control in the dialog
    //  3. Control IDs that are DWORDs
    //  4. Weight, italic, or charset attributes on the dialog's font if (((DLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF)
    {
    // it's a DIALOGEX -- we'd better check
    DWORD dwVersion = ::GetVersion();
    if (dwVersion & 0x80000000)
    {
    // it's Win95 -- versions of COMCTL32.DLL that export
    // a function called DllGetVersion are okay HINSTANCE hInst = LoadLibrary(_T("COMCTL32.DLL"));
    ASSERT(hInst != NULL);
    if (hInst != NULL)
    {
    FARPROC proc = GetProcAddress(hInst, "DllGetVersion");
    if (proc == NULL)
    ASSERT(FALSE);
    FreeLibrary(hInst);
    }
    }
    else if (LOBYTE(LOWORD(dwVersion)) == 3)
    {
    // it's Windows NT 3.x; we have no hope of this working
    ASSERT(FALSE);
    }
    }
    #endif // _DEBUG#ifndef _AFX_NO_OCC_SUPPORT
    // if the dialog could contain OLE controls, deal with them now
    if (afxOccManager != NULL)
    pTemplate = InitDialogInfo(pTemplate);
    #endif // set font of property page to same font used by property sheet
    HGLOBAL hTemplate = NULL;//_AfxChangePropPageFont(pTemplate, bWizard); if (m_hDialogTemplate != NULL)
    {
    GlobalFree(m_hDialogTemplate);
    m_hDialogTemplate = NULL;
    } if (hTemplate != NULL)
    {
    pTemplate = (LPCDLGTEMPLATE)hTemplate;
    m_hDialogTemplate = hTemplate;
    }
    psp.pResource = pTemplate;
    psp.dwFlags |= PSP_DLGINDIRECT;
    }
    #include <afxpriv.h>enum { CDF_CENTER, CDF_TOPLEFT, CDF_NONE};
    /*设置pWnd的字体,并把所属的孩子也调整到相同字体*/
    void ChangeDialogFont(CWnd* pWnd, CFont* pFont, int nFlag)
    {
    CRect windowRect; TEXTMETRIC tmOld, tmNew;
    CDC * pDC = pWnd->GetDC();//获取pWnd指针的客户区的设备环境
    CFont * pSavedFont = pDC->SelectObject(pWnd->GetFont());
    pDC->GetTextMetrics(&tmOld);
    pDC->SelectObject(pFont);
    pDC->GetTextMetrics(&tmNew);
    pDC->SelectObject(pSavedFont);
    pWnd->ReleaseDC(pDC); int oldHeight = tmOld.tmHeight+tmOld.tmExternalLeading;
    int newHeight = tmNew.tmHeight+tmNew.tmExternalLeading; if (nFlag != CDF_NONE)
    {
    CRect clientRect, newClientRect, newWindowRect; pWnd->GetWindowRect(windowRect);
    pWnd->GetClientRect(clientRect);
    int xDiff = windowRect.Width() - clientRect.Width();
    int yDiff = windowRect.Height() - clientRect.Height();

    newClientRect.left = newClientRect.top = 0;
    newClientRect.right = clientRect.right *
    tmNew.tmAveCharWidth / tmOld.tmAveCharWidth;
    newClientRect.bottom = clientRect.bottom * newHeight / oldHeight; if (nFlag == CDF_TOPLEFT) 
    {
    newWindowRect.left = windowRect.left;
    newWindowRect.top = windowRect.top;
    newWindowRect.right = windowRect.left +
    newClientRect.right + xDiff;
    newWindowRect.bottom = windowRect.top +
    newClientRect.bottom + yDiff;
    }
    else if (nFlag == CDF_CENTER)
    {
    newWindowRect.left = windowRect.left - 
    (newClientRect.right - clientRect.right)/2;
    newWindowRect.top = windowRect.top -
    (newClientRect.bottom - clientRect.bottom)/2;
    newWindowRect.right = newWindowRect.left +
    newClientRect.right + xDiff;
    newWindowRect.bottom = newWindowRect.top +
    newClientRect.bottom + yDiff;
    }
    pWnd->MoveWindow(newWindowRect);
    } pWnd->SetFont(pFont); CWnd* pChildWnd = pWnd->GetWindow(GW_CHILD); while (pChildWnd)
    {
    pChildWnd->SetFont(pFont);
    pChildWnd->GetWindowRect(windowRect); CString strClass;
    ::GetClassName(pChildWnd->m_hWnd,
    strClass.GetBufferSetLength(32), 31);
    strClass.MakeUpper();
    if(strClass==_T("COMBOBOX"))
    {
    CRect rect;
    pChildWnd->SendMessage(CB_GETDROPPEDCONTROLRECT,0,(LPARAM) &rect);
    windowRect.right = rect.right;
    windowRect.bottom = rect.bottom;
    } pWnd->ScreenToClient(windowRect);
    windowRect.left = windowRect.left *
    tmNew.tmAveCharWidth / tmOld.tmAveCharWidth;
    windowRect.right = windowRect.right *
    tmNew.tmAveCharWidth / tmOld.tmAveCharWidth;
    windowRect.top = windowRect.top * newHeight / oldHeight;
    windowRect.bottom = windowRect.bottom * newHeight / oldHeight;
    pChildWnd->MoveWindow(windowRect);

    pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT);
    }
    }BOOL CWizardSheet::OnInitDialog() 
    {
    BOOL bResult = CPropertySheet::OnInitDialog();
    CPropertyPage *pPage = GetActivePage ();
    ASSERT(pPage);
    ChangeDialogFont(this, &m_ftFont, CDF_CENTER);
    for (int iCntr = 0; iCntr < GetPageCount (); iCntr++)
    {
    VERIFY (SetActivePage (iCntr));
    pPage = GetActivePage();
    ASSERT (pPage);
    ChangeDialogFont (pPage, &m_ftFont, CDF_CENTER);
    }
    VERIFY(SetActivePage(pPage));
    CTabCtrl* pTab = GetTabControl();
    ASSERT (pTab); if (m_psh.dwFlags & PSH_WIZARD)
    {
    pTab->ShowWindow (SW_HIDE);
    GetClientRect (&m_rcRect_page); CWnd* pButton = GetDlgItem (ID_WIZBACK);
    ASSERT (pButton);
    CRect rc;
    pButton->GetWindowRect (&rc);
    ScreenToClient (&rc);
    m_rcRect_page.bottom = rc.top-2;
    }
    else
    {
    pTab->GetWindowRect (&m_rcRect_page);
    ScreenToClient (&m_rcRect_page);
    pTab->AdjustRect (FALSE, &m_rcRect_page);
    } pPage->MoveWindow (&m_rcRect_page);
    SetActivePage(0);//设置第一页激活 return bResult;
    }
    void CWizardSheet::BuildPropPageArray()
    {
    CPropertySheet::BuildPropPageArray();
    //得到Sheet向导的第一页
    CPropertyPage* pPage = GetPage (0);
    ASSERT (pPage);

    //在afxpriv.h中定义的CDialogTemplate类
    CDialogTemplate dlgtemp;
    //装载第一页的对话框模版
    VERIFY (dlgtemp.Load (pPage->m_psp.pszTemplate));
    //获取对话框模版的字体信息
    CString strFace;
    WORD wSize;
    VERIFY (dlgtemp.GetFont (strFace, wSize));
    if (m_ftFont.m_hObject)
    VERIFY (m_ftFont.DeleteObject());
    //利用从第一页获得的字体信息创建成员变量字体对象
    VERIFY (m_ftFont.CreatePointFont (wSize*10, strFace));
    }//下面两个量是CPropertySheet成员变量
    CFont m_ftFont; /****界面统一字体***/
    RECT m_rcRect_page; /****界面统一大小***/