资源简介
一个很好的开源代码,实现了listctrl列表项的 edit、combobox等功能
代码片段和文件信息
#include “stdafx.h“
#include “CGridColumnTraitCombo.h“
#include “CGridColumnTraitVisitor.h“
#include “CGridListCtrlEx.h“
//------------------------------------------------------------------------
// CGridColumnTraitCombo
//------------------------------------------------------------------------
CGridColumnTraitCombo::CGridColumnTraitCombo()
:m_MaxItems(7)
m_MaxWidth(200)
m_ComboBoxstyle(WS_VSCROLL | WS_HSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_NOINTEGRALHEIGHT)
m_pComboBox(NULL)
{}
void CGridColumnTraitCombo::Accept(CGridColumnTraitVisitor& visitor)
{
visitor.Visit(*this);
}
void CGridColumnTraitCombo::SetMaxItems(int items)
{
m_MaxItems = items;
}
int CGridColumnTraitCombo::GetMaxItems() const
{
return m_MaxItems;
}
void CGridColumnTraitCombo::SetMaxWidth(int width)
{
m_MaxWidth = width;
}
int CGridColumnTraitCombo::GetMaxWidth() const
{
return m_MaxWidth;
}
void CGridColumnTraitCombo::Setstyle(DWORD dwstyle)
{
m_ComboBoxstyle = dwstyle;
}
DWORD CGridColumnTraitCombo::Getstyle() const
{
return m_ComboBoxstyle;
}
CComboBox* CGridColumnTraitCombo::CreateComboBox(CGridListCtrlEx& owner int nRow int nCol const CRect& rect)
{
CComboBox* pComboBox = new CGridEditorComboBox(nRow nCol m_MaxWidth);
VERIFY( pComboBox->Create( WS_CHILD | m_ComboBoxstyle rect &owner 0) );
// Configure font
pComboBox->SetFont(owner.GetCellFont());
return pComboBox;
}
CWnd* CGridColumnTraitCombo::OnEditBegin(CGridListCtrlEx& owner int nRow int nCol)
{
// Get position of the cell to edit
CRect rcItem = GetCellEditRect(owner nRow nCol);
int requiredHeight = GetCellFontHeight(owner);
// Expand the size of the ComboBox according to max-elements
CRect rcFinalSize = rcItem;
rcFinalSize.bottom += rcItem.Height() + requiredHeight * m_MaxItems;
// Create edit control to edit the cell
// - Stores the pointer so elements can be dynamically added later
m_pComboBox = CreateComboBox(owner nRow nCol rcFinalSize);
VERIFY(m_pComboBox!=NULL);
// Add all items to list
if (m_ComboList.GetSize()>0)
{
LoadList(m_ComboList -1);
// Guess the currently selected item in the list
CString item = owner.GetItemText(nRow nCol);
int nCurSel = m_pComboBox->FindString(-1 item);
if (nCurSel!=-1)
m_pComboBox->SetCurSel(nCurSel);
else
m_pComboBox->SetWindowText(item);
}
else
{
CString item = owner.GetItemText(nRow nCol);
m_pComboBox->SetWindowText(item);
}
// Resize combobox according to element count
VERIFY( owner.GetCellRect(nRow nCol LVIR_LABEL rcFinalSize) );
rcFinalSize.bottom += rcItem.Height() + requiredHeight * min(m_MaxItems m_pComboBox->GetCount() + 1);
m_pComboBox->SetWindowPos(NULL // not relative to any other windows
0 0 // TopLeft corner doesn‘t change
rcFinalSize.Width() rcFinalSize.Height() // existing width new height
SWP_NOMOVE | SWP_NOZORDER // don‘t move bo
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 2679 2008-09-11 11:05 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridColumnTrait.h
....... 9691 2008-10-21 13:11 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridColumnTraitCombo.cpp
....... 2773 2008-09-18 10:16 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridColumnTraitCombo.h
....... 4461 2008-10-21 13:11 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridColumnTraitDateTime.cpp
....... 1723 2008-09-11 11:05 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridColumnTraitDateTime.h
....... 3525 2008-10-21 13:11 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridColumnTraitEdit.cpp
....... 1329 2008-09-11 11:05 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridColumnTraitEdit.h
....... 4150 2008-10-29 16:39 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridColumnTraitText.cpp
....... 1036 2008-09-22 10:56 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridColumnTraitText.h
....... 827 2008-09-11 11:05 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridColumnTraitVisitor.h
....... 50616 2008-11-07 12:08 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridListCtrlEx.cpp
....... 7205 2008-11-07 12:08 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridListCtrlEx.h
....... 22839 2008-11-03 10:37 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridListCtrlGroups.cpp
....... 2535 2008-09-22 10:56 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridListCtrlGroups.h
....... 920 2008-09-22 10:56 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridRowTrait.h
....... 5331 2008-10-29 16:39 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridRowTraitText.cpp
....... 1092 2008-09-22 10:56 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridRowTraitText.h
....... 652 2008-09-22 10:56 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridRowTraitVisitor.h
....... 4009 2008-09-22 10:56 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridRowTraitXP.cpp
....... 667 2008-09-22 10:56 CGridListCtrlEx_Demo\CGridListCtrlEx\CGridRowTraitXP.h
文件 22637568 2013-12-31 15:55 CGridListCtrlEx_Demo\DemoApplication\CGridListCtrlEx.ncb
....... 5764 2008-09-11 11:05 CGridListCtrlEx_Demo\DemoApplication\CGridListCtrlEx.rc
文件 890 2013-07-23 15:03 CGridListCtrlEx_Demo\DemoApplication\CGridListCtrlEx.sln
文件 889 2008-10-08 09:50 CGridListCtrlEx_Demo\DemoApplication\CGridListCtrlEx.sln.old
..A..H. 21504 2013-12-31 15:55 CGridListCtrlEx_Demo\DemoApplication\CGridListCtrlEx.suo
文件 8076 2013-07-23 15:03 CGridListCtrlEx_Demo\DemoApplication\CGridListCtrlEx.vcproj
文件 8012 2008-11-07 12:11 CGridListCtrlEx_Demo\DemoApplication\CGridListCtrlEx.vcproj.8.00.old
文件 1423 2013-12-31 15:55 CGridListCtrlEx_Demo\DemoApplication\CGridListCtrlEx.vcproj.Gaofeng-PC.Administrator.user
文件 1423 2013-08-12 11:26 CGridListCtrlEx_Demo\DemoApplication\CGridListCtrlEx.vcproj.GAOFENG-PC.Gaofeng.user
....... 1968 2008-09-05 17:48 CGridListCtrlEx_Demo\DemoApplication\CGridListCtrlExApp.cpp
............此处省略27个文件信息
- 上一篇:gao3431128_2371510.zip
- 下一篇:公安视频图像行业标准
相关资源
- An introduction to probabilistic graphical mod
- listview下拉刷新
- ExpandListView
- Soap监听工具Membrane-monitor2
- 《 带checkbox的ListView实现二——自定义
- List控件使用---SimpleAdapter使用详解一
- 仿QQ好友列表分组悬浮PinnedHeaderExpan
- listviewdemo
- ProbabilisticRobotics.pdf
- iPhone iPad iOS plist文件编辑器可修改存
- 列表控件(包括滚动条) 组合框 Sl
- eclipse和studio双版本:SwipeMenuListView-
- mingw Minimalist GNUfor Windows 程序
-
filelists.xm
l.gz - 将数据库中的数据表添加到ListContro
- ExpandableListView仿QQ好友列表
- ListView +RatingBar +TextView +adapter
- 基于list-mode数据的PET高分辨率重建算
- 仿美团弹出分类选择框左右两个list
- plist-合图、拆图工具
- HD4000-config.plist
- TableView汽车品牌导航图标和plist文件
- Probabilistic Graphical Model - Principles and
- 简易便签listview实现数据库链接
- expandableListview侧滑删除demo
- listView_choose
- ListView选中item颜色改变
- CardView+ListView
- CListBox中设置文本的颜色(字体)
- Introduction to Probabilistic Graphical Models
评论
共有 条评论