DlgSetupStatusWnd.cpp
资源名称:GGBT.rar [点击查看]
上传用户:lds876
上传日期:2013-05-25
资源大小:567k
文件大小:3k
源码类别:
P2P编程
开发平台:
Visual C++
- // DlgSetupStatusWnd.cpp : implementation file
- //
- #include "stdafx.h"
- #include "testbt.h"
- #include "DlgSetupStatusWnd.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDlgSetupStatusWnd
- CDlgSetupStatusWnd::CDlgSetupStatusWnd()
- {
- }
- CDlgSetupStatusWnd::~CDlgSetupStatusWnd()
- {
- }
- BEGIN_MESSAGE_MAP(CDlgSetupStatusWnd, CWnd)
- //{{AFX_MSG_MAP(CDlgSetupStatusWnd)
- ON_WM_PAINT()
- ON_WM_CREATE()
- ON_WM_ERASEBKGND()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDlgSetupStatusWnd message handlers
- void CDlgSetupStatusWnd::SetStatusText(CString strText)
- {
- m_strText = strText;
- if (GetSafeHwnd()) Invalidate();
- }
- BOOL CDlgSetupStatusWnd::CreateEx(CWnd *pParent, CRect rc, UINT uID, long lParam)
- {
- return Create(0, 0, WS_CHILD|WS_BORDER|WS_VISIBLE, rc, pParent, uID);
- }
- int CDlgSetupStatusWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- m_font.CreateFont(-12, 0, 0, 0, 400, 0, 0, 0, 134, 0, 0, 0, 2, "宋体");
- // m_bmpBk.LoadBitmap(IDB_BITMAP_SETUP_DLG_STATUS);
- return 0;
- }
- BOOL CDlgSetupStatusWnd::OnEraseBkgnd(CDC* pDC)
- {
- /*
- CDC memdc;
- memdc.CreateCompatibleDC(pDC);
- memdc.SelectObject(m_bmpBk);
- CRect rc;
- pDC->GetClipBox(&rc);
- pDC->BitBlt(rc.left, rc.top, rc.Width(), rc.Height(),
- &memdc, rc.left, rc.top, SRCCOPY);
- //*/
- CRect rc;
- pDC->GetClipBox(&rc);
- DrawFace(RGB(255, 255, 255), RGB(233, 235, 254), rc, rc, pDC);
- return TRUE;
- // return CWnd::OnEraseBkgnd(pDC);
- }
- void CDlgSetupStatusWnd::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
- CRect rc;
- GetClientRect(rc);
- rc.DeflateRect(20, 0);
- CFont* pOldFont = dc.SelectObject(&m_font);
- dc.SetBkMode(TRANSPARENT);
- dc.SetTextColor(RGB(180,180, 180));
- dc.DrawText(m_strText, rc, DT_LEFT|DT_VCENTER|DT_SINGLELINE);
- dc.SelectObject(pOldFont);
- /*
- CString strText;
- strText.Format("DL:%s/s, UL:%s/s", FormatSize(m_lDownRate).data(), FormatSize(m_lUpRate).data());
- CFont* pOldFont = dc.SelectObject(&m_font);
- CRect rc;
- GetClientRect(rc);
- dc.SetBkMode(TRANSPARENT);
- dc.DrawText(strText, rc, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
- dc.SelectObject(pOldFont);
- //*/
- // Do not call CWnd::OnPaint() for painting messages
- }
- void CDlgSetupStatusWnd::DrawFace(COLORREF Top, COLORREF Bottom, CRect& rc, CRect CalRc, CDC* pDC)
- {
- if (!CalRc.Height())
- return;
- int R, G, B;
- R = (GetRValue(Top) - GetRValue(Bottom)) / CalRc.Height();
- G = (GetGValue(Top) - GetGValue(Bottom)) / CalRc.Height();
- B = (GetBValue(Top) - GetBValue(Bottom)) / CalRc.Height();
- int ColR = GetRValue(Top), ColG = GetGValue(Top), ColB = GetBValue(Top);
- COLORREF ColMax = Top > Bottom ? Top : Bottom;
- COLORREF ColMin = Top > Bottom ? Bottom: Top;
- for(int i=0; i<rc.Height(); i++)
- {
- ColR -= R;
- ColG -= G;
- ColB -= B;
- CPen Pen;
- Pen.CreatePen(PS_SOLID, 1, RGB(ColR, ColG, ColB));
- CPen* pOldPen = pDC->SelectObject(&Pen);
- // pDC->SelectObject(&Pen);
- pDC->MoveTo(rc.left, rc.top+i);
- pDC->LineTo(rc.right, rc.top+i);
- pDC->SelectObject(pOldPen);
- Pen.DeleteObject();
- }
- }