xtd 0.2.0
Loading...
Searching...
No Matches
progress_box.cpp

demonstrates the use of xtd::forms::progress_box progress dialog.

Windows

macOS

Gnome

#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/form>
#include <xtd/forms/progress_box>
#include <xtd/threading/thread>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Progress box example");
client_size({ 400, 200 });
download_button.parent(*this)
.text("Download")
.location({ 10, 10 })
.size({ 150, 35 })
.click += [this] {
progress_box::show(*this, "Downloading", "Please wait...", 0, 0, 100, progress_box_options::show_cancel_button | progress_box_options::show_skip_button);
for (auto index = progress_box::minimum(); index <= progress_box::maximum(); ++index) {
threading::thread::sleep(100_ms); // Do some work...
progress_box::update(index, "Downloading", xtd::string::format("{}/{}", index, progress_box::maximum()));
if (progress_box::skipped()) index++;
if (progress_box::cancelled()) break;
}
progress_box::hide();
};
}
private:
button download_button;
};
auto main() -> int {
application::run(form1 {});
}
Represents a Windows button control.
Definition button.hpp:49
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
static basic_string format(const basic_string< char > &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.hpp:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10