MyDlgBar.cpp
上传用户:chenhai826
上传日期:2007-04-11
资源大小:72k
文件大小:2k
- // MyDlgBar.cpp : implementation file
- //
- #include "stdafx.h"
- #include "nopassword.h"
- #include "MyDlgBar.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMyDlgBar
- IMPLEMENT_DYNCREATE(CMyDlgBar, CDialogBar)
- CMyDlgBar::CMyDlgBar()
- {
- memset(m_Speed,0,100);
- m_Pos = 0;
- }
- CMyDlgBar::~CMyDlgBar()
- {
- }
- void CMyDlgBar::Add()
- {
- m_Speed[m_Pos] ++;
- }
- void CMyDlgBar::OnTimer(UINT nIDEvent)
- {
- static count = 0;
- if(count++ % CNPApp::m_Sampling)
- return;
- CClientDC dc(this);
- DrawWave(&dc);
- if(++m_Pos >= 100) m_Pos = 0;
- m_Speed[m_Pos] = 0;
- }
- void CMyDlgBar::DrawWave(CDC *pDC)
- {
- int i,count;
- CRect r1,r2;
- CBrush brush;
- GetClientRect(r1);
- GetDlgItem(IDC_THREAD)->GetWindowRect(r2);
- r1.left = r1.left + r2.Width() + 5;
- r1.top += 2;
- r1.bottom -= 2;
- r1.right -= 5;
- brush.CreateSolidBrush(RGB(0,255,0));
- pDC->FillRect(r1,&CBrush(RGB(0,0,0)));
- r2.bottom = r1.bottom;
- for(i=m_Pos,count = 0;count<100;i--,count++)
- {
- if(i == -1) i = 99;
- r2.left = r1.left + count*4+count;
- if(r2.left > r1.right) break;
- r2.right = r2.left + 4;
- r2.top = r2.bottom - (m_Speed[i]*r1.Height()/
- (CNPApp::m_Scale * CNPApp::m_Sampling));
- pDC->FillRect(r2,&brush);
- }
- CString msg; msg.Format("%.2f",m_Speed[m_Pos]/(float)CNPApp::m_Sampling);
- pDC->SetTextColor(RGB(255,255,0));
- pDC->SetBkMode(0);
- pDC->DrawText(msg,r1,DT_CENTER);
- }
- void CMyDlgBar::OnPaint()
- {
- CPaintDC dc(this);
- DrawWave(&dc);
- }
- void CMyDlgBar::OnCreate()
- {
- m_Timer = SetTimer(0,1000,NULL);
- }
- void CMyDlgBar::OnClose()
- {
- KillTimer(m_Timer);
- }
- BEGIN_MESSAGE_MAP(CMyDlgBar, CDialogBar)
- ON_WM_PAINT()
- ON_WM_TIMER()
- ON_WM_CREATE()
- ON_WM_CLOSE()
- END_MESSAGE_MAP()