流沙团
CMyROEdit 自定义编辑框类
2017-9-25 流沙团


头文件: (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();
}







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







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

发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容