我作了一个非模态propertysheet,在上面增加了5个页面,现在想在sheet上加一个按钮,不知怎么加

解决方案 »

  1.   

    1、CMyPropertySheet类中添加CButton m_Button;成员
    2、声明新增按钮的ID 
       #define IDC_MYBUTTON 77
    3、修改CMyPropertySheet类的OnInitDialog()函数,新增部分如下:
    BOOL CMyPropertySheet::OnInitDialog()
    {
    //...
    RECT rc; GetWindowRect (&rc);
    // Resize the CPropertySheet
    rc.bottom += 30;
    rc.left-= 90; MoveWindow (rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top);
    // Convert to client coordinates
    ScreenToClient (&rc);
    // m_Button is of type CButton and is a member of CMyPropertySheet
             m_Button.Create ("&MyButton", WS_CHILD | WS_VISIBLE | WS_TABSTOP,
                                  CRect (14, rc.bottom-30, 14+75, rc.bottom-30 + 21),
                                  this, IDC_MYBUTTON);
    //...
    }4、添加消息映射
       BEGIN_MESSAGE_MAP(CMyPropertySheet, CPropertySheet)
    //{{AFX_MSG_MAP(CMyPropertySheet)
    // NOTE - the ClassWizard will add and remove mapping macros here.
             //...
             ON_COMMAND(IDC_MYBUTTON, OnMyButton)
             //...
             //}}AFX_MSG_MAP
      END_MESSAGE_MAP()5、添加OnMyButton按钮消息相应函数的声明及实现5.1、
    public:
    void OnMyButton();
    5.2、
    void CMyPropertySheet::OnMyButton ()
    {
              AfxMessageBox ("MyButton was clicked!");
    } 可以了,祝成功!