108 lines
2.1 KiB
C++
Executable File
108 lines
2.1 KiB
C++
Executable File
// BmpProgress.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "gpsmain.h"
|
|
#include "BmpProgress.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CBmpProgress
|
|
|
|
CBmpProgress::CBmpProgress()
|
|
{
|
|
m_NormalID = 0;
|
|
m_DownID = 0;
|
|
|
|
m_Min = 0;
|
|
m_Max = 0;
|
|
}
|
|
|
|
CBmpProgress::~CBmpProgress()
|
|
{
|
|
m_BackDC.DeleteDC();
|
|
m_FrontDC.DeleteDC();
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CBmpProgress, CProgressCtrl)
|
|
//{{AFX_MSG_MAP(CBmpProgress)
|
|
ON_WM_PAINT()
|
|
ON_WM_ERASEBKGND()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CBmpProgress message handlers
|
|
|
|
void CBmpProgress::OnPaint()
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
// TODO: Add your message handler code here
|
|
if (m_NormalID && m_DownID)
|
|
{
|
|
dc.BitBlt(0,0,m_Pos,m_bmpSize.cy,&m_FrontDC,0,0,SRCCOPY);
|
|
dc.BitBlt(m_Pos,0,m_bmpSize.cx - m_Pos + 1,m_bmpSize.cy,&m_BackDC,m_Pos,0,SRCCOPY);
|
|
}
|
|
|
|
// Do not call CProgressCtrl::OnPaint() for painting messages
|
|
}
|
|
|
|
|
|
void CBmpProgress::SetPos(int nPos)
|
|
{
|
|
if (m_Max - m_Min > 0)
|
|
{
|
|
m_Pos = nPos * m_bmpSize.cx/(m_Max - m_Min);
|
|
Invalidate();
|
|
}
|
|
else
|
|
{
|
|
m_Max = m_Min = 0;
|
|
}
|
|
}
|
|
|
|
void CBmpProgress::SetRange(int nMin, int nMax)
|
|
{
|
|
m_Max = nMax;
|
|
m_Min = nMin;
|
|
}
|
|
|
|
BOOL CBmpProgress::OnEraseBkgnd(CDC* pDC)
|
|
{
|
|
// TODO: Add your message handler code here and/or call default
|
|
return FALSE;
|
|
//return CProgressCtrl::OnEraseBkgnd(pDC);
|
|
}
|
|
|
|
void CBmpProgress::LoadBitmap(int iNormal, int iDown)
|
|
{
|
|
m_NormalID = iNormal;
|
|
m_DownID = iDown;
|
|
|
|
CBitmap bmpBackground;
|
|
BITMAP bmpInfo;
|
|
bmpBackground.LoadBitmap(m_NormalID);
|
|
bmpBackground.GetBitmap(&bmpInfo);
|
|
|
|
m_BackDC.CreateCompatibleDC(NULL);
|
|
m_BackDC.SelectObject(&bmpBackground);
|
|
|
|
m_bmpSize.cx = bmpInfo.bmWidth;
|
|
m_bmpSize.cy = bmpInfo.bmHeight;
|
|
|
|
bmpBackground.DeleteObject();
|
|
|
|
bmpBackground.LoadBitmap(m_DownID);
|
|
m_FrontDC.CreateCompatibleDC(NULL);
|
|
m_FrontDC.SelectObject(&bmpBackground);
|
|
|
|
bmpBackground.DeleteObject();
|
|
}
|