home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / advanced / chatter / chatvw.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  2.2 KB  |  93 lines

  1. // chatvw.cpp : implementation of the CChatView class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "chatter.h"
  15.  
  16. #include "chatdoc.h"
  17. #include "chatvw.h"
  18.  
  19. #ifdef _DEBUG
  20. #undef THIS_FILE
  21. static char BASED_CODE THIS_FILE[] = __FILE__;
  22. #endif
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CChatView
  26.  
  27. IMPLEMENT_DYNCREATE(CChatView, CEditView)
  28.  
  29. BEGIN_MESSAGE_MAP(CChatView, CEditView)
  30.     //{{AFX_MSG_MAP(CChatView)
  31.     //}}AFX_MSG_MAP
  32. END_MESSAGE_MAP()
  33.  
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CChatView construction/destruction
  36.  
  37. CChatView::CChatView()
  38. {
  39. }
  40.  
  41. CChatView::~CChatView()
  42. {
  43. }
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CChatView drawing
  47.  
  48. void CChatView::OnDraw(CDC* pDC)
  49. {
  50.     CChatDoc* pDoc = GetDocument();
  51.     ASSERT_VALID(pDoc);
  52. }
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CChatView diagnostics
  56.  
  57. #ifdef _DEBUG
  58. void CChatView::AssertValid() const
  59. {
  60.     CEditView::AssertValid();
  61. }
  62.  
  63. void CChatView::Dump(CDumpContext& dc) const
  64. {
  65.     CEditView::Dump(dc);
  66. }
  67.  
  68. CChatDoc* CChatView::GetDocument() // non-debug version is inline
  69. {
  70.     return STATIC_DOWNCAST(CChatDoc, m_pDocument);
  71. }
  72. #endif //_DEBUG
  73.  
  74. /////////////////////////////////////////////////////////////////////////////
  75. // CChatView message handlers
  76.  
  77. BOOL CChatView::PreCreateWindow(CREATESTRUCT& cs)
  78. {
  79.     BOOL ret = CEditView::PreCreateWindow(cs);
  80.     cs.style = AFX_WS_DEFAULT_VIEW | WS_VSCROLL | ES_AUTOHSCROLL |
  81.         ES_AUTOVSCROLL | ES_MULTILINE | ES_NOHIDESEL | ES_READONLY;
  82.     return ret;
  83. }
  84.  
  85. void CChatView::Message(LPCTSTR lpszMessage)
  86. {
  87.     CString strTemp = lpszMessage;
  88.     strTemp += _T("\r\n");
  89.     int len = GetWindowTextLength();
  90.     GetEditCtrl().SetSel(len,len);
  91.     GetEditCtrl().ReplaceSel(strTemp);
  92. }
  93.