FlatEdit类(VC文本框重绘)

发表时间:2007-7-3 17:01:00

FlatEdit.h
========================================================
#pragma once
#include "afxwin.h"

class CFlatEdit : public CEdit
{
public:
 CFlatEdit(void);
public:
 ~CFlatEdit(void);
public:
 DECLARE_MESSAGE_MAP()
public:
 afx_msg void OnPaint();
};

===========================================================
FlatEdit.cpp
===========================================================
#include "stdafx.h"
#include "FlatEdit.h"

CFlatEdit::CFlatEdit(void)
{
}

CFlatEdit::~CFlatEdit(void)
{
}

BEGIN_MESSAGE_MAP(CFlatEdit, CEdit)
ON_WM_PAINT()
END_MESSAGE_MAP()

void CFlatEdit::OnPaint()
{
 CPaintDC dc(this);
 CPen pen;

 //slategray
 //#708090 #708090
 pen.CreatePen(PS_INSIDEFRAME | PS_SOLID, 1, #708090);
 RECT rect;
 
 GetClientRect(&rect);
 InflateRect(&rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
 
 //POINT p;
 //p.x = 5;
 //p.y = 5;
 //dc.RoundRect(&rect, p);

 CPen* oldPen = dc.SelectObject(&pen);
 dc.Rectangle(&rect);
 dc.SelectObject(oldPen);
 pen.DeleteObject();
}

你可能感兴趣的:(文本框)