64,654
社区成员
发帖
与我相关
我的任务
分享
void CStudy1View::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CClientDC CDC(this);
TEXTMETRIC TM;
CDC.GetTextMetrics(&TM);
if(13==nChar)
{
CClientDC ccdc(this);
m_point.x=m_point.x;
m_point.y=m_point.y+TM.tmHeight;
m_str.Empty();
SetCaretPos(m_point);
}
else if(8==nChar)
{
COLORREF COL=CDC.SetTextColor(CDC.GetBkColor());
CDC.TextOut(m_point.x,m_point.y,m_str);
m_str=m_str.Left(m_str.GetLength()-1);
CDC.SetTextColor(COL);
}
else
{
m_str+=nChar;
}
CSize CS=CDC.GetTextExtent(m_str);
CPoint pt;
pt.y=m_point.y;
pt.x=m_point.x+CS.cx;
SetCaretPos(pt);
CDC.TextOut(m_point.x,m_point.y,m_str);
CView::OnChar(nChar, nRepCnt, nFlags);
}
这段代码中,我想不通那个删除文本的操作为什么要那样写,看不懂,我觉得如下