CToolBar toolbar;
toolbar.CreateEx(this,TBSTYLE_FLAT,WS_CHILD|WS_VISIBLE|CBRS_ALIGN_TOP);
toolbar.LoadToolBar(IDR_TOOLBAR1);
#include
#include
#include "resource.h"
class MyFrameWnd :public CFrameWnd {
// 类内声明宏
DECLARE_MESSAGE_MAP()
public:
afx_msg int OnCreate(LPCREATESTRUCT pcs);
afx_msg void OnNew();
public:
CMenu menu;
CToolBar toolbar;
};
// 类外实现宏
BEGIN_MESSAGE_MAP(MyFrameWnd, CFrameWnd)
ON_WM_CREATE()
ON_COMMAND(Create_NewFile,OnNew)
END_MESSAGE_MAP()
void MyFrameWnd::OnNew() {
AfxMessageBox("框架-新建");
}
int MyFrameWnd::OnCreate(LPCREATESTRUCT pcs) {
// 设置菜单
menu.LoadMenuA(IDR_MENU1);
this->SetMenu(&menu);
// ::SetMenu(this->m_hWnd,menu.m_hMenu);
// 设置工具栏
toolbar.CreateEx(this,TBSTYLE_FLAT,WS_CHILD|WS_VISIBLE|CBRS_ALIGN_TOP);
toolbar.LoadToolBar(IDR_TOOLBAR1);
return CFrameWnd::OnCreate(pcs);
}
class MyWinApp :public CWinApp {
public:
MyWinApp() {
}
afx_msg void OnNew();
virtual BOOL InitInstance() {
MyFrameWnd* pFrame = new MyFrameWnd;
pFrame->Create(NULL, "Test");
m_pMainWnd = pFrame;
pFrame->ShowWindow(SW_SHOW);
pFrame->UpdateWindow();
return TRUE;
}
};
MyWinApp mainApp;