MFC实现工具栏插入图片和文本

发布时间:2016-12-9 21:30:28 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"MFC实现工具栏插入图片和文本",主要涉及到MFC实现工具栏插入图片和文本方面的内容,对于MFC实现工具栏插入图片和文本感兴趣的同学可以参考一下。

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; 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_TOOLBAR)) { TRACE0("Failed to create toolbar\n"); return -1;      } HBITMAP hbmp1=(HBITMAP)::LoadImage(AfxGetInstanceHandle(), _T("res\\shezhi.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE); HBITMAP hbmp2=(HBITMAP)::LoadImage(AfxGetInstanceHandle(), _T("res\\yunxing.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE); HBITMAP hbmp3=(HBITMAP)::LoadImage(AfxGetInstanceHandle(), _T("res\\zanting.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE); HBITMAP hbmp4=(HBITMAP)::LoadImage(AfxGetInstanceHandle(), _T("res\\tingzhi.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE); HBITMAP hbmp5=(HBITMAP)::LoadImage(AfxGetInstanceHandle(), _T("res\\chaxunshuju.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE); HBITMAP hbmp6=(HBITMAP)::LoadImage(AfxGetInstanceHandle(), _T("res\\shanchushuju.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE); HBITMAP hbmp7=(HBITMAP)::LoadImage(AfxGetInstanceHandle(), _T("res\\qingkong.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE); HBITMAP hbmp8=(HBITMAP)::LoadImage(AfxGetInstanceHandle(), _T("res\\chaxunyonghu.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE); HBITMAP hbmp9=(HBITMAP)::LoadImage(AfxGetInstanceHandle(), _T("res\\tianjiayonghu.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE); HBITMAP hbmp10=(HBITMAP)::LoadImage(AfxGetInstanceHandle(), _T("res\\shanchuyonghu.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE); CBitmap bitmap1,bitmap2,bitmap3,bitmap4,bitmap5,bitmap6,bitmap7,bitmap8,bitmap9,bitmap10; bitmap1.Attach(hbmp1); bitmap2.Attach(hbmp2); bitmap3.Attach(hbmp3); bitmap4.Attach(hbmp4); bitmap5.Attach(hbmp5); bitmap6.Attach(hbmp6); bitmap7.Attach(hbmp7); bitmap8.Attach(hbmp8); bitmap9.Attach(hbmp9); bitmap10.Attach(hbmp10); m_imageList.Create(42,32,ILC_COLOR16|ILC_MASK,12,12); m_imageList.Add(&bitmap1,RGB(0,0,0)); m_imageList.Add(&bitmap2,RGB(0,0,0)); m_imageList.Add(&bitmap3,RGB(0,0,0)); m_imageList.Add(&bitmap4,RGB(0,0,0)); m_imageList.Add(&bitmap5,RGB(0,0,0)); m_imageList.Add(&bitmap6,RGB(0,0,0)); m_imageList.Add(&bitmap7,RGB(0,0,0)); m_imageList.Add(&bitmap8,RGB(0,0,0)); m_imageList.Add(&bitmap9,RGB(0,0,0)); m_imageList.Add(&bitmap10,RGB(0,0,0)); m_wndToolBar.GetToolBarCtrl().SetImageList(&m_imageList); m_wndToolBar.SetButtonText(0,"设置"); m_wndToolBar.SetButtonText(1,"运行"); m_wndToolBar.SetButtonText(2,"暂停"); m_wndToolBar.SetButtonText(3,"停止"); m_wndToolBar.SetButtonText(5,"查询数据"); m_wndToolBar.SetButtonText(6,"删除数据"); m_wndToolBar.SetButtonText(7,"清空数据"); m_wndToolBar.SetButtonText(9,"查询用户"); m_wndToolBar.SetButtonText(10,"添加用户"); m_wndToolBar.SetButtonText(11,"删除用户"); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar);

上一篇:php编码转换函数mb_convert_encoding
下一篇:linux下c语言嵌入汇编

相关文章

相关评论