www.pudn.com > subject_1_113294.rar > Sample.cpp, change:2002-05-25,size:1229b


// Sample.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "Paint.h" 
#include "Sample.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CSample 
 
CSample::CSample() 
{ 
	Mode=-1; 
	Color=RGB(0,0,0); 
} 
 
CSample::~CSample() 
{ 
} 
 
void CSample::SetStyle(int Mode,COLORREF Color) 
{ 
	this->Mode=Mode; 
	this->Color=Color; 
} 
 
BEGIN_MESSAGE_MAP(CSample, CStatic) 
	//{{AFX_MSG_MAP(CSample) 
	ON_WM_PAINT() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CSample message handlers 
 
void CSample::OnPaint()  
{ 
	CPaintDC dc(this); // device context for painting 
	 
	// TODO: Add your message handler code here 
	CBrush *Brush,*OldBrush; 
	if(Mode==-1) 
	{ 
		Brush->CreateSolidBrush(Color); 
		OldBrush=dc.SelectObject(Brush); 
	} 
	else 
	{ 
		Brush->CreateHatchBrush(Mode,Color); 
		OldBrush=dc.SelectObject(Brush); 
	} 
	CRect rect; 
	GetClientRect(&rect); 
	dc.Rectangle(rect); 
	dc.SelectObject(OldBrush); 
	delete Brush;	 
	 
	// Do not call CStatic::OnPaint() for painting messages 
}