www.pudn.com > mfcopentree.rar > MyProgreeCtrl.cpp
// MyProgreeCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "mfcopen.h"
#include "MyProgreeCtrl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyProgreeCtrl
CMyProgreeCtrl::CMyProgreeCtrl()
{
m_nprog = 0;
}
CMyProgreeCtrl::~CMyProgreeCtrl()
{
}
BEGIN_MESSAGE_MAP(CMyProgreeCtrl, CProgressCtrl)
//{{AFX_MSG_MAP(CMyProgreeCtrl)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyProgreeCtrl message handlers
void CMyProgreeCtrl::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rc;
GetClientRect(&rc);
COLORREF col(RGB(0, 0, 255));
CRect rinv = rc;
rinv.right = int(rc.left+rc.Width()*m_nprog/10000.0f);
CPen pen(PS_SOLID, 1, col);
CBrush brush(RGB(0, 0, 255));
dc.SelectObject(&pen);
dc.SelectObject(&brush);
dc.Rectangle(rinv);
CString str;
str.Format("%d%%", m_nprog/100);
dc.SetTextColor(RGB(255, 255, 0));
dc.SetBkMode(TRANSPARENT);
dc.DrawText(str, &rc, DT_CENTER);
dc.GetTextExtent(str);
if(m_nprog>=10000)
{
::Sleep(1000);
ShowWindow(FALSE);
}
else
ShowWindow(TRUE);
// Do not call CProgressCtrl::OnPaint() for painting messages
}