MFC ListCtrl控件上增加Comb以及可编写子项


MFC ListCtrl控件上增加Comb以及可编写子项 并且可以保存已经删除每一行的数据
资源截图
代码片段和文件信息
/*******************************************************************************
Author : Aravindan Premkumar
Unregistered Copyright 2003 : Aravindan Premkumar
All Rights Reserved

This piece of code does not have any registered copyright and is free to be 
used as necessary. The user is free to modify as per the requirements. As a
fellow developer all that I expect and request for is to be given the 
credit for intially developing this reusable code by not removing my name as 
the author.
*******************************************************************************/

#include “stdafx.h“
#include “ComboListCtrl.h“
#include “InplaceCombo.h“
#include “InPlaceEdit.h“

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//#defines
#define FIRST_COLUMN 0
#define MIN_COLUMN_WIDTH 10
#define MAX_DROP_DOWN_ITEM_COUNT 10

/////////////////////////////////////////////////////////////////////////////
// CComboListCtrl

CComboListCtrl::CComboListCtrl()
{
m_iColumnCounts = 0;
m_ComboSupportColumnsList.RemoveAll();
m_ReadOnlyColumnsList.RemoveAll();
m_strValidEditCtrlChars.Empty();
m_dwEditCtrlstyle = ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_LEFT | ES_NOHIDESEL;
m_dwDropDownCtrlstyle = WS_BORDER | WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_AUTOVSCROLL | 
CBS_DROPDOWNLIST | CBS_DISABLENOSCROLL;
}

CComboListCtrl::~CComboListCtrl()
{
CInPlaceCombo::DeleteInstance();
CInPlaceEdit::DeleteInstance();  
}


BEGIN_MESSAGE_MAP(CComboListCtrl CListCtrl)
//{{AFX_MSG_MAP(CComboListCtrl)
ON_WM_HSCROLL()
ON_WM_VSCROLL()
ON_WM_LBUTTONDOWN()
ON_NOTIFY_REFLECT(LVN_ENDLABELEDIT OnEndLabelEdit)
ON_NOTIFY_REFLECT(LVN_BEGINLABELEDIT OnBeginLabelEdit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CComboListCtrl message handlers

CInPlaceCombo* CComboListCtrl::ShowInPlaceList(int iRowIndex int iColumnIndex CStringList& rComboItemsList 
   CString strCurSelecetion /*= ““*/ int iSel /*= -1*/)
{
// The returned obPointer should not be saved

// Make sure that the item is visible
if (!EnsureVisible(iRowIndex TRUE))
{
return NULL;
}

// Make sure that iColumnIndex is valid 
CHeaderCtrl* pHeader = static_cast (GetDlgItem(FIRST_COLUMN));

int iColumnCount = pHeader->GetItemCount();

if (iColumnIndex >= iColumnCount || GetColumnWidth(iColumnIndex) < MIN_COLUMN_WIDTH) 
{
return NULL;
}

// Calculate the rectangle specifications for the combo box
CRect obCellRect(0 0 0 0);
CalculateCellRect(iColumnIndex iRowIndex obCellRect);

int iHeight = obCellRect.Height();  
int iCount = (int )rComboItemsList.GetCount();

iCount = (iCount < MAX_DROP_DOWN_ITEM_COUNT) ? 
iCount + MAX_DROP_DOWN_ITEM_COUNT : (MAX_DROP_DOWN_ITEM_COUNT + 1); 

obCellRect.bottom += iHeight * iCount; 

// Create the in place

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-12-13 15:32  ListCtrlComboEdit
     目录           0  2012-12-13 17:23  ListCtrlComboEditListCtrl
     文件       12164  2012-03-29 13:58  ListCtrlComboEditListCtrlComboListCtrl.cpp
     文件        5022  2005-10-28 15:49  ListCtrlComboEditListCtrlComboListCtrl.h
     目录           0  2012-12-13 17:23  ListCtrlComboEditListCtrlDebug
     文件        6582  2012-12-13 17:23  ListCtrlComboEditListCtrlDebugBuildLog.htm
     文件       75179  2012-12-13 17:11  ListCtrlComboEditListCtrlDebugComboListCtrl.obj
     文件       37041  2012-12-13 17:11  ListCtrlComboEditListCtrlDebugInPlaceCombo.obj
     文件       31216  2012-12-13 17:11  ListCtrlComboEditListCtrlDebugInPlaceEdit.obj
     文件      120832  2012-12-13 17:23  ListCtrlComboEditListCtrlDebugListCtrl.exe
     文件         920  2012-12-13 17:11  ListCtrlComboEditListCtrlDebugListCtrl.exe.embed.manifest
     文件         984  2012-12-13 17:11  ListCtrlComboEditListCtrlDebugListCtrl.exe.embed.manifest.res
     文件         861  2012-12-13 17:23  ListCtrlComboEditListCtrlDebugListCtrl.exe.intermediate.manifest
     文件     1297532  2012-12-13 17:23  ListCtrlComboEditListCtrlDebugListCtrl.ilk
     文件       21925  2012-12-13 17:11  ListCtrlComboEditListCtrlDebugListCtrl.obj
     文件    22085632  2012-12-13 17:11  ListCtrlComboEditListCtrlDebugListCtrl.pch
     文件     3099648  2012-12-13 17:23  ListCtrlComboEditListCtrlDebugListCtrl.pdb
     文件       23388  2012-12-13 17:11  ListCtrlComboEditListCtrlDebugListCtrl.res
     文件       52062  2012-12-13 17:23  ListCtrlComboEditListCtrlDebugListCtrlDlg.obj
     文件          65  2012-12-13 17:23  ListCtrlComboEditListCtrlDebugmt.dep
     文件      310523  2012-12-13 17:11  ListCtrlComboEditListCtrlDebugstdafx.obj
     文件      756736  2012-12-13 17:23  ListCtrlComboEditListCtrlDebugvc90.idb
     文件     1593344  2012-12-13 17:23  ListCtrlComboEditListCtrlDebugvc90.pdb
     文件        4487  2003-12-24 16:11  ListCtrlComboEditListCtrlInPlaceCombo.cpp
     文件        2880  2012-03-29 12:47  ListCtrlComboEditListCtrlInPlaceCombo.h
     文件        5024  2004-07-14 09:26  ListCtrlComboEditListCtrlInPlaceEdit.cpp
     文件        2847  2012-03-29 12:47  ListCtrlComboEditListCtrlInPlaceEdit.h
     文件       42748  2012-12-13 15:34  ListCtrlComboEditListCtrlListCtrl.aps
     文件        1478  2005-10-28 15:45  ListCtrlComboEditListCtrlListCtrl.cpp
     文件         449  2005-10-28 15:45  ListCtrlComboEditListCtrlListCtrl.h
     文件        5285  2005-10-28 16:56  ListCtrlComboEditListCtrlListCtrl.rc
............此处省略43个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)