home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC_Samples / cmnctrls / notifwdw.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  2.7 KB  |  100 lines

  1. // NotifySowCase.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "ctrldemo.h"
  6. #include "notifwdw.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CNotifyShowCase
  16.  
  17. CNotifyShowCase::CNotifyShowCase()
  18. {
  19.     m_totalLines = 200;  // use this default
  20. }
  21.  
  22. CNotifyShowCase::~CNotifyShowCase()
  23. {
  24. }
  25.  
  26. BEGIN_MESSAGE_MAP(CNotifyShowCase, CEdit)
  27.     //{{AFX_MSG_MAP(CNotifyShowCase)
  28.         // NOTE - the ClassWizard will add and remove mapping macros here.
  29.     //}}AFX_MSG_MAP
  30. END_MESSAGE_MAP()
  31.  
  32. notifDescrip CNotifyShowCase::m_rgNotifDescrip[NOTIFCOUNT] = 
  33. {
  34.         // list control notifications
  35.     {LVN_ITEMCHANGING, _T("LVN_ITEMCHANGING")},  
  36.     {LVN_ITEMCHANGED, _T("LVN_ITEMCHANGED")},
  37.     {LVN_INSERTITEM, _T("LVN_INSERTITEM")},
  38.     {LVN_DELETEITEM, _T("LVN_DELETEITEM")},
  39.     {LVN_DELETEALLITEMS, _T("LVN_DELETEALLITEMS")},
  40.     {LVN_BEGINLABELEDIT, _T("LVN_BEGINLABELEDIT")},
  41.     {LVN_ENDLABELEDIT, _T("LVN_ENDLABELEDIT")},
  42.     {LVN_BEGINDRAG, _T("LVN_BEGINDRAG")},
  43.     {LVN_BEGINRDRAG, _T("LVN_BEGINRDRAG")},
  44.     {LVN_COLUMNCLICK, _T("LVN_COLUMNCLICK")},
  45.     {LVN_GETDISPINFO, _T("LVN_GETDISPINFO")},
  46.     {LVN_SETDISPINFO, _T("LVN_SETDISPINFO")},
  47.         // tree control notifications
  48.     {TVN_ITEMEXPANDING, _T("TVN_ITEMEXPANDING")},
  49.     {TVN_BEGINLABELEDIT, _T("TVN_BEGINLABELEDIT")},
  50.     {TVN_ENDLABELEDIT, _T("TVN_ENDLABELEDIT")},
  51.     {TVN_SELCHANGING, _T("TVN_SELCHANGING")},
  52.     {TVN_SELCHANGED, _T("TVN_SELCHANGED")},
  53.     {TVN_GETDISPINFO, _T("TVN_GETDISPINFO")},
  54.     {TVN_SETDISPINFO, _T("TVN_SETDISPINFO")},
  55.     {TVN_BEGINDRAG, _T("TVN_BEGINDRAG")},
  56.     {TVN_KEYDOWN, _T("TVN_KEYDOWN")},
  57.     {TVN_DELETEITEM, _T("TVN_DELETEITEM")},
  58.     {TVN_ITEMEXPANDED, _T("TVN_ITEMEXPANDED")},
  59. };
  60.  
  61.  
  62. /////////////////////////////////////////////////////////////////////////////
  63. // CNotifyShowCase message handlers
  64. void CNotifyShowCase::AddLine(LPCTSTR lpsz)
  65. {
  66.     TCHAR    szt[50];
  67.     int        nLastChar;
  68.     int        cLines;
  69.  
  70.     if (GetLineCount() >= m_totalLines)
  71.     {
  72.         SetSel(0, LineLength(0), TRUE/*bNoScroll*/);  // select the first line
  73.         Clear();  // and remove it
  74.     }
  75.  
  76.     nLastChar = LineIndex((cLines = GetLineCount() - 1)) + LineLength(cLines);
  77.     _stprintf(szt, _T("%s\x0D\x0A"), lpsz);
  78.     SetSel(nLastChar, nLastChar, TRUE/*bNoScroll*/);
  79.     ReplaceSel(szt);
  80. }
  81.  
  82. void CNotifyShowCase::ShowNotification(UINT nCode)
  83. {
  84.     int i;
  85.  
  86.     for (i = 0; i < NOTIFCOUNT; i++)    // linear search for few items is OK
  87.         if (m_rgNotifDescrip[i].nCode == nCode)
  88.             break;
  89.  
  90.     if (i == NOTIFCOUNT)
  91.     {
  92.         TCHAR szt[30];
  93.  
  94.         _stprintf(szt, (LPCTSTR)CString((LPCTSTR)IDS_PRINT1), nCode);
  95.         AddLine(szt);
  96.     }
  97.     else
  98.         AddLine(m_rgNotifDescrip[i]. sztCodeName);
  99. }
  100.