如何在属性页上增加一个与“确定”和“取消”同一行的按钮。

解决方案 »

  1.   

    从CPropertySheet中派生一个类,如CMyPropertySheet
    在CMyPropertySheet的OnInitDialog中增加按钮:// 得到“确定”按钮的位置
    CWnd *pWndOK = GetDlgItem(IDOK);
    CRect rcOK;
    pWndOK->GetWindowRect(&rcOK);CRect rcButton(rcOK);
    rcButton.Offset(-rcButton.Width(), 0);
    m_cButton.Create(...,rcButton,...); // 在目标位置创建一个按钮
      

  2.   

    http://www.vckbase.com/code/listcode.asp?mclsid=3&sclsid=317
      

  3.   

    1、定义CButton类型的成员变量m_Button;class CYourPropertySheet : public CPropertySheet
    {
    //...
    private:
      CButton m_Button;
    //...
    }2、在指定位置创建按钮
    BOOL CYourPropertySheet::OnInitDialog() 
    {
    //...
    int ids [] = {IDOK, IDCANCEL};CRect rect0,rect1;
    GetDlgItem(ids[0])->GetWindowRect(rect0);
    GetDlgItem(ids[1])->GetWindowRect(rect1);ScreenToClient (rect0);
    ScreenToClient (rect1);CPoint cpOffset(rect1.left - rect0.left,0);
    rect0 -= cpOffset;

    m_Button.Create("&MyButton", 
    WS_CHILD | WS_VISIBLE | WS_TABSTOP,
    rect0,
    this, 0x8888); //...
    }
      

  4.   

    下面演示如何在左下角加入一Edit控件:
    MyPropSheet.h中:public:
        CEdit m_edit;MyPropSheet.cpp中:BOOL CMyPropSheet::OnInitDialog ()
    {
        BOOL bResult = CPropertySheet::OnInitDialog ();    
        CRect rect;
        
        int nHeight = 24;
        int nWidth = 120;
        int nOffset = 6;
        
        GetClientRect (&rect);    // Find a bottom-left point for the edit control in the client area
        int nX = rect.left + nOffset;
        int nY = rect.top + (rect.Height() - nHeight) - nOffset;
        
        // finally create the edit control
        m_Edit.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), NULL,
                         WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, 
            nX, nY, nWidth, nHeight, m_hWnd, 0, 0 );    return bResult;
    }