xtd 0.2.0
move_form.cpp

demonstrates the use of form event.

Windows

macOS

Gnome

#include <xtd/forms/application>
#include <xtd/forms/form>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
auto main() -> int {
auto main_form = form::create("Move form");
auto mouse_location = point::empty;
main_form.mouse_down += [&](object & sender, const mouse_event_args & e) {
mouse_location = e.location();
main_form.cursor(cursors::no_move_2d());
};
main_form.mouse_up += [&](object & sender, const mouse_event_args & e) {
mouse_location = point::empty;
main_form.cursor(cursors::default_cursor());
};
main_form.mouse_move += [&](object & sender, const mouse_event_args & e) {
if (mouse_location != point::empty) main_form.location(main_form.location() + e.location() - mouse_location);
};
application::run(main_form);
}
static void run()
Begins running a standard application message loop on the current thread, without a form.
static cursor default_cursor()
Gets the default cursor, which is usually an arrow cursor.
static cursor no_move_2d()
Gets the cursor that appears during wheel operations when the mouse is not moving,...
static form create()
A factory to create an xtd::forms::form.
Provides data for the xtd::forms::control::mouse_up, xtd::forms::control::mouse_down,...
Definition mouse_event_args.hpp:34
@ e
The E key.
Definition console_key.hpp:96
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:219
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
static const point empty
Represents a xtd::drawing::point that has xtd::drawing::point::x and xtd::drawing::point::y values se...
Definition point.hpp:59