一个效果很好的outlookbar控件CXTOutBarCtrl
该控件来源于Xtreme Toolkit,我对其进行了修改,使其不依赖于类库独立存在,由于我没有运用XT的其他类,可能你会觉得它没有在类库中的华丽,但相对于其小巧的体格而言,已经很难得了。
源文件包括两个头文件,两个执行文件:XTMemDC.h,XTMemDC.cpp,XTOutBarCtrl.h,
XTOutBarCtrl.cpp.
其中XTMemDC是一个CDC继承类,用于辅助功能。
该控件的使用方法:
1、用mfc sdi wizard生成一个子SDI程序。
2、在MainFrm.h头部加入#include "XTOutBarCtrl.h"
3、在MainFrm.h是加入成员变量
CSplitterWnd m_wndSplitter;
CXTOutBarCtrl m_wndOutlookBar;
CImageList m_ImageLarge;
CImageList m_ImageSmall;
bool m_bDestroy;
4、CMainFrame增加消息映射函数
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// create splitter window
if (!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 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);
// Add the tree control to the outlook bar.
//xu iFolder = m_wndOutlookBar.AddFolderBar(_T("Tree Control"), &m_wndTreeCtrl );
// Set the default font used by the outlook bar.
//xu m_wndOutlookBar.SetFontX(&xtAfxData.font);
// We want to receive notification messages.
m_wndOutlookBar.SetOwner(this);
// Select the first folder in the bar.
m_wndOutlookBar.SetSelFolder(iFolder);
// Sizing for splitter
CRect r;
GetClientRect(&r);
m_wndSplitter.SetColumnInfo( 0, r.Width()/7, 0 );
m_wndSplitter.SetColumnInfo( 1, r.Width()/5, 0 );
// m_wndSplitter1.SetSplitterStyle(XT_SPLIT_NOFULLDRAG);
}
6、CMainFrame增加消息映射 LRESULT CMainFrame::OnOutbarNotify(WPARAM wParam, LPARAM lParam)
{
int nBarAction = (int)wParam;
// Cast the lParam to a XT_OUTBAR_INFO* struct pointer.
XT_OUTBAR_INFO* pOBInfo = (XT_OUTBAR_INFO*)lParam;
ASSERT(pOBInfo);
switch (nBarAction)
{
case OBN_XT_ITEMCLICK:
TRACE2( "Item selected: %d, Name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText);
break;
case OBN_XT_FOLDERCHANGE:
TRACE2( "Folder selected: %d, Name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText);
break;
case OBN_XT_ONLABELENDEDIT:
TRACE2( "Item edited: %d, New name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText);
break;
case OBN_XT_ONGROUPENDEDIT:
TRACE2( "Folder edited: %d, New name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText);
break;
case OBN_XT_DRAGITEM:
TRACE3( "Dragging From: %d, To: %d, Name: %s.\n", pOBInfo->nDragFrom,
pOBInfo->nDragTo, pOBInfo->lpszText);
break;
case OBN_XT_ITEMHOVER:
TRACE2( "Hovering Item: %d, Name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText);
break;
case OBN_XT_DELETEITEM:
if (!m_bDestroy && AfxMessageBox(_T("Are you sure you want to remove this folder shortcut?"),
MB_ICONWARNING|MB_YESNO) == IDNO)
{
// The user selected No, return FALSE to abort the action.
return FALSE;
}
TRACE2( "Item deleted: %d, Name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText);
break;
case OBN_XT_DELETEFOLDER:
if (!m_bDestroy && AfxMessageBox(_T("Are you sure you want to remove the specified folder?"),
MB_ICONWARNING|MB_YESNO) == IDNO)
{
// The user selected No, return FALSE to abort the action.
return FALSE;
}
TRACE2( "Folder deleted: %d, Name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText);
break;
}
return TRUE;
}
还有其他一些内容请参见源程序,愿这个控件能对您的编程有所帮助,谢谢。
转载于:https://www.cnblogs.com/tecsoon/archive/2009/04/01/1427509.html
一个效果很好的outlookbar控件CXTOutBarCtrl相关推荐
- 分享一个 C# Winfrom 下的 OutlookBar 控件的使用
最近在上网的时候,发现了这个C# 下的 OutlookBar 控件,看了一下感觉还真不错,特此记录一下. using System; using System.Drawing; using Syste ...
- 想建一个带分隔条的label 控件;
想建一个带分隔条的label 控件: Delphi / Windows SDK/API http://www.delphi2007.net/DelphiBase/html/delphi_2006120 ...
- c# OutlookBar控件
最近在上网的时候,发现了这个C# 下的 OutlookBar 控件,看了一下感觉还真不错,特此记录一下. using System; using System.Drawing; using Syste ...
- 一个自定义的安卓验证码输入框控件、银行卡归属类型查询
一个自定义的安卓验证码输入框控件.银行卡归属类型查询. GitHub:https://github.com/longer96/VerifyCode Dependency Gradle dependen ...
- CalendarView使用详细文档(一个很不错的日历控件)
github地址:https://github.com/huanghaibin-dev/CalendarView CalendarView使用详细文档 日历控件定制是移动开发平台上比较常见的而且比较难 ...
- 如何实现一个循环显示超长图片的控件
*本篇文章已授权微信公众号 guolin_blog (郭霖)独家发布 某次被问到如何实现一个滚筒状的控件,就是可以将一张很长的图片沿着Y轴无限旋转,如下图所示: 大概就是这个意思,当时还不知道图片可以 ...
- 【WPF】一个类似于QQ面板的GroupShelf控件
最近做控件上了瘾,现在把做的一个类似于QQ面板的控件放上来. [分析] 从整体来看,这个控件应该同ListBox,ListView这类控件一样,是一个ItemsControl,而中间的项,就是它的It ...
- java自定义日历控件_【无私分享】修订版干货!!!一个炫酷的自定义日历控件,摆脱日历时间选择烦恼,纯福利~...
可能不少的小伙伴都有看楼主昨天发的自定义日历控件,虽然实现功能不多,但也还算将就吧. 但是看了的小伙伴就很心急了,说楼主上传到gitHub的东西有问题,楼主下载来看了看,基本都没问题吧,没弄好的小伙伴 ...
- 【无私分享】修订版干货!!!一个炫酷的自定义日历控件,摆脱日历时间选择烦恼,纯福利~...
可能不少的小伙伴都有看楼主昨天发的自定义日历控件,虽然实现功能不多,但也还算将就吧. 没有看的小伙伴如果有兴趣的话可以去看看:http://www.cnblogs.com/liushilin/p/57 ...
最新文章
- 深入浅出Redis五种基本数据类型
- 在云中进行灾难恢复的五种有效方式
- 使用TestNG-xslt+ant来美化selenium测试报告
- 将excel文件中的数据导入到mysql
- 基于 Kyma 的企业级云原生应用的扩展案例分享
- [scikit-learn 机器学习] 2. 简单线性回归
- 【HTML/CSS】HTML元素种类的划分
- 杭电2539点球大战
- VS2017专业版使用最新版Qt5.9.2教程(转载)
- 关于python字符编码_关于python文件的字符编码
- python的dict()字典数据类型的方法详解以及案例使用
- 求1+2!+3!+...+20!的和。
- html 排版标签、文本格式化标签、图像标签、链接标签、注释标签、路径、锚点定位、base文本标签、pre标签、特殊字符
- 卷积操作中的group
- 本周内外盘行情回顾2022.2.27
- Android中的动画2(逐帧动画)
- 感知复合型人才的重要性!
- Java实现能完成 加减乘除幂与阶乘 组合运算的计算器
- matlab中传递函数的离散化
- java自动化测试语言高级之发送邮件