00001 #include "stdafx.h"
00002 #include "progressbar.h"
00003
00004
00005 #ifdef _DEBUG
00006 #define new DEBUG_NEW
00007 #undef THIS_FILE
00008 static char THIS_FILE[] = __FILE__;
00009 #endif
00010
00011
00012
00013 IMPLEMENT_DYNAMIC(CProgStatusBar, CStatusBar)
00014 BEGIN_MESSAGE_MAP(CProgStatusBar, CStatusBar)
00015 ON_WM_CREATE()
00016 ON_WM_SIZE()
00017 END_MESSAGE_MAP()
00018
00019 CProgStatusBar::CProgStatusBar()
00020 {
00021 }
00022
00023 CProgStatusBar::~CProgStatusBar()
00024 {
00025 }
00026
00028
00029
00030 int CProgStatusBar::OnCreate(LPCREATESTRUCT lpcs)
00031 {
00032 lpcs->style |= WS_CLIPCHILDREN;
00033 VERIFY(CStatusBar::OnCreate(lpcs) == 0);
00034 VERIFY(m_wndProgBar.Create(WS_CHILD, CRect(), this, 1));
00035 m_wndProgBar.SetRange(0,100);
00036 return 0;
00037 }
00038
00040
00041
00042
00043
00044 void CProgStatusBar::OnSize(UINT nType, int cx, int cy)
00045 {
00046 CStatusBar::OnSize(nType, cx, cy);
00047 CRect rc;
00048 GetItemRect(0, &rc);
00049 m_wndProgBar.MoveWindow(&rc,FALSE);
00050 }
00051
00053
00054
00055
00056
00057
00058
00059
00060
00061 void CProgStatusBar::OnProgress(UINT udPos)
00062 {
00063 CProgressCtrl& pc = m_wndProgBar;
00064 DWORD dwOldStyle = pc.GetStyle();
00065 DWORD dwNewStyle = dwOldStyle;
00066 if (udPos > 0)
00067
00068 dwNewStyle |= WS_VISIBLE;
00069 else
00070
00071 dwNewStyle &= ~WS_VISIBLE;
00072
00073 if (dwNewStyle != dwOldStyle) {
00074
00075 SetWindowText(NULL);
00076 SetWindowLong(pc.m_hWnd, GWL_STYLE, dwNewStyle);
00077 }
00078
00079
00080 pc.SetPos(udPos);
00081 if (udPos == 0)
00082
00083 GetParent()->PostMessage(WM_SETMESSAGESTRING, AFX_IDS_IDLEMESSAGE);
00084 }
00085
00086
00087 void CProgStatusBar::OnProgressMinMax(int minPos, int maxPos) {
00088 m_wndProgBar.SetPos(0);
00089 m_wndProgBar.SetRange(minPos, maxPos);
00090 }