demonstrates some events received by form.
#include <xtd/xtd>
class something_ready_notifier : public object {
public:
something_ready_notifier() = default;
event<something_ready_notifier, event_handler> something_ready;
void on_something_ready() {
something_ready.invoke(*this, event_args::empty);
}
void notify_something_ready() {
synchronizer.begin_invoke({*this, &something_ready_notifier::on_something_ready});
}
protected:
form synchronizer;
};
class form1 : public form {
public:
static void main() {
application::run(form1 {});
}
form1() {
text(
"Send messages to form");
client_size({300, 300});
controls().push_back_range({button_send, list_box_messages});
static auto counter = 0;
list_box_messages.items().push_back(string::format("Something ready notified {} times", ++counter));
list_box_messages.selected_index(list_box_messages.items().size() - 1);
};
button_send.auto_size(true);
button_send.location({10, 10});
button_send.text("Send async notify something ready");
thread_pool::queue_user_work_item([&] {
thread::sleep(2_s);
notifier.notify_something_ready();
});
};
list_box_messages.location({10, 50});
list_box_messages.size({280, 240});
}
protected:
list_box list_box_messages;
something_ready_notifier notifier;
};
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:168
#define delegate_
The declaration of a delegate type is similar to a method signature. It has a return value and any nu...
Definition delegate.hpp:900
xtd::forms::style_sheets::control button
The buttton data allows you to specify the box of a button control.
Definition button.hpp:25