请问CEdit类如何在只读模式下,设置背景颜色?
解决方案 »
- 8位位图可以是彩色图像吗?
- 如何计算进程、线程的ProcessorTimer、Privileged和User?
- MSChart初始值
- 用ShellAPI实现目录树
- 想学习用VC进行COM编程,不知有什么好书?最好多些实际的编程
- 给大家出几道高难度题
- select * from Name where address like '%abc%'如何在vc中加入%号呢!!
- 如何在vc++中编写扩展存储过程的,如何传参?急急急
- 关于打开文件夹的一个小问题,全天在线,解决问题,立即加分!
- 一个线程同步的问题
- 新手问题:在对话框程序中,若要定义一个全局变量(CString g_str),应在何处定义,如何定义?
- mfc中有没有直接10进制转16进制的函数
OnCtlColor()
//#include "stdafx.h"
#include "dlg.h"
#include "MyEdit.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CMyEditCMyEdit::CMyEdit()
{
m_bluecolor=RGB(0,0,255); // blue
m_bluebrush.CreateSolidBrush(m_bluecolor); // blue background
}CMyEdit::~CMyEdit()
{
}
BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
//{{AFX_MSG_MAP(CMyEdit)
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CMyEdit message handlersHBRUSH CMyEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
HBRUSH hbr; pDC->SetBkColor(m_bluecolor); // change the background color
hbr = (HBRUSH) m_bluebrush; // apply the brush
return hbr;
}-----------------------------------------
#if !defined(AFX_MYEDIT_H__26502F97_38CA_47F6_B986_B58C15E14BEE__INCLUDED_)
#define AFX_MYEDIT_H__26502F97_38CA_47F6_B986_B58C15E14BEE__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MyEdit.h : header file
///////////////////////////////////////////////////////////////////////////////
// CMyEdit windowclass CMyEdit : public CEdit
{
// Construction
public:
CMyEdit();// Attributes// Operations
public:// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyEdit)
//}}AFX_VIRTUAL// Implementation
public:
virtual ~CMyEdit(); // Generated message map functions
protected:
//{{AFX_MSG(CMyEdit)
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
//}}AFX_MSG DECLARE_MESSAGE_MAP()
private:
CBrush m_bluebrush;
COLORREF m_bluecolor;
};///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_MYEDIT_H__26502F97_38CA_47F6_B986_B58C15E14BEE__INCLUDED_)
www.vckbase.com第14期中有源码