RTRichEdit.cpp
上传用户:qhonly
上传日期:2013-06-10
资源大小:487k
文件大小:2k
源码类别:

界面编程

开发平台:

Visual C++

  1. // RTRichEdit.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "RTRichEdit.h"
  5. #include "RTDraw.h"
  6. // CRTRichEdit
  7. IMPLEMENT_DYNAMIC(CRTRichEdit, CRichEditCtrl)
  8. CRTRichEdit::CRTRichEdit()
  9. {
  10. }
  11. CRTRichEdit::~CRTRichEdit()
  12. {
  13. }
  14. CBitmap* CRTRichEdit::m_BackBitmap[5] = {NULL,NULL,NULL,NULL,NULL};
  15. UINT     CRTRichEdit::m_BackBitmapDrawMode[5]={0,0,0,0,0};
  16. BOOL     CRTRichEdit::m_bEnableSkin = TRUE;
  17. BEGIN_MESSAGE_MAP(CRTRichEdit, CRichEditCtrl)
  18. ON_WM_PAINT()
  19. ON_WM_ERASEBKGND()
  20. END_MESSAGE_MAP()
  21. // CRTRichEdit 消息处理程序
  22. void CRTRichEdit::OnPaint()
  23. {
  24. if(!m_bEnableSkin)return CRichEditCtrl::OnPaint();
  25. CRect rcWnd;
  26. GetClientRect(&rcWnd);
  27. CClientDC ptDC(this);
  28. CDC defDC;
  29. CMemDC memDC(&ptDC,rcWnd);
  30. defDC.CreateCompatibleDC(&ptDC);
  31. CBitmap  defBmp;
  32. CBitmap* defOld;
  33. defBmp.CreateCompatibleBitmap(&ptDC,rcWnd.Width(),rcWnd.Height());
  34. defOld = defDC.SelectObject(&defBmp);
  35. //DefWindowProc(WM_ERASEBKGND, (WPARAM)defDC.m_hDC , 0);
  36. DefWindowProc(WM_PAINT, (WPARAM)defDC.m_hDC , 0);
  37. CRTDraw::RTDrawBitmap(&memDC,&rcWnd,m_BackBitmap[BMP_BACK],m_BackBitmapDrawMode[BMP_BACK]);
  38. memDC.BitBlt(rcWnd.left,rcWnd.top,rcWnd.Width(),rcWnd.Height(),&defDC,rcWnd.left,rcWnd.top,SRCCOPY);
  39. //memDC.TransparentBlt(rcWnd.left,rcWnd.top,rcWnd.Width(),rcWnd.Height(),&defDC,rcWnd.left,rcWnd.top,rcWnd.Width(),rcWnd.Height(),GetSysColor(COLOR_WINDOW));
  40. CPaintDC dc(this);
  41. defDC.SelectObject(defOld);
  42. }
  43. BOOL CRTRichEdit::OnEraseBkgnd(CDC* pDC)
  44. {
  45.     if(!m_bEnableSkin)return CRichEditCtrl::OnEraseBkgnd(pDC);
  46. return TRUE;
  47. }
  48. void CRTRichEdit::PreSubclassWindow()
  49. {
  50. m_Container.Create(this);
  51. CRichEditCtrl::PreSubclassWindow();
  52. }
  53. void CRTRichEdit::SetBackBitmap(CBitmap* pBack[],UINT DrawMode[])
  54. {
  55. for(int i = 0; i < 5 ; i ++)
  56. {
  57. m_BackBitmap[i] = pBack[i];
  58. m_BackBitmapDrawMode[i] = DrawMode[i];
  59. }
  60. }
  61. void CRTRichEdit::EnableSkin(BOOL IsEnable)
  62. {
  63. m_bEnableSkin = IsEnable;
  64. }