xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
progress_dialog.cpp

The following code example demonstrate the use of progress_dialog dialog.

Windows

macOS

Gnome

#include <thread>
#include <xtd/xtd>
using namespace std::literals;
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Progress dialog example");
button_process.auto_size(true);
button_process.location({10, 10});
button_process.parent(*this);
button_process.text("Process...");
button_process.click += [this] {
dialog.text("Process running");
dialog.show_skip_button(true);
dialog.show_remaining_time(true);
dialog.show_sheet_dialog(*this);
for (auto step = 1; step <= dialog.maximum(); ++step) {
dialog.value(step);
dialog.message(ustring::format("Step {}/{} ==> {}", dialog.value(), dialog.maximum(), dialog.skipped() ? "skipped" : "done"));
std::this_thread::sleep_for(100ms);
}
};
button_indeterminate_process.auto_size(true);
button_indeterminate_process.location({100, 10});
button_indeterminate_process.parent(*this);
button_indeterminate_process.text("Indeterminate process...");
button_indeterminate_process.click += [this] {
dialog.text("Indeterminate process running");
dialog.message("Click \"Cancel\" to abort");
dialog.marquee(true);
dialog.show_cancel_button(true);
dialog.show_elapsed_time(true);
dialog.show_sheet_dialog(*this);
while (!dialog.cancelled()) {
application::do_events();
std::this_thread::sleep_for(100ms);
}
};
}
private:
button button_process;
button button_indeterminate_process;
};
int main() {
application::run(form1());
}
Represents a Windows button control.
Definition: button.h:54
Represents a window or dialog box that makes up an application's user interface.
Definition: form.h:40
Represents a common dialog box that displays progress dialog.
Definition: progress_dialog.h:24
bool show_remaining_time() const
Gets a value that indicates whether remaining time is shown.
Definition: progress_dialog.h:137
const xtd::ustring & message() const
Gets the message text.
Definition: progress_dialog.h:92
bool skipped() const
Gets whether user has clicked on skip button.
bool show_elapsed_time() const
Gets a value that indicates whether elapsed time is shown.
Definition: progress_dialog.h:121
bool marquee() const
Gets a value that Indicates progress by continuously scrolling a block across a progress_bar in a mar...
Definition: progress_dialog.h:62
void show_sheet_dialog(const iwin32_window &owner)
Runs progress dialog box.
const xtd::ustring & text() const
Gets the dialog title.
Definition: progress_dialog.h:162
int32_t value()
Gets the current position of the progress bar.
Definition: progress_dialog.h:179
bool cancelled() const
Gets whether user has clicked on cancel button.
int32_t maximum()
Gets the maximum value of the range of the control.
Definition: progress_dialog.h:83
bool show_cancel_button() const
Gets a value that indicates whether cancel button is shown.
Definition: progress_dialog.h:113
bool show_skip_button() const
Gets a value that indicates whether skip button is shown.
Definition: progress_dialog.h:145
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17