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

Shows how to create an application with xtd::forms::application::add_message_filter method.

Windows

macOS

Gnome

#include <xtd/xtd>
namespace application_add_message_filter_example {
class main_form : public form, public imessage_filter {
public:
main_form() {
text("Application add message filter example");
panel_.border_style(forms::border_style::groove);
skip_button_click_check_box_.auto_size(true);
click += delegate_ {diagnostics::debug::write_line(string::format("(form.click) x={}, y={}", mouse_position().x, mouse_position().y));};
button_.click += delegate_ {diagnostics::debug::write_line(string::format("(button.click) x={}, y={}", mouse_position().x, mouse_position().y));};
skip_button_click_check_box_.click += delegate_ {diagnostics::debug::write_line(string::format("(check_box.click) x={}, y={}", mouse_position().x, mouse_position().y));};
panel_.click += delegate_ {diagnostics::debug::write_line(string::format("(panel.click) x={}, y={}", mouse_position().x, mouse_position().y));};
}
private:
bool pre_filter_message(const message& message) {
// Uncomment following line to see all messages.
//diagnostics::debug::write_line(string::format("message=[{}], control=[{}]", message.to_string(), from_handle(message.hwnd).has_value() ? from_handle(message.hwnd).value().get().to_string() : "(null)"));
return skip_button_click_check_box_.checked() && message.msg == WM_LBUTTONDOWN && message.hwnd == button_.handle();
}
debug_form debug_form_;
panel panel_ = panel::create(*this, {10, 10}, {200, 100});
button button_ = button::create(panel_, "Click me", {10, 10});
check_box skip_button_click_check_box_ = check_box::create(panel_, "Skip button click event", check_state::unchecked, {10, 40});
};
}
int main() {
application::run(application_add_message_filter_example::main_form {});
}
static void add_message_filter(const imessage_filter &value)
Adds a message filter to monitor Windows messages as they are routed to their destinations.
#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:932