home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / HISTORY.ZIP / Hacks / HistoryEditDemo / HistoryEdit.cpp next >
Encoding:
C/C++ Source or Header  |  1998-03-15  |  1.6 KB  |  82 lines

  1. /*
  2.  *  HistoryEdit.cpp
  3.  *
  4.  *  Description:
  5.  *    CHistoryEdit implementation
  6.  *
  7.  *    A CEdit subclass that allows you to display a text history
  8.  *    of events.
  9.  *
  10.  *  Author:
  11.  *    Ravi Bhavnani (ravib@datablast.net)
  12.  *
  13.  *  Revision History:
  14.  *    15 Mar 1998   rab   Original version
  15.  */
  16.  
  17. #include "stdafx.h"
  18. #include "HistoryEdit.h"
  19.  
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CHistoryEdit
  28.  
  29. CHistoryEdit::CHistoryEdit()
  30. {
  31.   m_bSelectable = FALSE;
  32. }
  33.  
  34. CHistoryEdit::~CHistoryEdit()
  35. {
  36. }
  37.  
  38. BEGIN_MESSAGE_MAP(CHistoryEdit, CEdit)
  39.     //{{AFX_MSG_MAP(CHistoryEdit)
  40.     ON_WM_SETFOCUS()
  41.     //}}AFX_MSG_MAP
  42. END_MESSAGE_MAP()
  43.  
  44. /////////////////////////////////////////////////////////////////////////////
  45. // CHistoryEdit operations
  46.  
  47. void CHistoryEdit::AppendString
  48.   (CString str)
  49. //
  50. //  Purpose:
  51. //    Appends a text string to the history buffer.
  52. //
  53. //  Returns:
  54. //    None.
  55. //
  56. {
  57. CString   strBuffer;    // current contents of edit control
  58.  
  59.   // Append string
  60.   GetWindowText (strBuffer);
  61.   if (!strBuffer.IsEmpty())
  62.      strBuffer += "\r\n";
  63.   strBuffer += str;
  64.   SetWindowText (strBuffer);
  65.  
  66.   // Scroll the edit control
  67.   LineScroll (GetLineCount(), 0);
  68. }
  69.  
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CHistoryEdit message handlers
  72.  
  73. void CHistoryEdit::OnSetFocus(CWnd* pOldWnd) 
  74. {
  75.   // Don't allow user to select text
  76.   if (m_bSelectable)
  77.      CEdit::OnSetFocus (pOldWnd);
  78.   else
  79.      pOldWnd->SetFocus();
  80. }
  81.  
  82. // End EditHistroy.cpp