www.pudn.com > ListCtrl2014.rar > ListEdit.cpp, change:2014-05-09,size:2021b


// LlistEdit.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "XKListCtrl.h" 
#include "ListEdit.h" 
 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CListEdit 
 
CListEdit::CListEdit() 
{ 
	IsNumber =false; 
	color = RGB(0,0,0); 
} 
 
CListEdit::~CListEdit() 
{ 
} 
 
 
BEGIN_MESSAGE_MAP(CListEdit, CEdit) 
	//{{AFX_MSG_MAP(CListEdit) 
	ON_WM_CHAR() 
	ON_WM_CREATE() 
	ON_WM_CTLCOLOR() 
	ON_WM_KILLFOCUS() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CListEdit message handlers 
void CListEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)  
{ 
	// TODO: Add your message handler code here and/or call default 
	if (IsNumber) 
		if (((nChar <45)||(nChar>46)&&(nChar<48)||(nChar > 57))&& (nChar != 8)) 
		{ 
			nChar = 0; 
			Beep(100,100); 
		} 
		else 
			CEdit::OnChar(nChar, nRepCnt, nFlags); 
	else 
		CEdit::OnChar(nChar, nRepCnt, nFlags); 
} 
 
int CListEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)  
{ 
	if (CEdit::OnCreate(lpCreateStruct) == -1) 
		return -1; 
	 
	// TODO: Add your specialized creation code here 
	LOGFONT font; 
	font.lfHeight = -12; 
	font.lfWidth = 0; 
	font.lfItalic = 0; 
	font.lfStrikeOut = 0; 
	font.lfEscapement = 0; 
	font.lfUnderline = 0; 
	font.lfWeight = 400; 
	font.lfCharSet = 134; 
 
	_tcscpy(font.lfFaceName, _T("")); 
 
	m_font.DeleteObject(); 
	m_font.CreateFontIndirect(&font); 
	SetFont(&m_font); 
 
	return 0; 
} 
 
void CListEdit::SetEditTextColor(COLORREF Color) 
{ 
	color = Color; 
	Invalidate(); 
} 
 
HBRUSH CListEdit::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)  
{ 
	pDC->SetTextColor(color); 
	 
	CBrush brush(color); 
 
	return brush; 
} 
 
void CListEdit::OnKillFocus(CWnd* pNewWnd)  
{ 
	CEdit::OnKillFocus(pNewWnd); 
	 
	CXKListCtrl* temp = (CXKListCtrl*)GetParent(); 
 	if(temp) 
 	{ 
 		temp->DisposeEdit(); 
	} 
}