www.gusucode.com > VC++屏幕取色程序源码升级版源码程序 > VC++屏幕取色程序源码升级版源码程序\code\SmallDlg.cpp

    // SmallDlg.cpp : implementation file
// download by http://www.NewXing.com

#include "stdafx.h"
#include "Page.h"
#include "SmallDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSmallDlg dialog


CSmallDlg::CSmallDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSmallDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSmallDlg)
	m_strRGB = _T("");
	//}}AFX_DATA_INIT
}


void CSmallDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSmallDlg)
	DDX_Text(pDX, IDC_RGB, m_strRGB);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSmallDlg, CDialog)
	//{{AFX_MSG_MAP(CSmallDlg)
	ON_WM_PAINT()
	ON_WM_MOUSEMOVE()
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSmallDlg message handlers

void CSmallDlg::OnPaint() 
{
	CPaintDC dc(this);
	CBrush br(m_color); 
	dc.FillRect(m_rect, &br);	

}

BOOL CSmallDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
 
	GetDlgItem(IDC_COLOR)->GetWindowRect(m_rect);
	m_rect.left+=3;
	m_rect.top +=3;
	m_rect.right -=3;
	m_rect.bottom -=3;
	ScreenToClient(&m_rect);
	
	LOGFONT lf;
	::ZeroMemory(&lf,sizeof(lf));  //API函数,它将一块内存清零
	lf.lfHeight =150;         
	lf.lfWeight =FW_BOLD;     //粗体,  FW_NORMAL常规
	lf.lfItalic =false;
	
	::lstrcpy(lf.lfFaceName ,"Times New Roman"); 
													 //::lstrcpy也是API函数,它将一个文本字符串从一个内存位置复制到另一个内存位置
													 //你也可以用C函数memset和 strcpy(实际上,应该调用 _tcscpy()而不是strcpy这样就能
													 //处理ANSI或Unicode  字符了),但是经常调用API函数减少了静态连接库的程序代码

                           
	m_font.CreatePointFontIndirect(&lf);
	GetDlgItem(IDC_RGB)->SetFont(&m_font);


	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}




void CSmallDlg::OnMouseMove(UINT nFlags, CPoint point) 
{

 
	

	CDialog::OnMouseMove(nFlags, point);
}

HBRUSH CSmallDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	

	if(pWnd->GetDlgCtrlID()==IDC_RGB)
		pDC->SetTextColor(RGB(71,171,71));
	// TODO: Return a different brush if the default is not desired
	return hbr;
}