15,979
社区成员
发帖
与我相关
我的任务
分享
BEGIN_MESSAGE_MAP(CDialog1, CDialog)
//{{AFX_MSG_MAP(CDialog1)
ON_WM_CREATE()
ON_WM_SIZE()
ON_COMMAND(ID_BUTTON_TEST1, OnButtonTest1) //工具栏按钮1的响应函数
ON_COMMAND(ID_BUTTON_TEST2, OnButtonTest2) //工具栏按钮2的响应函数
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialog1 message handlers
int CDialog1::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_TOOLBAR1))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
return 0;
}
void CDialog1::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
m_wndToolBar.MoveWindow(0, 0, cx, 25);
}
void CDialog1::OnButtonTest1()
{
AfxMessageBox("Button1 is pressed!");
}
void CDialog1::OnButtonTest2()
{
AfxMessageBox("Button2 is pressed!");
}
int CDialog1::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_TOOLBAR1))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndToolBar.GetToolBarCtrl().EnableButton(ID_BUTTON_TEST1,TRUE); return 0;
}