xtd 0.2.0
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] {
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++;
}
};
}
private:
button download_button;
};
auto main() -> int {
application::run(form1 {});
}
static void run()
Begins running a standard application message loop on the current thread, without a form.
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 void hide()
Hides a progress box in front.
static int32 maximum()
Gets the maximum value of the range of the progress dialog.
static bool skipped()
Check if the progress dialog is skipped.
static void show(const xtd::string &title)
Displays a progress box.
static int32 minimum()
Gets the minimum value of the range of the progress dialog.
static bool cancelled()
Check if the progress dialog is canceled.
static void update(const progress_box_options options)
Updates progress box.
static void sleep(int32 milliseconds_timeout)
Suspends the current thread for a specified time.
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
@ show_skip_button
Whether skip button is shown.
Definition progress_box_options.hpp:28
@ show_cancel_button
Whether cancel button is shown.
Definition progress_box_options.hpp:26
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:217
Contains classes that represent ASCII and Unicode character encodings; abstract base classes for conv...
Definition basic_string_builder.hpp:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8