在线急救!!!!如何在非模态propertysheet上增加按钮

chaoren 2003-08-19 12:49:10
我作了一个非模态propertysheet,在上面增加了5个页面,现在想在sheet上加一个按钮,不知怎么加
...全文
35 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
bager 2003-08-19
  • 打赏
  • 举报
回复
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!");
}

可以了,祝成功!
曾经的猎狐 2003-08-19
  • 打赏
  • 举报
回复
直接在对话框上加

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧