www.pudn.com > Gh0st.rar > ColorEdit.cpp, change:2011-02-03,size:2222b


// ColorEdit.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "ColorEdit.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CColorEdit 
 
CColorEdit::CColorEdit() 
{ 
 m_text_color=GetSysColor(COLOR_WINDOWTEXT); 
 m_back_color=GetSysColor(COLOR_WINDOW); 
 m_brush.CreateSysColorBrush(HS_DIAGCROSS); 
} 
 
CColorEdit::~CColorEdit() 
{ 
} 
 
 
BEGIN_MESSAGE_MAP(CColorEdit, CEdit) 
 //{{AFX_MSG_MAP(CColorEdit) 
 ON_WM_CTLCOLOR_REFLECT() 
 //}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CColorEdit message handlers 
 
void CColorEdit::SetFontHeight(int Height) 
{ 
  LOGFONT tfont; 
  this->GetFont()->GetLogFont(&tfont); 
  tfont.lfHeight=Height; 
 
  m_font.Detach(); 
  m_font.CreateFontIndirect(&tfont); 
  this->SetFont(&m_font); 
} 
 
void CColorEdit::SetTextColor(COLORREF col) 
{ 
   m_text_color=col; 
} 
 
void CColorEdit::SetBackColor(COLORREF col) 
{ 
	m_back_color=col; 
} 
 
HBRUSH CColorEdit::CtlColor(CDC* pDC, UINT nCtlColor)  
{  
  pDC->SetTextColor(m_text_color);//文本颜色 
  pDC->SetBkColor(m_back_color); //文本背景色 
  return m_brush; 
} 
 
void CColorEdit::AppendText(LPCTSTR lpszString) 
{ 
   int len=this->GetWindowTextLength(); 
   this->SetSel(len,len); 
   this->ReplaceSel(lpszString); 
} 
 
void CColorEdit::SetBordText(BOOL Isbord) 
{ 
   LOGFONT tfont; 
   this->GetFont()->GetLogFont(&tfont); 
   if(Isbord) 
   { 
    tfont.lfWeight |=FW_BLACK; 
   } 
   else 
   { 
    tfont.lfWeight &= ~FW_BLACK; 
   } 
  m_font.Detach(); 
  m_font.CreateFontIndirect(&tfont); 
  this->SetFont(&m_font); 
} 
 
const CColorEdit& CColorEdit::operator=(const CString& stringSrc) 
{ 
   this->SetWindowText(stringSrc); 
   return *this; 
} 
 
const CColorEdit& CColorEdit::operator=(LPCSTR lpsz) 
{ 
   this->SetWindowText(CString(lpsz)); 
   return *this; 
} 
 
const CColorEdit& CColorEdit::operator=(LPCWSTR lpsz) 
{ 
   this->SetWindowText(CString(lpsz)); 
   return *this; 
} 
 
CString& CColorEdit::GetText() 
{ 
   this->GetWindowText(m_text); 
   return m_text; 
}