1
0

ProgressDialog.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * ProgressDialog.h
  3. * ----------------
  4. * Purpose: An abortable, progress-indicating dialog, e.g. for showing conversion progress.
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #pragma once
  10. #include "openmpt/all/BuildSettings.hpp"
  11. OPENMPT_NAMESPACE_BEGIN
  12. class CProgressDialog : public CDialog
  13. {
  14. private:
  15. ITaskbarList3 *m_taskBarList = nullptr;
  16. uint64 m_min = 0, m_max = 0, m_shift = 0;
  17. const bool m_customDialog;
  18. public:
  19. bool m_abort = false;
  20. CProgressDialog(CWnd *parent = nullptr, UINT resourceID = 0);
  21. ~CProgressDialog();
  22. // Set the window title
  23. void SetTitle(const TCHAR *title);
  24. // Set the text on abort button
  25. void SetAbortText(const TCHAR *abort);
  26. // Set the text to be displayed along the progress bar.
  27. void SetText(const TCHAR *text);
  28. // Set the minimum and maximum value of the progress bar.
  29. void SetRange(uint64 min, uint64 max);
  30. // Set the current progress.
  31. void SetProgress(uint64 progress);
  32. // Show the progress in the task bar as well
  33. void EnableTaskbarProgress();
  34. // Process all queued Windows messages
  35. void ProcessMessages();
  36. // Run method for this dialog that must implement the action to be carried out - unless a custom resourceID was provided,
  37. // in which case the user is responsible for running the dialog and the implementation of this function may be a no-op.
  38. virtual void Run() = 0;
  39. protected:
  40. BOOL OnInitDialog() override;
  41. void OnCancel() override { m_abort = true; }
  42. DECLARE_MESSAGE_MAP()
  43. };
  44. OPENMPT_NAMESPACE_END