ChatClientView.cpp
资源名称:(vc).rar [点击查看]
上传用户:wpp2016
上传日期:2010-02-01
资源大小:1250k
文件大小:2k
源码类别:
Telnet服务器
开发平台:
Visual C++
- // ChatClientView.cpp : implementation file
- //
- #include "stdafx.h"
- #include "AnyServer.h"
- #include "ChatClientView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #include "AnyServerDoc.h"
- #include "ChatSock.h"
- /////////////////////////////////////////////////////////////////////////////
- // CChatClientView
- #include "ChatView.h"
- IMPLEMENT_DYNCREATE(CChatClientView, CEditView)
- CChatClientView::CChatClientView()
- {
- }
- CChatClientView::~CChatClientView()
- {
- }
- BEGIN_MESSAGE_MAP(CChatClientView, CEditView)
- //{{AFX_MSG_MAP(CChatClientView)
- ON_WM_KEYDOWN()
- ON_WM_KILLFOCUS()
- ON_WM_CTLCOLOR_REFLECT()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CChatClientView drawing
- void CChatClientView::OnDraw(CDC* pDC)
- {
- CAnyServerDoc* pDoc = (CAnyServerDoc*)GetDocument();
- }
- /////////////////////////////////////////////////////////////////////////////
- // CChatClientView diagnostics
- #ifdef _DEBUG
- void CChatClientView::AssertValid() const
- {
- CEditView::AssertValid();
- }
- void CChatClientView::Dump(CDumpContext& dc) const
- {
- CEditView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CChatClientView message handlers
- void CChatClientView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- if (nChar==VK_RETURN)
- {
- GetWindowText(((CAnyServerDoc*)GetDocument())->m_Client);
- TRY
- {
- *(((CAnyServerDoc*)GetDocument())->m_pConnect->m_pArchiveOut)<<((CAnyServerDoc*)GetDocument())->m_Client;
- ((CAnyServerDoc*)GetDocument())->m_pConnect->m_pArchiveOut->Flush();
- }
- CATCH(CFileException,e)
- {
- ((CAnyServerDoc*)GetDocument())->m_pConnect->m_pArchiveOut->Abort();
- AfxMessageBox("Send Message Error!");
- }
- END_CATCH
- }
- CEditView::OnKeyDown(nChar, nRepCnt, nFlags);
- }
- void CChatClientView::OnInitialUpdate()
- {
- CEditView::OnInitialUpdate();
- GetEditCtrl().LimitText(4096);
- }
- void CChatClientView::OnKillFocus(CWnd* pNewWnd)
- {
- CEditView::OnKillFocus(pNewWnd);
- if (pNewWnd!=NULL&&pNewWnd->IsKindOf(RUNTIME_CLASS(CChatView))) SetFocus();
- }
- HBRUSH CChatClientView::CtlColor(CDC* pDC, UINT nCtlColor)
- {
- HBRUSH hBrush=(HBRUSH)::GetStockObject(WHITE_BRUSH);
- // TODO: Return a non-NULL brush if the parent's handler should not be called
- return hBrush;
- }