TreePropertySheetAnimateWidget.cpp
上传用户:qifu0001
上传日期:2007-01-02
资源大小:52k
文件大小:2k
源码类别:

TreeView控件

开发平台:

Visual C++

  1. // TreePropertySheetAnimateWidget.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "TreePropertySheet.h"
  5. #include "TreePropertySheetAnimateWidget.h"
  6. #include <math.h>
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CTreePropertySheetAnimateWidget
  14. CTreePropertySheetAnimateWidget::CTreePropertySheetAnimateWidget(CWnd *pParentWnd,COLORREF clrLeft1,COLORREF clrLeft2,COLORREF clrRight1,COLORREF clrRight2,int nSteps)
  15. {
  16. Create(NULL,NULL,WS_CHILD,CRect(0,0,0,0),pParentWnd,(UINT)IDC_STATIC);
  17. m_clrLeft1 =clrLeft1;
  18. m_clrLeft2 =clrLeft2;
  19. m_clrRight1 =clrRight1;
  20. m_clrRight2 =clrRight2;
  21. m_nSteps =nSteps;
  22. m_nStep =0;
  23. }
  24. CTreePropertySheetAnimateWidget::~CTreePropertySheetAnimateWidget()
  25. {
  26. }
  27. BEGIN_MESSAGE_MAP(CTreePropertySheetAnimateWidget, CWnd)
  28. //{{AFX_MSG_MAP(CTreePropertySheetAnimateWidget)
  29. ON_WM_CREATE()
  30. ON_WM_TIMER()
  31. //}}AFX_MSG_MAP
  32. END_MESSAGE_MAP()
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CTreePropertySheetAnimateWidget message handlers
  35. int CTreePropertySheetAnimateWidget::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  36. {
  37. if (CWnd::OnCreate(lpCreateStruct) == -1)
  38. return -1;
  39. // TODO: Add your specialized creation code here
  40. SetTimer(0x1234,100,NULL);
  41. return 0;
  42. }
  43. void CTreePropertySheetAnimateWidget::OnTimer(UINT nIDEvent) 
  44. {
  45. // TODO: Add your message handler code here and/or call default
  46. if(nIDEvent==0x1234) {
  47. CTreePropertySheet *pSheet;
  48. pSheet =GetSheet(this);
  49. if(pSheet!=NULL) {
  50. COLORREF clrLeft,clrRight;
  51. float fVal=(float)(::GetTickCount());
  52. float nStep=(float)(sin((fVal/2000.0)*3.14159265)*128.0);
  53. nStep +=128;
  54. clrLeft =interpolate(m_clrLeft1,m_clrLeft2,(int)nStep,256);
  55. clrRight=interpolate(m_clrRight1,m_clrRight2,(int)nStep,256);
  56. m_nStep++;
  57. if(m_nStep==(2*m_nSteps))
  58. m_nStep=0;
  59. GetSheet(this)->m_clrCaptionLeft=clrLeft;
  60. GetSheet(this)->m_clrCaptionRight=clrRight;
  61. GetSheet(this)->InvalidateCaption(TRUE);
  62. GetSheet(this)->UpdateWindow();
  63. }
  64. }
  65. }