1)工具栏
CBitmap bm;
UINT Resource[size]={IDB_BMP1,IDB_BMP2,IDB_BMP3,IDB_BMP4,IDB_BMP5,IDB_BMP6}; //位图ID数组
int i;
m_ImageList.Create(32,32,ILC_COLOR24|ILC_MASK,0,0); //创建Image List
m_ToolBar.Create(TBSTYLE_FLAT | CCS_TOP | WS_CHILD | WS_VISIBLE | WS_BORDER | CCS_ADJUSTABLE,CRect(0,0,0,0),this,IDR_TOOLBAR1);
//创建Toolbar Control
m_ToolBar.SetBitmapSize(CSize(32,32));
for (i = 0; i < size; i++)
{
bm.LoadBitmap(Resource[i]);
m_ImageList.Add(&bm,(CBitmap *)NULL);
bm.Detach();
}
m_ToolBar.SetImageList(&m_ImageList);
TBBUTTON Buttons[size]; //定义TBBUTTON结构体数组
CString str;
for ( i = 0; i < size; i++)
{
str.LoadString(IDS_FILE + i); //IDS_FILE是在String Table中添加的String,此处的关键是一定在string table 里面关联上工具栏上要显示的字符
Buttons[i].iString = m_ToolBar.AddStrings(str);
Buttons[i].dwData = 0;
Buttons[i].fsState = TBSTATE_ENABLED;
Buttons[i].fsStyle = TBSTYLE_BUTTON;
Buttons[i].iBitmap = i;
//Buttons[i].idCommand=IDS_FILE+i; //按钮命令响应
}
Buttons[0].idCommand = ID_1;
Buttons[1].idCommand = ID_2;
Buttons[2].idCommand = ID_3;
Buttons[3].idCommand = ID_4;
Buttons[4].idCommand = ID_5;
Buttons[5].idCommand = ID_6;
m_ToolBar.AddButtons(size,Buttons);
m_ToolBar.AutoSize();
m_ToolBar.ShowWindow(SW_SHOW);
2)状态栏
this->m_StatusBar.Create(WS_CHILD|WS_VISIBLE|SBT_OWNERDRAW, CRect(0,0,0,0), this, 0);
int strPartDim[]= {
300, //
600, //
-1, //
};
m_StatusBar.SetParts(sizeof(strPartDim)/sizeof(strPartDim[0]), strPartDim);
3)菜单栏
在资源里面添加菜单,然后再对话框的属性中的Menu中关联上菜单的ID就ok了。