Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.2 KiB

  1. // dlgsavep.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "eventrap.h"
  5. #include "dlgsavep.h"
  6. #ifdef _DEBUG
  7. #undef THIS_FILE
  8. static char BASED_CODE THIS_FILE[] = __FILE__;
  9. #endif
  10. /////////////////////////////////////////////////////////////////////////////
  11. // CDlgSaveProgress dialog
  12. CDlgSaveProgress::CDlgSaveProgress(BOOL bIsSaving)
  13. : CDialog(CDlgSaveProgress::IDD, NULL)
  14. {
  15. //{{AFX_DATA_INIT(CDlgSaveProgress)
  16. // NOTE: the ClassWizard will add member initialization here
  17. //}}AFX_DATA_INIT
  18. m_bWasCanceled = FALSE;
  19. m_bIsSaving = bIsSaving; // May indicate loading or saving.
  20. }
  21. void CDlgSaveProgress::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CDialog::DoDataExchange(pDX);
  24. //{{AFX_DATA_MAP(CDlgSaveProgress)
  25. DDX_Control(pDX, IDC_PROGRESS, m_progress);
  26. //}}AFX_DATA_MAP
  27. }
  28. BEGIN_MESSAGE_MAP(CDlgSaveProgress, CDialog)
  29. //{{AFX_MSG_MAP(CDlgSaveProgress)
  30. //}}AFX_MSG_MAP
  31. END_MESSAGE_MAP()
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CDlgSaveProgress message handlers
  34. void CDlgSaveProgress::OnCancel()
  35. {
  36. // TODO: Add extra cleanup here
  37. if (!m_bIsSaving) {
  38. // Cancel is currently enabled only for a load
  39. m_bWasCanceled = TRUE;
  40. CDialog::OnCancel();
  41. }
  42. }
  43. void CDlgSaveProgress::ProgressYield()
  44. {
  45. MSG msg;
  46. // Remove all available messages for any window that belongs to
  47. // the current application.
  48. while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
  49. // Translate and siapatch the given message if the window handle is
  50. // null or the given message is not for the modeless dialog box hwnd.
  51. if (!m_hWnd || !IsDialogMessage(&msg)) {
  52. TranslateMessage(&msg);
  53. DispatchMessage(&msg);
  54. }
  55. }
  56. }
  57. BOOL CDlgSaveProgress::StepProgress(LONG nSteps)
  58. {
  59. ProgressYield();
  60. while (--nSteps >= 0) {
  61. m_progress.StepIt();
  62. }
  63. return m_bWasCanceled;
  64. }
  65. void CDlgSaveProgress::SetStepCount(LONG nSteps)
  66. {
  67. #if _MFC_VER >= 0x0600
  68. m_progress.SetRange32(0, nSteps);
  69. #else
  70. m_progress.SetRange(0, nSteps);
  71. #endif
  72. m_progress.SetPos(0);
  73. m_progress.SetStep(1);
  74. }