ProgressWnd.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #if _MSC_VER > 1000
  2. #pragma once
  3. #endif // _MSC_VER > 1000
  4. class CProgressWnd : public CWnd
  5. {
  6. // Construction/Destruction
  7. public:
  8. CProgressWnd();
  9. CProgressWnd(CWnd* pParent, LPCTSTR pszTitle, BOOL bSmooth = FALSE);
  10. virtual ~CProgressWnd();
  11. BOOL Create(CWnd* pParent, LPCTSTR pszTitle, BOOL bSmooth = FALSE);
  12. BOOL GoModal(LPCTSTR pszTitle =_T("Progress"), BOOL bSmooth = FALSE);
  13. protected:
  14. void CommonConstruct();
  15. // Operations
  16. public:
  17. void SetRange(int nLower, int nUpper, int nStep = 1);
  18. // Set range and step size
  19. int OffsetPos(int nPos); // Same as CProgressCtrl
  20. int StepIt(); // "
  21. int SetStep(int nStep); // "
  22. int SetPos(int nPos); // "
  23. void SetText(LPCTSTR fmt, ...); // Set text in text area
  24. void Clear(); // Clear text, reset bar
  25. void Hide(); // Hide window
  26. void Show(); // Show window
  27. void HideCancel();
  28. void ShowCancel();
  29. int GetPos() const { return m_nPrevPos; }
  30. BOOL Cancelled() { return m_bCancelled; } // Was "Cancel" hit?
  31. void SetWindowSize(int nNumTextLines, int nWindowWidth = 390);
  32. void PeekAndPump(BOOL bCancelOnESCkey = TRUE); // Message pumping for modal operation
  33. void SetTitleText(CString csTitle);
  34. // Implementation
  35. protected:
  36. void GetPreviousSettings();
  37. void SaveCurrentSettings();
  38. protected:
  39. BOOL m_bCancelled;
  40. BOOL m_bModal;
  41. BOOL m_bPersistantPosition;
  42. int m_nPrevPos, m_nPrevPercent;
  43. int m_nStep;
  44. int m_nMaxValue, m_nMinValue;
  45. int m_nNumTextLines;
  46. CStatic m_Text;
  47. CProgressCtrl m_wndProgress;
  48. CButton m_CancelButton;
  49. CString m_strTitle,
  50. m_strCancelLabel;
  51. CFont m_font;
  52. // Overrides
  53. // ClassWizard generated virtual function overrides
  54. //{{AFX_VIRTUAL(CProgressWnd)
  55. public:
  56. virtual BOOL DestroyWindow();
  57. //}}AFX_VIRTUAL
  58. // Generated message map functions
  59. protected:
  60. //{{AFX_MSG(CProgressWnd)
  61. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  62. //}}AFX_MSG
  63. afx_msg void OnCancel();
  64. DECLARE_MESSAGE_MAP()
  65. };