MyDlgBar.cpp
上传用户:chenhai826
上传日期:2007-04-11
资源大小:72k
文件大小:2k
源码类别:

破解

开发平台:

Visual C++

  1. // MyDlgBar.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "nopassword.h"
  5. #include "MyDlgBar.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CMyDlgBar
  13. IMPLEMENT_DYNCREATE(CMyDlgBar, CDialogBar)
  14. CMyDlgBar::CMyDlgBar()
  15. {
  16. memset(m_Speed,0,100);
  17. m_Pos = 0;
  18. }
  19. CMyDlgBar::~CMyDlgBar()
  20. {
  21. }
  22. void CMyDlgBar::Add()
  23. {
  24. m_Speed[m_Pos] ++;
  25. }
  26. void CMyDlgBar::OnTimer(UINT nIDEvent)
  27. {
  28. static count = 0;
  29. if(count++ % CNPApp::m_Sampling)
  30. return;
  31. CClientDC dc(this);
  32. DrawWave(&dc);
  33. if(++m_Pos >= 100)  m_Pos = 0;
  34. m_Speed[m_Pos] = 0;
  35. }
  36. void CMyDlgBar::DrawWave(CDC *pDC)
  37. {
  38. int i,count;
  39. CRect r1,r2;
  40. CBrush brush;
  41. GetClientRect(r1);
  42. GetDlgItem(IDC_THREAD)->GetWindowRect(r2);
  43. r1.left = r1.left + r2.Width() + 5;
  44. r1.top += 2;
  45. r1.bottom -= 2;
  46. r1.right -= 5;
  47. brush.CreateSolidBrush(RGB(0,255,0));
  48. pDC->FillRect(r1,&CBrush(RGB(0,0,0)));
  49. r2.bottom = r1.bottom;
  50. for(i=m_Pos,count = 0;count<100;i--,count++)
  51. {
  52. if(i == -1) i = 99;
  53. r2.left = r1.left + count*4+count;
  54. if(r2.left > r1.right) break;
  55. r2.right = r2.left + 4;
  56. r2.top = r2.bottom - (m_Speed[i]*r1.Height()/
  57. (CNPApp::m_Scale * CNPApp::m_Sampling));
  58. pDC->FillRect(r2,&brush);
  59. }
  60. CString msg; msg.Format("%.2f",m_Speed[m_Pos]/(float)CNPApp::m_Sampling);
  61. pDC->SetTextColor(RGB(255,255,0));
  62. pDC->SetBkMode(0);
  63. pDC->DrawText(msg,r1,DT_CENTER);
  64. }
  65. void CMyDlgBar::OnPaint()
  66. {
  67. CPaintDC dc(this);
  68. DrawWave(&dc);
  69. }
  70. void CMyDlgBar::OnCreate()
  71. {
  72. m_Timer = SetTimer(0,1000,NULL);
  73. }
  74. void CMyDlgBar::OnClose()
  75. {
  76. KillTimer(m_Timer);
  77. }
  78. BEGIN_MESSAGE_MAP(CMyDlgBar, CDialogBar)
  79. ON_WM_PAINT()
  80. ON_WM_TIMER()
  81. ON_WM_CREATE()
  82. ON_WM_CLOSE()
  83. END_MESSAGE_MAP()