www.pudn.com > MyColorEdit.rar > ColorEdit.cpp
// ColorEdit.cpp : implementation file
//
#include "stdafx.h"
#include "MyColorEdit.h"
#include "ColorEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CColorEdit
CColorEdit::CColorEdit()
{
}
CColorEdit::~CColorEdit()
{
}
BEGIN_MESSAGE_MAP(CColorEdit, CEdit)
//{{AFX_MSG_MAP(CColorEdit)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CColorEdit message handlers
/*
void CColorEdit::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your message handler code here and/or call default
AfxMessageBox("ghhhhh");
CRect Rect = lpDrawItemStruct->rcItem;
CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
//获取当前字体的高度.
TEXTMETRIC tmFont;
int Height;
if (GetTextMetrics(pDC->GetSafeHdc(),&tmFont))
{
Height=tmFont.tmHeight;
}
for(int i=0;i<3;i++)
{
CRect *RedrawRect=new CRect(2,3+Height*i,8,9+(i+1)*Height);
pDC->FillSolidRect(RedrawRect, RGB(255,0,89));
}
CEdit::OnDrawItem(nIDCtl, lpDrawItemStruct);
}*/
void SetRectValue(CColorEdit &edit,const CRect &rect)
{
edit.RedrawRect=rect;
}
void CColorEdit::DrawEditCtrl( CRect &rect )
{
CClientDC dc(this);
//dc.FillSolidRect(lpRect, RGB(255,0,89));
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(RGB(25,456,5));
dc.SetBkColor(RGB(255,67,89));
dc.DrawText("fgggh", &rect, DT_LEFT );
}
void CColorEdit::OnPaint()
{
CPaintDC dc(this); // device context for painting
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(RGB(25,456,5));
dc.SetBkColor(RGB(255,67,89));
dc.DrawText("fgggh", &RedrawRect, DT_LEFT );
}