demonstrates the use of wnd_proc method.
#include <xtd/drawing/system_brushes>
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/window_messages>
namespace wnd_proc_example {
class form1 :
public form {
public:
form1() {
client_size({300, 300});
text("form1");
font({
font().
font_family(), 18.0f, drawing::font_style::bold, drawing::graphics_unit::point, 0});
}
protected:
form::on_paint(e);
if (app_active) {
e.graphics().fill_rectangle(system_brushes::menu_highlight(), 10, 10, 280, 50);
e.graphics().draw_string(
"Application is active",
font(), system_brushes::control_text(), 10, 10);
} else {
e.graphics().fill_rectangle(system_brushes::control(), 10, 10, 280, 50);
e.graphics().draw_string(
"Application is inactive",
font(), system_brushes::control_text(), 10, 10);
}
}
void wnd_proc(
message& m)
override {
switch (m.msg()) {
app_active = (as<int>(m.wparam()) != 0);
invalidate();
break;
}
form::wnd_proc(m);
}
private:
bool app_active = true;
};
}
auto main() -> int {
application::run(wnd_proc_example::form1 {});
}
Defines a particular format for text, including font face, size, and style attributes....
Definition font.h:45
drawing::font_family font_family() const noexcept
Gets the xtd::drawing::font_family associated with this xtd::drawing::font.
constexpr xtd::uint32 WM_ACTIVATEAPP
Sent when a window belonging to a different application than the active window is about to be activat...
Definition window_messages.h:192
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition brush.h:18
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10