9#include "dialog_intf.hpp"
10#include "../win32/win32.hpp"
11#include "../macros.hpp"
14#include <system_error>
16hi_export_module(hikogui.utility.dialog : impl);
18hi_export
namespace hi {
inline namespace v1 {
20hi_export
inline std::expected<dialog_button, std::error_code>
dialog(std::string_view title, std::string_view text,
dialog_button_mask button_mask)
noexcept
24 switch (button_mask) {
27 type = MB_APPLMODAL | MB_CANCELTRYCONTINUE | MB_ICONWARNING;
32 type = MB_APPLMODAL | MB_OK | MB_ICONINFORMATION;
37 type = MB_APPLMODAL | MB_OKCANCEL | MB_ICONEXCLAMATION;
42 type = MB_APPLMODAL | MB_OKCANCEL | MB_ICONWARNING;
47 type = MB_APPLMODAL | MB_YESNO | MB_ICONQUESTION;
52 type = MB_APPLMODAL | MB_YESNOCANCEL | MB_ICONQUESTION;
59 if (
auto const r = win32_MessageBox(
nullptr, text, title, type)) {
61 case IDABORT:
return dialog_button::cancel;
62 case IDCANCEL:
return dialog_button::cancel;
63 case IDCONTINUE:
return dialog_button::_continue;
64 case IDIGNORE:
return dialog_button::_continue;
65 case IDNO:
return dialog_button::no;
66 case IDOK:
return dialog_button::ok;
67 case IDRETRY:
return dialog_button::retry;
68 case IDTRYAGAIN:
return dialog_button::retry;
69 case IDYES:
return dialog_button::yes;
Rules for working with win32 headers.
The HikoGUI namespace.
Definition array_generic.hpp:20
std::expected< dialog_button, std::error_code > dialog(std::string_view title, std::string_view text, dialog_button_mask button_mask=dialog_button_mask::ok) noexcept
Display a modal dialog.
Definition dialog_win32_impl.hpp:20
dialog_button_mask
Definition dialog_intf.hpp:28
@ yes_no
A dialog box with "yes" and "no" buttons.
@ ok
A dialog box with just a "ok" button.
@ yes_no_cancel
A dialog box with "yes", "no" and "cancel" buttons.
@ retry_cancel
A dialog box with "retry" and "cancel" buttons.
@ ok_cancel
A dialog box with "ok" and "cancel" buttons.
@ cancel_retry_continue
A dialog box with "cancel", "retry" and "continue" buttons.
DOXYGEN BUG.
Definition algorithm_misc.hpp:20