📄 lineedit.cpp
字号:
// LineEdit.cpp : implementation file
//
#include "stdafx.h"
#include "a1.h"
#include "LineEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLineEdit
CLineEdit::CLineEdit()
{
m_bCanEdit=false;
}
CLineEdit::~CLineEdit()
{
}
BEGIN_MESSAGE_MAP(CLineEdit, CEdit)
//{{AFX_MSG_MAP(CLineEdit)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLineEdit message handlers
//DEL void CLineEdit::OnPaint()
//DEL {
//DEL CPaintDC dc(this); // device context for painting
//DEL /*
//DEL CRect rect;
//DEL this->GetClientRect(&rect);
//DEL dc.FillSolidRect(&rect,RGB(254,254,254));
//DEL dc.MoveTo(rect.left,rect.bottom-8);
//DEL dc.LineTo(rect.right,rect.bottom-8);
//DEL
//DEL CString str;
//DEL this->GetWindowText(str);
//DEL CFont* font=this->GetFont();
//DEL dc.SelectObject(font);
//DEL dc.TextOut(0,0,str);*/
//DEL }
BOOL CLineEdit::PreTranslateMessage(MSG* pMsg)
{
if(pMsg!=NULL)
const HWND hwnd=pMsg->hwnd;
if(!m_bCanEdit)
if(pMsg->message==WM_KEYDOWN)
{
if(pMsg->wParam!=VK_ESCAPE)
pMsg->wParam=VK_CONTROL;
}
return CEdit::PreTranslateMessage(pMsg);
}
bool CLineEdit::SetCanEdit(bool canedit)
{
this->m_bCanEdit=canedit;
return m_bCanEdit;
}
//DEL HBRUSH CLineEdit::CtlColor(CDC* pDC, UINT nCtlColor)
//DEL {
//DEL pDC->SetBkColor(RGB(255,255,255));
//DEL
//DEL CRect rect;
//DEL this->GetClientRect(&rect);
//DEL pDC->FillSolidRect(&rect,RGB(255,255,255));
//DEL pDC->MoveTo(rect.left,rect.bottom-8);
//DEL pDC->LineTo(rect.right,rect.bottom-8);
//DEL // TODO: Return a non-NULL brush if the parent's handler should not be called
//DEL return (HBRUSH)m_brush;
//DEL }
void CLineEdit::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
this->GetClientRect(&rect);
dc.FillSolidRect(&rect,RGB(254,254,254));
dc.MoveTo(rect.left,rect.bottom-8);
dc.LineTo(rect.right,rect.bottom-8);
CString str;
this->GetWindowText(str);
CFont* font=this->GetFont();
dc.SelectObject(font);
dc.TextOut(0,0,str);
// Do not call CEdit::OnPaint() for painting messages
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -