xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Go to the documentation of this file.
1 #pragma once
5 #include <any>
6 #include <chrono>
7 #include <thread>
8 #include "application.h"
9 #include "form.h"
10 #include "component.h"
12 #include "dialog_result.h"
13 #include "help_event_handler.h"
14 #include "iwin32_window.h"
17 struct __xtd_forms_common_dialog_closed_caller__;
21 namespace xtd {
23  namespace forms {
31  class common_dialog : public component {
32  public:
34  common_dialog() = default;
38  xtd::forms::dialog_result dialog_result() const {return dialog_result_;}
43  std::any tag() const {return tag_;}
48  tag_ = tag;
49  return*this;
50  }
55  virtual void reset() = 0;
61  auto form = form::active_form();
62  dialog_result_ = run_dialog(0) ? dialog_result::ok : dialog_result::cancel;
64  if (form.has_value()) form.value().get().activate();
65  return dialog_result_;
66  }
73  auto form = form::active_form();
74  dialog_result_ = run_dialog(owner.handle()) ? dialog_result::ok : dialog_result::cancel;
76  if (form.has_value()) form.value().get().activate();
77  return dialog_result_;
78  }
83  void show_sheet(const iwin32_window& owner) {
84  dialog_result_ = xtd::forms::dialog_result::none;
85  run_sheet(owner.handle());
86  }
92  show_sheet(owner);
93  while (dialog_result_ == xtd::forms::dialog_result::none) {
95  std::this_thread::sleep_for(std::chrono::milliseconds(100));
96  }
97  return dialog_result_;
98  }
108  protected:
110  friend struct ::__xtd_forms_common_dialog_closed_caller__;
117  dialog_result_ = e.dialog_result();
118  dialog_closed(*this, e);
119  }
124  virtual void on_help_request(help_event_args& e) {help_request(*this, e);}
129  virtual bool run_dialog(intptr_t hwnd_owner) = 0;
135  virtual void run_sheet(intptr_t hwnd_owner) = 0;
138  std::any tag_;
141  };
142  }
143 }
common_dialog & tag(const std::any &tag)
Sets an object that contains data about the control.
Definition: common_dialog.h:47
xtd::forms::dialog_result show_dialog()
Runs a common dialog box with a default owner.
Definition: common_dialog.h:60
Specifies identifiers to indicate the return value of a dialog box.
Definition: dialog_result.h:39
Nothing is returned from the dialog box. This means that the modal dialog continues running...
Contains xtd::forms::application class.
Contains xtd::forms::dialog_closed_event_handler dialog.
virtual bool run_dialog(intptr_t hwnd_owner)=0
When overridden in a derived class, specifies a common dialog box.
virtual void on_help_request(help_event_args &e)
Raises the common_dialog::help_request event.
Definition: common_dialog.h:124
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
event< common_dialog, help_event_handler > help_request
Occurs when the user clicks the Help button on a common dialog box.
Definition: common_dialog.h:102
xtd::forms::dialog_result dialog_result() const
Get async dialog_result result after dialog box is closing.
Definition: common_dialog.h:38
Contains xtd::forms::iwin32_window interface.
Provides an interface to expose Win32 HWND handles.
Definition: iwin32_window.h:19
event< common_dialog, dialog_closed_event_handler > dialog_closed
Occurs when the user close a common dialog box with dialog close button or other dialog buttons...
Definition: common_dialog.h:106
Initializes a new instance of the common_dialog class.
Represents a window or dialog box that makes up an application&#39;s user interface.
Definition: form.h:40
std::any tag() const
Gets an object that contains data about the control.
Definition: common_dialog.h:43
Represents an event.
Definition: event.h:21
virtual void on_dialog_closed(const dialog_closed_event_args &e)
Raises the common_dialog::dialog_close event.
Definition: common_dialog.h:116
Contains xtd::forms::form container.
virtual intptr_t handle() const =0
Gets the handle to the window represented by the implementer.
Contains xtd::forms::help_event_handler event handler.
xtd::forms::dialog_result show_sheet_dialog(const iwin32_window &owner)
Runs a common dialog box with the specified owner.
Definition: common_dialog.h:91
Contains xtd::forms::dialog_result enum class.
Indicates that all styles except allow_binary_specifier, allow_octal_specifier and allow_hex_specifie...
virtual void reset()=0
When overridden in a derived class, resets the properties of a common dialog box to their default val...
void activate()
Activates the form and gives it focus.
Provides data for a dialog closed event.
Definition: dialog_closed_event_args.h:17
Provides data for the control_added and control_removed events.
Definition: help_event_args.h:22
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
Contains xtd::forms::component class.
virtual forms::dialog_result dialog_result() const
Get the dialog_result contains the result when closing dialog. One of dialog_result enumerated values...
Definition: dialog_closed_event_args.h:27
The dialog box return value is Cancel (usually sent from a button labeled Cancel).
The dialog box return value is OK (usually sent from a button labeled OK).
xtd::forms::dialog_result show_dialog(const iwin32_window &owner)
Runs a common dialog box with the specified owner.
Definition: common_dialog.h:72
virtual void run_sheet(intptr_t hwnd_owner)=0
When overridden in a derived class, specifies a common dialog box.
Specifies the base class used for displaying dialog boxes on the screen.
Definition: common_dialog.h:31
static std::optional< std::reference_wrapper< form > > active_form()
Gets the currently active form for this application.
Definition: form.h:60
void show_sheet(const iwin32_window &owner)
Runs a common dialog box with the specified owner.
Definition: common_dialog.h:83
Provides the base implementation and enables object sharing between applications. ...
Definition: component.h:21
static void do_events()
Processes all Windows messages currently in the message queue.