// ListCtrlEx.cpp : implementation file
|
//
|
|
#include "stdafx.h"
|
#include "ListCtrlEx.h"
|
|
#include "SortClass.h"
|
|
#ifdef _DEBUG
|
#define new DEBUG_NEW
|
#undef THIS_FILE
|
static char THIS_FILE[] = __FILE__ ;
|
#endif
|
|
/////////////////////////////////////////////////////////////////////////////
|
// CListCtrlEx
|
|
CListCtrlEx::CListCtrlEx()
|
{
|
m_nColNum = 0;
|
m_nDisableRow = -1;
|
m_nDisableCol = -1;
|
m_nEditDisableState = EDITDISABLE_NONE;
|
|
m_pEdit = NULL;
|
m_pComboBox = NULL;
|
m_pEditDisableCols = NULL;
|
m_pEditDisableRows = NULL;
|
m_strInitEditText = _T("");
|
m_nInPlaceCtrl = -1;
|
m_bSortOrder = TRUE;
|
m_bEnableSortList = TRUE;
|
m_nLength = 0;
|
|
m_pComboData = NULL;
|
m_nComboDataState = COMBODATASTATE_SINGLE;
|
|
m_pEditCtrlCols = NULL;
|
m_pComboCtrlCols = NULL;
|
m_nEditCtrlLength = 0;
|
m_nComboCtrlLength = 0;
|
|
m_bSetImageList = FALSE;
|
|
m_pbNumericCol = NULL;
|
}
|
|
CListCtrlEx::~CListCtrlEx()
|
{
|
if(m_pEdit)
|
{
|
delete m_pEdit;
|
m_pEdit = NULL;
|
}
|
|
if(m_pComboBox)
|
{
|
delete m_pComboBox;
|
m_pComboBox = NULL;
|
}
|
|
if(m_pEditDisableCols)
|
{
|
delete m_pEditDisableCols;
|
m_pEditDisableCols = NULL;
|
}
|
|
if(m_pEditDisableRows)
|
{
|
delete m_pEditDisableRows;
|
m_pEditDisableRows = NULL;
|
}
|
|
if(m_pComboData)
|
{
|
m_pComboData->RemoveAll();
|
delete m_pComboData;
|
m_pComboData = NULL;
|
}
|
|
if(m_pEditCtrlCols)
|
{
|
delete m_pEditCtrlCols;
|
m_pEditCtrlCols = NULL;
|
}
|
|
if(m_pComboCtrlCols)
|
{
|
delete m_pComboCtrlCols;
|
m_pComboCtrlCols = NULL;
|
}
|
|
if(m_pbNumericCol != NULL)
|
{
|
delete[] m_pbNumericCol;
|
m_pbNumericCol = NULL;
|
}
|
|
ResetTextColor();
|
ResetBKColor();
|
}
|
|
|
BEGIN_MESSAGE_MAP(CListCtrlEx, CListCtrl)
|
//{{AFX_MSG_MAP(CListCtrlEx)
|
ON_WM_LBUTTONDOWN()
|
ON_WM_VSCROLL()
|
ON_WM_HSCROLL()
|
ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnclick)
|
ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)
|
//}}AFX_MSG_MAP
|
END_MESSAGE_MAP()
|
|
/////////////////////////////////////////////////////////////////////////////
|
// CListCtrlEx message handlers
|
|
void CListCtrlEx::OnLButtonDown(UINT nFlags, CPoint point)
|
{
|
// TODO: Add your message handler code here and/or call default
|
|
CListCtrl::OnLButtonDown(nFlags, point);
|
|
// AddBlankItem();
|
|
LVHITTESTINFO pItem;
|
pItem.pt = point;
|
int test = SubItemHitTest(&pItem);
|
|
int nCol,nRow;
|
nRow = pItem.iItem;
|
nCol = pItem.iSubItem;
|
|
if(nRow != -1)
|
{
|
CRect rect;
|
if(nCol == 0)
|
{
|
GetItemRect(nRow,rect,LVIR_BOUNDS);
|
rect.right = GetColumnWidth(nCol);
|
}
|
else
|
GetSubItemRect(nRow,nCol,LVIR_BOUNDS,rect);
|
|
// Á¦¿ÜµÈ Çà,¿ üũ //////////////////////////////////////////////////////
|
if(m_nEditDisableState == EDITDISABLE_ROWS || m_nEditDisableState == EDITDISABLE_COLS)
|
{
|
if(m_nDisableRow == nRow)
|
return;
|
if(m_nDisableCol == nCol)
|
return;
|
}
|
if(m_nEditDisableState == EDITDISABLE_ROWCOL)
|
{
|
if(m_nDisableRow == nRow && m_nDisableCol == nCol)
|
return;
|
}
|
|
if(m_nEditDisableState == EDITDISABLE_ROWS_ARRAY)
|
{
|
if(m_pEditDisableRows)
|
{
|
for(int i=0;i<m_nLength;i++)
|
{
|
if(m_pEditDisableRows[i] == nRow)
|
return;
|
}
|
}
|
}
|
if(m_nEditDisableState == EDITDISABLE_COLS_ARRAY)
|
{
|
if(m_pEditDisableCols)
|
{
|
for(int i=0;i<m_nLength;i++)
|
{
|
if(m_pEditDisableCols[i] == nCol)
|
return;
|
}
|
}
|
}
|
// End.. //////////////////////////////////////////////////////////////////
|
|
if(m_nInPlaceCtrl == INPLACECTRL_EDIT)
|
{
|
if(m_pEdit)
|
{
|
delete m_pEdit;
|
m_pEdit = NULL;
|
}
|
|
m_pEdit = new CInPlaceEdit(nRow,nCol,m_strInitEditText);
|
m_pEdit->Create(WS_BORDER | WS_CHILD | WS_VISIBLE,rect,this,10000);
|
m_pEdit->ShowWindow(SW_SHOW);
|
}
|
|
|
if(m_nInPlaceCtrl == INPLACECTRL_COMBO)
|
{
|
if(m_pComboBox)
|
{
|
delete m_pComboBox;
|
m_pComboBox = NULL;
|
}
|
|
m_pComboBox = new CInPlaceComboBox(nRow,nCol);
|
rect.bottom = rect.bottom + 200;
|
m_pComboBox->Create(WS_BORDER | WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL,rect,this,10001);
|
// DWORD dwStyle = m_pComboBox->GetStyle();
|
// dwStyle &= ~CBS_SORT;
|
// SetWindowLong(m_pComboBox->m_hWnd, GWL_STYLE, dwStyle);
|
POSITION pos = m_pComboData->GetHeadPosition();
|
while(pos)
|
{
|
m_pComboBox->AddString(m_pComboData->GetNext(pos));
|
}
|
|
m_pComboBox->ShowDropDown();
|
m_pComboBox->SetCurSel(0);
|
|
m_pComboBox->ShowWindow(SW_SHOW);
|
}
|
|
if(m_nInPlaceCtrl == INPLACECTRL_EDIT_COMBO)
|
{
|
if(m_pEditCtrlCols)
|
{
|
for(int i=0;i<m_nEditCtrlLength;i++)
|
{
|
if(nCol == m_pEditCtrlCols[i])
|
{
|
if(m_pEdit)
|
{
|
delete m_pEdit;
|
m_pEdit = NULL;
|
}
|
|
m_pEdit = new CInPlaceEdit(nRow,nCol,m_strInitEditText);
|
m_pEdit->Create(WS_BORDER | WS_CHILD | WS_VISIBLE,rect,this,10000);
|
m_pEdit->ShowWindow(SW_SHOW);
|
}
|
}
|
}
|
|
if(m_pComboCtrlCols)
|
{
|
for(int j=0;j<m_nComboCtrlLength;j++)
|
{
|
if(nCol == m_pComboCtrlCols[j])
|
{
|
if(m_pComboBox)
|
{
|
delete m_pComboBox;
|
m_pComboBox = NULL;
|
}
|
|
m_pComboBox = new CInPlaceComboBox(nRow,nCol);
|
rect.bottom = rect.bottom + 200;
|
m_pComboBox->Create(WS_BORDER | WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL,rect,this,10001);
|
// DWORD dwStyle = m_pComboBox->GetStyle();
|
// dwStyle &= ~CBS_SORT;
|
// SetWindowLong(m_pComboBox->m_hWnd, GWL_STYLE, dwStyle);
|
|
if(!m_pComboData)
|
return;
|
|
if(m_nComboDataState == COMBODATASTATE_SINGLE)
|
{
|
POSITION pos = m_pComboData->GetHeadPosition();
|
while(pos)
|
{
|
m_pComboBox->AddString(m_pComboData->GetNext(pos));
|
}
|
}
|
|
if(m_nComboDataState == COMBODATASTATE_MULTI)
|
{
|
POSITION pos = m_pComboData->FindIndex(j);
|
|
if(!pos)
|
return;
|
|
CString strData = m_pComboData->GetAt(pos);
|
CString strToken;
|
|
for(int k=0;k<strData.GetLength();k++)
|
{
|
TCHAR ch = strData.GetAt(k);
|
|
if(ch == _T(',') )
|
{
|
m_pComboBox->AddString((LPTSTR)(LPCTSTR)strToken);
|
strToken.Empty();
|
}
|
else
|
strToken += ch;
|
}
|
m_pComboBox->AddString((LPTSTR)(LPCTSTR)strToken);
|
}
|
|
m_pComboBox->ShowDropDown();
|
m_pComboBox->SetCurSel(0);
|
|
m_pComboBox->ShowWindow(SW_SHOW);
|
}
|
}
|
}
|
}
|
}
|
}
|
|
void CListCtrlEx::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
|
{
|
// TODO: Add your message handler code here and/or call default
|
if (GetFocus() != this)
|
SetFocus();
|
|
CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
|
}
|
|
void CListCtrlEx::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
|
{
|
// TODO: Add your message handler code here and/or call default
|
if (GetFocus() != this)
|
SetFocus();
|
|
CListCtrl::OnHScroll(nSBCode, nPos, pScrollBar);
|
}
|
|
void CListCtrlEx::OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult)
|
{
|
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
|
// TODO: Add your control notification handler code here
|
|
if(m_bEnableSortList)
|
SortListCtrl(pNMListView->iSubItem);
|
|
*pResult = 0;
|
}
|
|
void CListCtrlEx::SetTextColor(int nRow, COLORREF clrText)
|
{
|
POSITION pos = m_ListColorText.GetHeadPosition();
|
pListRowColor pLRC;
|
BOOL bIs = FALSE;
|
while (pos)
|
{
|
pLRC = m_ListColorText.GetNext(pos);
|
if (pLRC)
|
{
|
if (pLRC->s_nRow == nRow)
|
{
|
pLRC->s_Color = clrText;
|
bIs = TRUE;
|
break;
|
}
|
}
|
}
|
if (!bIs)
|
{
|
pListRowColor pLRC = new ListRowColor;
|
pLRC->s_nRow = nRow;
|
pLRC->s_Color = clrText;
|
m_ListColorText.AddTail(pLRC);
|
}
|
}
|
|
void CListCtrlEx::SetBKColor(int nRow, COLORREF clrBK)
|
{
|
POSITION pos = m_ListColorBk.GetHeadPosition();
|
pListRowColor pLRC;
|
BOOL bIs = FALSE;
|
while (pos)
|
{
|
pLRC = m_ListColorBk.GetNext(pos);
|
if (pLRC)
|
{
|
if (pLRC->s_nRow == nRow)
|
{
|
pLRC->s_Color = clrBK;
|
bIs = TRUE;
|
break;
|
}
|
}
|
}
|
if (!bIs)
|
{
|
pListRowColor pLRC = new ListRowColor;
|
pLRC->s_nRow = nRow;
|
pLRC->s_Color = clrBK;
|
m_ListColorBk.AddTail(pLRC);
|
}
|
}
|
|
void CListCtrlEx::ReleaseTextColor(int nRow)
|
{
|
POSITION posDel = NULL;
|
POSITION pos = m_ListColorText.GetHeadPosition();
|
pListRowColor pLRC;
|
BOOL bIs = FALSE;
|
while (pos)
|
{
|
posDel = pos;
|
pLRC = m_ListColorText.GetNext(pos);
|
if (pLRC && pLRC->s_nRow == nRow)
|
{
|
bIs = TRUE;
|
break;
|
}
|
}
|
if (bIs && posDel && pLRC)
|
{
|
delete pLRC;
|
pLRC = NULL;
|
m_ListColorText.RemoveAt(posDel);
|
}
|
}
|
|
void CListCtrlEx::ReleaseBKColor(int nRow)
|
{
|
POSITION posDel = NULL;
|
POSITION pos = m_ListColorBk.GetHeadPosition();
|
pListRowColor pLRC;
|
BOOL bIs = FALSE;
|
while (pos)
|
{
|
posDel = pos;
|
pLRC = m_ListColorBk.GetNext(pos);
|
if (pLRC && pLRC->s_nRow == nRow)
|
{
|
bIs = TRUE;
|
break;
|
}
|
}
|
if (bIs && posDel && pLRC)
|
{
|
delete pLRC;
|
pLRC = NULL;
|
m_ListColorBk.RemoveAt(posDel);
|
}
|
}
|
|
void CListCtrlEx::ResetTextColor()
|
{
|
POSITION pos = m_ListColorText.GetHeadPosition();
|
pListRowColor pLRC;
|
while (pos)
|
{
|
pLRC = m_ListColorText.GetNext(pos);
|
if (pLRC)
|
delete pLRC;
|
pLRC = NULL;
|
}
|
m_ListColorText.RemoveAll();
|
}
|
|
void CListCtrlEx::ResetBKColor()
|
{
|
POSITION pos = m_ListColorBk.GetHeadPosition();
|
pListRowColor pLRC;
|
while (pos)
|
{
|
pLRC = m_ListColorBk.GetNext(pos);
|
if (pLRC)
|
delete pLRC;
|
pLRC = NULL;
|
}
|
m_ListColorBk.RemoveAll();
|
}
|
|
void CListCtrlEx::AddBlankItem()
|
{
|
int nRow;
|
nRow = GetCountPerPage();
|
|
if(GetItemCount()<nRow)
|
{
|
for(int i=0;i<nRow;i++)
|
{
|
for(int j=0;j<m_nColNum;j++)
|
{
|
if(GetItemText(i,j) == _T(""))
|
InsertListItem(i,j,_T(""));
|
}
|
}
|
}
|
}
|
|
void CListCtrlEx::SetColNum(int nColNum)
|
{
|
m_nColNum = nColNum;
|
}
|
|
CImageList* CListCtrlEx::SetImageList(CImageList* pImageList, int nImageListType)
|
{
|
if (pImageList)
|
{
|
m_bSetImageList = TRUE;
|
return CListCtrl::SetImageList(pImageList, nImageListType);
|
}
|
|
return NULL;
|
}
|
|
void CListCtrlEx::InsertListItem(int nRow, int nCol,LPTSTR lpString)
|
{
|
LV_ITEM item;
|
|
item.mask = LVIF_TEXT;
|
item.iItem = nRow;
|
item.iSubItem = nCol;
|
item.pszText = lpString;
|
InsertItem(&item);
|
|
item.iSubItem = nCol;
|
item.pszText = lpString;
|
SetItem(&item);
|
}
|
|
void CListCtrlEx::InsertListItem(int nRow, int nCol, int nImageIdx, LPTSTR lpString)
|
{
|
if (m_bSetImageList)
|
{
|
LV_ITEM item;
|
|
item.mask = LVIF_TEXT | LVIF_IMAGE;
|
item.iItem = nRow;
|
item.iSubItem = nCol;
|
item.iImage = nImageIdx;
|
item.pszText = lpString;
|
InsertItem(&item);
|
|
item.iSubItem = nCol;
|
item.pszText = lpString;
|
SetItem(&item);
|
}
|
else
|
InsertListItem(nRow, nCol, lpString);
|
}
|
|
void CListCtrlEx::InsertListItemEx(int nRow, int nCol, const CString& strString)
|
{
|
LV_ITEM item;
|
|
item.mask = LVIF_TEXT;
|
item.iItem = nRow;
|
item.iSubItem = nCol;
|
item.pszText = (LPTSTR)(LPCTSTR)strString;
|
InsertItem(&item);
|
|
item.iSubItem = nCol;
|
item.pszText = (LPTSTR)(LPCTSTR)strString;
|
SetItem(&item);
|
}
|
|
void CListCtrlEx::InsertListItemEx(int nRow, int nCol, int nValue)
|
{
|
CString strValue = _T("");
|
strValue.Format(_T("%d"), nValue);
|
|
LV_ITEM item;
|
|
item.mask = LVIF_TEXT | LVIF_IMAGE;
|
item.iItem = nRow;
|
item.iSubItem = nCol;
|
item.pszText = (LPTSTR)(LPCTSTR)strValue;
|
InsertItem(&item);
|
|
item.iSubItem = nCol;
|
item.pszText = (LPTSTR)(LPCTSTR)strValue;
|
SetItem(&item);
|
}
|
|
void CListCtrlEx::InsertListItemEx(int nRow, int nCol, double dValue, int nRight)
|
{
|
CString strValue = _T("");
|
strValue.Format(_T("%f"), dValue);
|
int nPoint = strValue.ReverseFind('.');
|
if (nPoint > 0 && nPoint + 1 < strValue.GetLength() - nRight)
|
strValue = strValue.Left(nPoint + 4);
|
|
LV_ITEM item;
|
|
item.mask = LVIF_TEXT | LVIF_IMAGE;
|
item.iItem = nRow;
|
item.iSubItem = nCol;
|
item.pszText = (LPTSTR)(LPCTSTR)strValue;
|
InsertItem(&item);
|
|
item.iSubItem = nCol;
|
item.pszText = (LPTSTR)(LPCTSTR)strValue;
|
SetItem(&item);
|
}
|
|
void CListCtrlEx::InsertListItem(int nRow, int nCol, int nImageIdx)
|
{
|
if (m_bSetImageList)
|
{
|
LV_ITEM item;
|
|
item.mask = LVIF_TEXT | LVIF_IMAGE;
|
item.iItem = nRow;
|
item.iImage = nImageIdx;
|
|
item.iSubItem = nCol;
|
item.pszText = _T("");
|
SetItem(&item);
|
}
|
else
|
InsertListItem(nRow, nCol, _T("") );
|
}
|
|
void CListCtrlEx::EditDisableRows(int nRows)
|
{
|
SetEditDisableState(EDITDISABLE_NONE);
|
m_nDisableRow = nRows;
|
m_nEditDisableState = EDITDISABLE_ROWS;
|
}
|
|
void CListCtrlEx::EditDisableCols(int nCols)
|
{
|
SetEditDisableState(EDITDISABLE_NONE);
|
m_nDisableCol = nCols;
|
m_nEditDisableState = EDITDISABLE_COLS;
|
}
|
|
void CListCtrlEx::EditDisableRowCol(int nRow, int nCol)
|
{
|
SetEditDisableState(EDITDISABLE_NONE);
|
m_nDisableRow = nRow;
|
m_nDisableCol = nCol;
|
m_nEditDisableState = EDITDISABLE_ROWCOL;
|
}
|
|
void CListCtrlEx::EditDisableCols(CString strCols,int nLength)
|
{
|
if(m_pEditDisableCols)
|
{
|
delete m_pEditDisableCols;
|
m_pEditDisableCols = NULL;
|
}
|
|
m_pEditDisableCols = new int[nLength];
|
m_nLength = nLength;
|
int nCol = 0;
|
|
CString strToken;
|
for(int i=0;i<strCols.GetLength();i++)
|
{
|
TCHAR ch = strCols.GetAt(i);
|
|
if(ch == _T(',') )
|
{
|
m_pEditDisableCols[nCol++] = _ttoi( strToken );
|
strToken.Empty();
|
}
|
else
|
strToken += ch;
|
}
|
m_pEditDisableCols[nLength-1] = _ttoi(strToken);
|
|
m_nEditDisableState = EDITDISABLE_COLS_ARRAY;
|
}
|
|
void CListCtrlEx::EditDisableRows(CString strRows,int nLength)
|
{
|
if(m_pEditDisableRows)
|
{
|
delete m_pEditDisableRows;
|
m_pEditDisableRows = NULL;
|
}
|
|
m_pEditDisableRows = new int[nLength];
|
m_nLength = nLength;
|
int nRow = 0;
|
|
CString strToken;
|
for(int i=0;i<strRows.GetLength();i++)
|
{
|
TCHAR ch = strRows.GetAt(i);
|
|
if(ch == _T(','))
|
{
|
m_pEditDisableRows[nRow++] = _ttoi(strToken);
|
strToken.Empty();
|
}
|
else
|
strToken += ch;
|
}
|
m_pEditDisableRows[nLength-1] = _ttoi(strToken);
|
|
m_nEditDisableState = EDITDISABLE_ROWS_ARRAY;
|
}
|
|
int CListCtrlEx::GetEditDisableState()
|
{
|
return m_nEditDisableState;
|
}
|
|
int CListCtrlEx::GetEditDisableRows()
|
{
|
return m_nDisableRow;
|
}
|
|
int CListCtrlEx::GetEditDisableCols()
|
{
|
return m_nDisableCol;
|
}
|
|
void CListCtrlEx::SetEditDisableState(int nState)
|
{
|
if(EDITDISABLE_NONE)
|
{
|
m_nDisableRow = -1;
|
m_nDisableCol = -1;
|
m_nEditDisableState = EDITDISABLE_NONE;
|
}
|
}
|
|
void CListCtrlEx::SetDefaultEditText(CString strInitText)
|
{
|
m_strInitEditText = strInitText;
|
}
|
|
void CListCtrlEx::SetInPlaceCtrl(int nCtrl)
|
{
|
if(m_pEditCtrlCols)
|
{
|
delete m_pEditCtrlCols;
|
m_pEditCtrlCols = NULL;
|
}
|
|
if(m_pComboCtrlCols)
|
{
|
delete m_pComboCtrlCols;
|
m_pComboCtrlCols = NULL;
|
}
|
|
m_nInPlaceCtrl = nCtrl;
|
}
|
|
void CListCtrlEx::InitListHeader(TCHAR *colList[], int *widthList, int nLength, int nHeight)
|
{
|
LV_COLUMN lvcolumn;
|
|
for(int i=0; i < nLength; i++)
|
{
|
lvcolumn.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
|
lvcolumn.fmt = LVCFMT_LEFT;
|
lvcolumn.pszText= colList[i];
|
lvcolumn.iSubItem= i;
|
lvcolumn.cx= widthList[i];
|
InsertColumn(i, &lvcolumn);
|
}
|
|
if (!m_bSetImageList)
|
{
|
// ¸®½ºÆ®ÀÇ row ³ôÀÌ Á¶Àý
|
CImageList m_image;
|
m_image.Create(1, nHeight, ILC_COLORDDB, 1, 0); //2¹øÂ° ÆÄ¶ó¹ÌÅÍ·Î ³ôÀÌÁ¶Àý.....
|
SetImageList(&m_image, LVSIL_SMALL);
|
}
|
|
if(m_pbNumericCol != NULL)
|
{
|
delete[] m_pbNumericCol;
|
m_pbNumericCol = NULL;
|
}
|
m_pbNumericCol = new BOOL[nLength];
|
memset(m_pbNumericCol,FALSE,sizeof(BOOL)*nLength);
|
|
SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
|
}
|
|
void CListCtrlEx::SortListCtrl(int nCol)
|
{
|
BOOL bNemeric = FALSE;
|
if(m_pbNumericCol != NULL)
|
{
|
bNemeric = m_pbNumericCol[nCol];
|
}
|
CSortClass csc(this, nCol , bNemeric);
|
|
if(m_bSortOrder)
|
m_bSortOrder = FALSE;
|
else
|
m_bSortOrder = TRUE;
|
|
|
csc.Sort(m_bSortOrder?1:0);
|
}
|
|
void CListCtrlEx::SetEnableSortList(BOOL nEnable)
|
{
|
m_bEnableSortList = nEnable;
|
}
|
|
|
BOOL CListCtrlEx::GetEnableSortList()
|
{
|
return m_bEnableSortList;
|
}
|
|
|
void CListCtrlEx::SetComboData(TCHAR *pData[], int nState , int nLength)
|
{
|
if(m_nInPlaceCtrl == INPLACECTRL_EDIT)
|
return;
|
|
if(m_pComboData)
|
{
|
m_pComboData->RemoveAll();
|
delete m_pComboData;
|
m_pComboData = NULL;
|
}
|
|
m_pComboData = new CStringList;
|
|
for(int i=0;i<nLength;i++)
|
{
|
m_pComboData->AddTail( pData[i] );
|
}
|
m_nComboDataState = nState;
|
}
|
|
void CListCtrlEx::SetComboData(CStringList* pList, int nState)
|
{
|
if(m_nInPlaceCtrl == INPLACECTRL_EDIT)
|
return;
|
|
if(m_pComboData)
|
{
|
m_pComboData->RemoveAll();
|
delete m_pComboData;
|
m_pComboData = NULL;
|
}
|
|
m_pComboData = new CStringList;
|
|
POSITION pos = pList->GetHeadPosition();
|
|
while(pos)
|
{
|
m_pComboData->AddTail(pList->GetNext(pos));
|
}
|
|
m_nComboDataState = nState;
|
}
|
|
void CListCtrlEx::SetEditCtrlCols(CString strCols, int nLength)
|
{
|
if(m_pEditCtrlCols)
|
{
|
delete m_pEditCtrlCols;
|
m_pEditCtrlCols = NULL;
|
}
|
|
m_pEditCtrlCols = new int[nLength];
|
m_nEditCtrlLength = nLength;
|
int nCol = 0;
|
|
CString strToken;
|
for(int i=0;i<strCols.GetLength();i++)
|
{
|
TCHAR ch = strCols.GetAt(i);
|
|
if(ch == _T(','))
|
{
|
m_pEditCtrlCols[nCol++] = _ttoi(strToken);
|
strToken.Empty();
|
}
|
else
|
strToken += ch;
|
}
|
m_pEditCtrlCols[nLength-1] = _ttoi(strToken);
|
|
m_nInPlaceCtrl = INPLACECTRL_EDIT_COMBO;
|
}
|
|
void CListCtrlEx::SetComboCtrlCols(CString strCols, int nLength)
|
{
|
if(m_pComboCtrlCols)
|
{
|
delete m_pComboCtrlCols;
|
m_pComboCtrlCols = NULL;
|
}
|
|
m_pComboCtrlCols = new int[nLength];
|
m_nComboCtrlLength = nLength;
|
int nCol = 0;
|
|
CString strToken;
|
for(int i=0;i<strCols.GetLength();i++)
|
{
|
TCHAR ch = strCols.GetAt(i);
|
|
if(ch == _T(','))
|
{
|
m_pComboCtrlCols[nCol++] = _ttoi(strToken);
|
strToken.Empty();
|
}
|
else
|
strToken += ch;
|
}
|
m_pComboCtrlCols[nLength-1] = _ttoi(strToken);
|
|
m_nInPlaceCtrl = INPLACECTRL_EDIT_COMBO;
|
}
|
|
void CListCtrlEx::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
|
{
|
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
|
|
*pResult = CDRF_DODEFAULT;
|
if (CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage)
|
*pResult = CDRF_NOTIFYITEMDRAW;
|
else if (CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage)
|
{
|
int nItem = static_cast<int>(pLVCD->nmcd.dwItemSpec); // °¢ ¶óÀÎ ¼³Á¤
|
|
COLORREF crTextColor = RGB(0,0,0), crBkColor = RGB(255,255,255);
|
pListRowColor pLRC = NULL;
|
POSITION pos = NULL;
|
|
// ±ÛÀÚ»ö ¹Ù²Ù±â
|
pos = m_ListColorText.GetHeadPosition();
|
while (pos)
|
{
|
pLRC = m_ListColorText.GetNext(pos);
|
if (pLRC && pLRC->s_nRow == nItem)
|
break;
|
}
|
if (pLRC)
|
pLVCD->clrText = pLRC->s_Color;
|
|
// ¹è°æ»ö ¹Ù²Ù±â
|
pos = m_ListColorBk.GetHeadPosition();
|
while (pos)
|
{
|
pLRC = m_ListColorBk.GetNext(pos);
|
if (pLRC && pLRC->s_nRow == nItem)
|
break;
|
}
|
if (pLRC)
|
pLVCD->clrTextBk = pLRC->s_Color;
|
|
// Tell Windows to paint the control itself;
|
*pResult = CDRF_DODEFAULT;
|
}
|
}
|
|
void CListCtrlEx::InitNumericCol( BOOL* pbCol,int nLength )
|
{
|
for(int i=0; i < nLength; i++)
|
{
|
m_pbNumericCol[i] = pbCol[i];
|
}
|
}
|