msgdlg.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/private/msgdlg.h
  3. // Purpose: helper functions used with native message dialog
  4. // Author: Rickard Westerlund
  5. // Created: 2010-07-12
  6. // Copyright: (c) 2010 wxWidgets team
  7. // Licence: wxWindows licence
  8. ///////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_MSW_PRIVATE_MSGDLG_H_
  10. #define _WX_MSW_PRIVATE_MSGDLG_H_
  11. #include "wx/msw/wrapcctl.h"
  12. #include "wx/scopedarray.h"
  13. // Macro to help identify if task dialogs are available: we rely on
  14. // TD_WARNING_ICON being defined in the headers for this as this symbol is used
  15. // by the task dialogs only. Also notice that task dialogs are available for
  16. // Unicode applications only.
  17. #if defined(TD_WARNING_ICON) && wxUSE_UNICODE
  18. #define wxHAS_MSW_TASKDIALOG
  19. #endif
  20. // Provides methods for creating a task dialog.
  21. namespace wxMSWMessageDialog
  22. {
  23. #ifdef wxHAS_MSW_TASKDIALOG
  24. class wxMSWTaskDialogConfig
  25. {
  26. public:
  27. enum { MAX_BUTTONS = 4 };
  28. wxMSWTaskDialogConfig()
  29. : buttons(new TASKDIALOG_BUTTON[MAX_BUTTONS]),
  30. parent(NULL),
  31. iconId(0),
  32. style(0),
  33. useCustomLabels(false)
  34. { }
  35. // initializes the object from a message dialog.
  36. wxMSWTaskDialogConfig(const wxMessageDialogBase& dlg);
  37. wxScopedArray<TASKDIALOG_BUTTON> buttons;
  38. wxWindow *parent;
  39. wxString caption;
  40. wxString message;
  41. wxString extendedMessage;
  42. long iconId;
  43. long style;
  44. bool useCustomLabels;
  45. wxString btnYesLabel;
  46. wxString btnNoLabel;
  47. wxString btnOKLabel;
  48. wxString btnCancelLabel;
  49. wxString btnHelpLabel;
  50. // Will create a task dialog with it's paremeters for it's creation
  51. // stored in the provided TASKDIALOGCONFIG parameter.
  52. // NOTE: The wxMSWTaskDialogConfig object needs to remain accessible
  53. // during the subsequent call to TaskDialogIndirect().
  54. void MSWCommonTaskDialogInit(TASKDIALOGCONFIG &tdc);
  55. // Used by MSWCommonTaskDialogInit() to add a regular button or a
  56. // button with a custom label if used.
  57. void AddTaskDialogButton(TASKDIALOGCONFIG &tdc,
  58. int btnCustomId,
  59. int btnCommonId,
  60. const wxString& customLabel);
  61. }; // class wxMSWTaskDialogConfig
  62. typedef HRESULT (WINAPI *TaskDialogIndirect_t)(const TASKDIALOGCONFIG *,
  63. int *, int *, BOOL *);
  64. // Return the pointer to TaskDialogIndirect(). This should only be called
  65. // if HasNativeTaskDialog() returned true and is normally guaranteed to
  66. // succeed in this case.
  67. TaskDialogIndirect_t GetTaskDialogIndirectFunc();
  68. #endif // wxHAS_MSW_TASKDIALOG
  69. // Check if the task dialog is available: this simply checks the OS version
  70. // as we know that it's only present in Vista and later.
  71. bool HasNativeTaskDialog();
  72. // Translates standard MSW button IDs like IDCANCEL into an equivalent
  73. // wx constant such as wxCANCEL.
  74. int MSWTranslateReturnCode(int msAns);
  75. }; // namespace wxMSWMessageDialog
  76. #endif // _WX_MSW_PRIVATE_MSGDLG_H_