CMyROEdit 自定义编辑框类

头文件: (MyROEdit.h)

#pragma once


// CMyROEdit

class CMyROEdit : public CEdit
{
	DECLARE_DYNAMIC(CMyROEdit)

public:
	CMyROEdit();
	virtual ~CMyROEdit();

protected:
	DECLARE_MESSAGE_MAP()
public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	afx_msg void OnEnSetfocus();
};

cpp文件:(MyROEdit.cpp)


// MyROEdit.cpp : implementation file
//

#include "stdafx.h"
#include "MyROEdit.h"


// CMyROEdit

IMPLEMENT_DYNAMIC(CMyROEdit, CEdit)

CMyROEdit::CMyROEdit()
{
}

CMyROEdit::~CMyROEdit()
{
}


BEGIN_MESSAGE_MAP(CMyROEdit, CEdit)
	ON_CONTROL_REFLECT(EN_SETFOCUS, &CMyROEdit::OnEnSetfocus)
END_MESSAGE_MAP()



// CMyROEdit message handlers



BOOL CMyROEdit::PreTranslateMessage(MSG* pMsg)
{
	if ( pMsg->message == WM_KEYDOWN ){
		if ( ( ( pMsg->wParam == 'c' ) || ( pMsg->wParam == 'C' ) ) && (GetKeyState( VK_CONTROL) < 0) ){
			return CEdit::PreTranslateMessage(pMsg);
		}else{
			return TRUE;
		}
	}
	if ( pMsg->message == WM_RBUTTONDBLCLK || pMsg->message == WM_RBUTTONDOWN || pMsg->message == WM_RBUTTONUP){
		return TRUE;
	}

	return CEdit::PreTranslateMessage(pMsg);
}

void CMyROEdit::OnEnSetfocus()
{
	HideCaret();
}


------------


测试可用, 给了自己一个自定义类的思路!

原文链接: CMyROEdit 自定义编辑框类 版权所有,转载时请注明出处,违者必究。
注明出处格式:流沙团 ( http://www.gyarmy.com/post-283.html )

发表评论

0则评论给“CMyROEdit 自定义编辑框类”