一个效果很好的outlookbar控件CXTOutBarCtrl

2016-01-29 11:54 542 1 收藏

一个效果很好的outlookbar控件CXTOutBarCtrl,一个效果很好的outlookbar控件CXTOutBarCtrl

【 tulaoshi.com - C语言心得技巧 】

一个效果很好的outlookbar控件CXTOutBarCtrl
作者:许昌元

下载本文示例源代码



该控件来源于Xtreme Toolkit,我对其进行了修改,使其不依赖于类库独立存在,由于我没有运用XT的其他类,可能你会觉得它没有在类库中的华丽,但相对于其小巧的体格而言,已经很难得了。

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com)

源文件包括两个头文件,两个执行文件:XTMemDC.h,XTMemDC.cpp,XTOutBarCtrl.h,XTOutBarCtrl.cpp.

其中XTMemDC是一个CDC继承类,用于辅助功能。

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com)

该控件的使用方法:

1、用mfc sdi wizard生成一个子SDI程序。

2、在MainFrm.h头部加入#include "XTOutBarCtrl.h"

3、在MainFrm.h是加入成员变量

CSplitterWndm_wndSplitter;CXTOutBarCtrlm_wndOutlookBar;CImageListm_ImageLarge;CImageListm_ImageSmall;boolm_bDestroy;
4、CMainFrame增加消息映射函数
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) {// create splitter windowif (!m_wndSplitter.CreateStatic(this, 1, 2))return FALSE;// Here we create the outbar control using the splitter as its parent// and setting its id to the first pane.if (!m_wndOutlookBar.Create(WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN, CRect(0,0,0,0),&m_wndSplitter, m_wndSplitter.IdFromRowCol(0, 0), OBS_XT_DEFAULT)){TRACE0("Failed to create outlook bar.");return FALSE;}if (!m_wndSplitter.CreateView(0, 1, pContext->m_pNewViewClass,CSize(100, 100), pContext)){m_wndSplitter.DestroyWindow();return FALSE;}// Set the background and text color of the outlook bar.m_wndOutlookBar.SetBackColor(RGB(0x3a,0x6e,0xa5));m_wndOutlookBar.SetTextColor(RGB(0xff,0xff,0xff));// Set the default sizes for the splitter panes.CRect r;GetClientRect(&r);m_wndSplitter.SetColumnInfo( 0, r.Width()/4, 0 );m_wndSplitter.RecalcLayout();// Add items to the outlook bar.InitializeOutlookBar();return TRUE;}

5、CMainFrame增加成员函数
void CMainFrame::InitializeOutlookBar(){// Create the image lists used by the outlook bar.m_ImageSmall.Create (16, 16, ILC_COLOR16|ILC_MASK, 2, 1);m_ImageLarge.Create (32, 32, ILC_COLOR16|ILC_MASK, 2, 1);// initiailize the image lists.for (int i = 0; i < 11; ++i){HICON hIcon = AfxGetApp()->LoadIcon(nIcons[i]);ASSERT(hIcon);m_ImageSmall.Add(hIcon);m_ImageLarge.Add(hIcon);}int iFolder; // index of the added folder// set the image lists for the outlook bar.m_wndOutlookBar.SetImageList(&m_ImageLarge, OBS_XT_LARGEICON);m_wndOutlookBar.SetImageList(&m_ImageSmall, OBS_XT_SMALLICON);// Add the first folder to the outlook bar.iFolder = m_wndOutlookBar.AddFolder(_T("Shortcuts 1"), 0);// Add items to the folder, syntax is folder, index, text, image, and item data.m_wndOutlookBar.InsertItem(iFolder, 1, _T("Item 1"), 0, NULL);m_wndOutlookBar.InsertItem(iFolder, 2, _T("Item 2"), 1, NULL);m_wndOutlookBar.InsertItem(iFolder, 3, _T("Item 3"), 2, NULL);m_wndOutlookBar.InsertItem(iFolder, 4, _T("Item 4"), 3, NULL);m_wndOutlookBar.InsertItem(iFolder, 5, _T("Item 5"), 4, NULL);m_wndOutlookBar.InsertItem(iFolder, 6, _T("Item 6"), 5, NULL);// Add the second folder to the outlook bar.iFolder = m_wndOutlookBar.AddFolder(_T("Shortcuts 2"), 1);// Add
                        

来源:http://www.tulaoshi.com/n/20160129/1483805.html

延伸阅读
  }    trRow = tbBoard.insertRow(2);    var cnDateName = new Array("周日","周一","周二","周三","周四","周五","周六");    for (var i = 0; i < 7; i++) {     tbCell=trRow.insertCell(i)     tbCell.innerText=cnDateName[i];     tbCell.align...
   }    btnCell.onmouseout=function(){     btnCell.style.cssText="width:100%;border:1 outset;background-color:buttonface;";    }   // btnCell.onmousedown=function(){   //  btnCell.style.cssText="width:100%;border:1 inset;background-color:#F0F0F0;";   // }...
    calendar.currentDate--;     if(calendar.currentDate==0){      calendar.currentDate=12;      calendar.currentDate[0]--;     }     calendar.show(calendar.target,calendar.currentDate[0]+"-"+calendar.currentDate+"-"+cale...
   if(defaultDate==undefined || defaultDate==""){     var theDate=new Array();     calendar.head.innerText = calendar.today[0]+"-"+calendar.today+"-"+calendar.today;     theDate[0]=calendar.today[0]; theDate=calendar.today; theDate=calendar.today;    } &n...
  this.getMonthLen=function(theYear, theMonth) {    theMonth--;    var oneDay = 1000 * 60 * 60 * 24;    var thisMonth = new Date(theYear, theMonth, 1);    var nextMonth = new Date(theYear, theMonth + 1, 1);    var len = Math.ceil((nextMonth.getTime() - thisMonth.ge...

经验教程

151

收藏

71
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部