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


// ModeSelect.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "Paint.h" 
#include "ModeSelect.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CModeSelect dialog 
 
 
CModeSelect::CModeSelect(CWnd* pParent /*=NULL*/) 
	: CDialog(CModeSelect::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CModeSelect) 
		// NOTE: the ClassWizard will add member initialization here	 
	CurSel=0; 
	//}}AFX_DATA_INIT 
} 
 
 
void CModeSelect::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CModeSelect) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CModeSelect, CDialog) 
	//{{AFX_MSG_MAP(CModeSelect) 
	ON_WM_PAINT() 
	ON_WM_LBUTTONDOWN() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CModeSelect message handlers 
 
BOOL CModeSelect::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	 
	// TODO: Add extra initialization here 
	 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void CModeSelect::OnPaint()  
{ 
	CPaintDC dc(this); // device context for painting 
	 
	// TODO: Add your message handler code here	 
	CPen *Pen=new CPen(); 
	CPen *OldPen; 
	Pen->CreatePen(PS_SOLID,2,RGB(255,0,0)); 
	OldPen=dc.SelectObject(Pen); 
	CBrush *br=new CBrush(); 
	br->CreateSolidBrush(NULL_BRUSH); 
	dc.SelectObject(br);	 
	dc.Rectangle(CurSel/3*50,CurSel%3*50,(CurSel/3+1)*50,(CurSel%3+1)*50); 
	dc.SelectObject(OldPen); 
	delete Pen; 
 
	for(int i=0;i<2;i++) 
		for(int j=0;j<3;j++) 
		{ 
			CBrush *Brush=new CBrush(); 
			CBrush *OldBrush; 
			Brush->CreateHatchBrush(i*3+j,RGB(0,0,0)); 
			OldBrush=dc.SelectObject(Brush); 
			dc.Rectangle(i*50+2,j*50+2,(i+1)*50-2,(j+1)*50-2); 
			delete Brush; 
		} 
 
	// Do not call CDialog::OnPaint() for painting messages 
} 
 
void CModeSelect::OnLButtonDown(UINT nFlags, CPoint point)  
{ 
	// TODO: Add your message handler code here and/or call default 
	if(point.x>100||point.y>150) 
		return; 
 
	int xi=point.x/50; 
	int yj=point.y/50; 
 
	CurSel=xi*3+yj; 
	Invalidate(true);	 
	CDialog::OnLButtonDown(nFlags, point); 
}