// EditBox.cpp : implementation file // #include "stdafx.h" #include "cldprn32.h" #include "EditBox.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CStatusEditBox CStatusEditBox::CStatusEditBox() { } CStatusEditBox::~CStatusEditBox() { } BEGIN_MESSAGE_MAP(CStatusEditBox, CEdit) //{{AFX_MSG_MAP(CStatusEditBox) ON_WM_KEYDOWN() ON_CONTROL_REFLECT(EN_SETFOCUS, OnSetFocus) //}}AFX_MSG_MAP END_MESSAGE_MAP() void CStatusEditBox::AddStatus(const CString& sNewStatus) { CString sStatus; GetWindowText(sStatus); if (sStatus.GetLength()) { sStatus += TEXT("\r\n"); } SetWindowText(sStatus + sNewStatus); LineScroll(GetLineCount()); } ///////////////////////////////////////////////////////////////////////////// // CStatusEditBox message handlers void CStatusEditBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // Ctrl + A selects all the text in the edit box if (GetKeyState(VK_CONTROL) < 0 && nChar == 'A') { SetSel(0, -1); } CEdit::OnKeyDown(nChar, nRepCnt, nFlags); } void CStatusEditBox::OnSetFocus() { // Deselect all the text in the edit box SetSel(-1, 0); }