richeditctrlex.cpp
上传用户:swkcbjrc
上传日期:2016-04-02
资源大小:45277k
文件大小:2k
源码类别:

游戏

开发平台:

Visual C++

  1. // richeditctrlex.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "..gamehigh.h"
  5. #include "..includericheditctrlex.h"
  6. #include "macros.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CRichEditCtrlEx
  14. CRichEditCtrlEx::CRichEditCtrlEx()
  15. {
  16. }
  17. CRichEditCtrlEx::~CRichEditCtrlEx()
  18. {
  19. }
  20. BEGIN_MESSAGE_MAP(CRichEditCtrlEx, CRichEditCtrl)
  21. //{{AFX_MSG_MAP(CRichEditCtrlEx)
  22. // NOTE - the ClassWizard will add and remove mapping macros here.
  23. //}}AFX_MSG_MAP
  24. END_MESSAGE_MAP()
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CRichEditCtrlEx message handlers
  27. BOOL CRichEditCtrlEx::AppendText(LPCTSTR lpszText, COLORREF clrText)
  28. {
  29. ASSERT(lpszText);
  30. if(NULL == lpszText ||
  31. 0 == strlen(lpszText))
  32. {
  33. return FALSE;
  34. }
  35. SAFE_CHECKWND(this)
  36. {
  37. CHARFORMAT   CharFormat;
  38. memset(&CharFormat,0,sizeof(CHARFORMAT));
  39. CharFormat.cbSize=sizeof(CHARFORMAT);
  40. CharFormat.dwMask=CFM_COLOR;
  41. CharFormat.crTextColor=clrText;
  42. this->SetWordCharFormat(CharFormat);
  43. this->ReplaceSel(lpszText, FALSE);
  44. }
  45. return TRUE;
  46. }
  47. BOOL CRichEditCtrlEx::AppendText(LPCTSTR lpszText, int nHeight, COLORREF clrText)
  48. {
  49. ASSERT(lpszText);
  50. if(NULL == lpszText ||
  51. 0 == strlen(lpszText))
  52. {
  53. return FALSE;
  54. }
  55. SAFE_CHECKWND(this)
  56. {
  57. CHARFORMAT   CharFormat;
  58. memset(&CharFormat,0,sizeof(CHARFORMAT));
  59. CharFormat.cbSize =sizeof(CHARFORMAT);
  60. CharFormat.dwMask =CFM_COLOR | CFM_SIZE;
  61. CharFormat.crTextColor =clrText;
  62. CharFormat.yHeight =nHeight;
  63. this->SetWordCharFormat(CharFormat);
  64. this->ReplaceSel(lpszText, FALSE);
  65. }
  66. return TRUE;
  67. }