ProgressDlg.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. FinalSun/FinalAlert 2 Mission Editor
  3. Copyright (C) 1999-2024 Electronic Arts, Inc.
  4. Authored by Matthias Wagner
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. */
  16. // ProgressDlg.cpp: Implementierungsdatei
  17. //
  18. #include "stdafx.h"
  19. #include "finalsun.h"
  20. #include "ProgressDlg.h"
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. /////////////////////////////////////////////////////////////////////////////
  27. // Dialogfeld CProgressDlg
  28. CProgressDlg::CProgressDlg(CString lpDescription, CWnd* pParent /*=NULL*/)
  29. : CDialog(CProgressDlg::IDD, pParent)
  30. {
  31. //{{AFX_DATA_INIT(CProgressDlg)
  32. m_Label = lpDescription;
  33. m_ProgLabel = _T("");
  34. //}}AFX_DATA_INIT
  35. m_bCancel=FALSE;
  36. Create(CProgressDlg::IDD, pParent);
  37. }
  38. void CProgressDlg::DoDataExchange(CDataExchange* pDX)
  39. {
  40. CDialog::DoDataExchange(pDX);
  41. //{{AFX_DATA_MAP(CProgressDlg)
  42. DDX_Control(pDX, IDC_PROGRESS, m_Progress);
  43. DDX_Text(pDX, IDC_LABEL, m_Label);
  44. DDX_Text(pDX, IDC_PROGLABEL, m_ProgLabel);
  45. //}}AFX_DATA_MAP
  46. }
  47. BEGIN_MESSAGE_MAP(CProgressDlg, CDialog)
  48. //{{AFX_MSG_MAP(CProgressDlg)
  49. //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP()
  51. /////////////////////////////////////////////////////////////////////////////
  52. // Behandlungsroutinen für Nachrichten CProgressDlg
  53. void CProgressDlg::SetRange(int min, int max)
  54. {
  55. m_Progress.SetRange32(min, max);
  56. }
  57. void CProgressDlg::SetPosition(int nPos)
  58. {
  59. m_Progress.SetPos(nPos);
  60. m_Progress.UpdateWindow();
  61. m_ProgLabel="Progress: ";
  62. float p=m_Progress.GetPos();
  63. int min,max;
  64. m_Progress.GetRange(min,max);
  65. if(max-min==0) return;
  66. float f=p/((float)(max-min));
  67. char c[50];
  68. itoa(f*100, c, 10);
  69. m_ProgLabel+=c;
  70. m_ProgLabel+=" %";
  71. UpdateData(FALSE);
  72. }
  73. void CProgressDlg::PostNcDestroy()
  74. {
  75. delete this;
  76. //CDialog::PostNcDestroy();
  77. }
  78. void CProgressDlg::OnCancel()
  79. {
  80. m_bCancel=TRUE;
  81. CDialog::OnCancel();
  82. }