//添加图标及工具栏
//本代码添加在对话框的OnInitDialog()消息响应函数中
//设置图标
m_pImageList=new CImageList();
m_pImageList->Create(16, 16, ILC_MASK, 2, 2);
m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_BACKWARD));
m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_UPWARD));
//设置工具栏的大小
CRect rect;
rect.left=0;
rect.bottom=200;
rect.right=rect.left+200;
rect.top=0;
//定义工具栏的控件
TBBUTTON arrTbButton[2];
m_UpBack.AddString(IDS_UP);
m_UpBack.AddString(IDS_BACK);
arrTbButton[0].iString=NULL;
arrTbButton[0].iBitmap=0;
arrTbButton[0].fsStyle=TBSTYLE_BUTTON ;
arrTbButton[0].fsState=TBSTATE_ENABLED ;
arrTbButton[0].idCommand=ID_BACK;
arrTbButton[1].idCommand=ID_UP;
arrTbButton[1].iBitmap=1;
arrTbButton[1].iString=NULL;
arrTbButton[1].fsStyle=TBSTYLE_BUTTON;
arrTbButton[1].fsState=TBSTATE_INDETERMINATE;
//在容器中创建工具栏,这样保证在任意位置创建工具栏
m_UpBack.Create(WS_CHILD|WS_VISIBLE|CCS_ADJUSTABLE|TBSTYLE_FLAT,rect,(CStatic*)(GetDlgItem(IDC_TB_CONTAINER)),0);
m_UpBack.AddButtons(2,arrTbButton);
m_UpBack.SetImageList(m_pImageList);
m_UpBack.SetStyle(TBSTYLE_FLAT | TBSTYLE_BUTTON |TBSTYLE_AUTOSIZE );
//设置高度,这样将工具栏上面的横线隐藏
int iButtonHeight=HIWORD(m_UpBack.GetButtonSize());
CRect CombRect;
((CComboBox*)GetDlgItem(IDC_COM_FOLDER))->GetWindowRect(&CombRect);
SetWindowPos((CStatic*)GetDlgItem(IDC_TB_CONTAINER),0,CombRect.top,iButtonHeight,200,SWP_NOMOVE);