xtd 0.2.0
Loading...
Searching...
No Matches
xtd::forms::control Class Reference
Inheritance diagram for xtd::forms::control:
xtd::forms::component xtd::forms::iwin32_window xtd::iclonable xtd::icomparable< control > xtd::iequatable< control > xtd::isynchronize_invoke xtd::interface xtd::equality_operators< type_t, equatable_t > xtd::interface xtd::comparison_operators< type_t, comparable_t > xtd::interface xtd::interface xtd::interface xtd::object xtd::forms::animation xtd::forms::button_base xtd::forms::collapsible_panel xtd::forms::color_picker xtd::forms::date_time_picker xtd::forms::dot_matrix_display xtd::forms::font_picker xtd::forms::group_box xtd::forms::label xtd::forms::lcd_label xtd::forms::list_control xtd::forms::loading_indicator xtd::forms::month_calendar xtd::forms::picture_box xtd::forms::progress_bar xtd::forms::scroll_bar xtd::forms::scrollable_control xtd::forms::seven_segment_display xtd::forms::splitter xtd::forms::status_bar xtd::forms::tab_control xtd::forms::text_box_base xtd::forms::tool_bar xtd::forms::track_bar

Definition

Defines the base class for controls, which are components with visual representation.

Header
#include <xtd/forms/control>
Namespace
xtd::forms
Library
xtd.forms
Remarks
To create your own control class, inherit from the xtd::forms::user_control, xtd::forms::control classes, or from the other Windows Forms provided controls.
The xtd::forms::control class implements very basic functionality required by classes that display information to the user. It handles user input through the keyboard and pointing devices. It handles message routing and security. It defines the bounds of a control (its position and size), although it does not implement painting. It provides a window handle (hWnd).
Windows Forms controls use ambient properties so child controls can appear like their surrounding environment. An ambient property is a control property that, if not set, is retrieved from the xtd::forms::control::parent control. If the control does not have a parent, and the property is not set, the control attempts to determine the value of the ambient property through the site property. If the control is not sited, if the site does not support ambient properties, or if the property is not set on the ambient_properties, the control uses its own default values. Typically, an ambient property represents a characteristic of a control, such as xtd::forms::control::back_color, that is communicated to a child control. For example, a button will have the same xtd::forms::control::back_color as its parent form by default. Ambient properties provided by the control class include: xtd::forms::control::cursor, xtd::forms::control::font, xtd::forms::control::back_color, xtd::forms::control::fore_color, and xtd::forms::control::right_to_left.
The majority of the controls in the xtd::forms namespace use the underlying Windows common control as a base to build on.
Examples
The following code example demonstrates the use of control control.
#include <xtd/drawing/colors>
#include <xtd/forms/application>
#include <xtd/forms/control>
#include <xtd/forms/form>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
namespace control_example {
class form1 : public form {
public:
form1() {
text("Control example");
control1.parent(*this);
control1.cursor(cursors::hand());
control1.back_color(colors::spring_green());
control1.location({50, 50});
control1.size({100, 50});
control1.click += [&] {
control1.back_color(control1.back_color() == colors::spring_green() ? colors::orange_red() : colors::spring_green());
};
}
private:
control control1;
};
}
auto main() -> int {
application::run(control_example::form1 {});
}
colors for all the standard colors. This class cannot be inherited.
Definition colors.hpp:26
static void run()
Begins running a standard application message loop on the current thread, without a form.
Defines the base class for controls, which are components with visual representation.
Definition control.hpp:81
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
@ text
The xtd::forms::status_bar_panel displays text in the standard font.
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:11
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.hpp:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Examples
control.cpp, form_show.cpp, key_events.cpp, and owner_button.cpp.

Classes

class  control_collection
 Represents a collection of controls. More...
 

Public Aliases

using context_menu_ref = std::reference_wrapper< xtd::forms::context_menu >
 Represent an xtd::forms::context_menu reference.
 

Public Events

event< control, event_handlerauto_size_changed
 Occurs when the value of the xtd::forms::control::auto_size property changes.
 
event< control, event_handlerback_color_changed
 Occurs when the value of the xtd::forms::control::back_color property changes.
 
event< control, event_handlerbackground_image_changed
 Occurs when the value of the xtd::forms::control::background_image property changes.
 
event< control, event_handlerbackground_image_layout_changed
 Occurs when the value of the xtd::forms::control::background_image_layout property changes.
 
event< control, event_handlercontrol_appearance_changed
 Occurs when the value of the xtd::forms::control::control_appearance property changes.
 
event< control, event_handlerclick
 Occurs when the xtd::forms::control is clicked.
 
event< control, event_handlerclient_size_changed
 Occurs when the value of the xtd::forms::control::client_size property changes.
 
event< control, event_handlercursor_changed
 Occurs when the value of the xtd::forms::control::cursor property changes.
 
event< control, control_event_handlercontrol_added
 Occurs when a new xtd::forms::control::control is added to the xtd::forms::control::control_collection.
 
event< control, control_event_handlercontrol_removed
 Occurs when a new xtd::forms::control:: is removed to the xtd::forms::control::control_collection.
 
event< control, event_handlerdock_changed
 Occurs when the value of the xtd::forms::control::dock property changes.
 
event< control, event_handlerdouble_click
 Occurs when the xtd::forms::control is double-clicked.
 
event< control, event_handlergot_focus
 Occurs when the xtd::forms::control receives focus.
 
event< control, event_handlerhandle_created
 Occurs when a handle is created for the xtd::forms::control.
 
event< control, event_handlerhandle_destroyed
 Occurs when the control's handle is in the process of being destroyed.
 
event< control, event_handlerenabled_changed
 Occurs when the value of the xtd::forms::control::enabled property changes.
 
event< control, event_handlerfore_color_changed
 Occurs when the value of the xtd::forms::control::fore_color property changes.
 
event< control, event_handlerfont_changed
 Occurs when the value of the xtd::forms::control::font property changes.
 
event< control, help_event_handlerhelp_requested
 Occurs when the user requests help for a xtd::forms::control.
 
event< control, key_event_handlerkey_down
 Occurs when a key is pressed while the xtd::forms::control has focus.
 
event< control, key_press_event_handlerkey_press
 Occurs when a character. space or backspace key is pressed while the xtd::forms::control has focus.
 
event< control, key_event_handlerkey_up
 Occurs when a key is released while the xtd::forms::control has focus.
 
event< control, event_handlerlayout
 Occurs when a xtd::forms::control should reposition its child controls.
 
event< control, event_handlerlocation_changed
 Occurs when the value of the xtd::forms::control::location property changes.
 
event< control, event_handlerlost_focus
 Occurs when the xtd::forms::control loses focus.
 
event< control, mouse_event_handlermouse_click
 Occurs when the xtd::forms::control is clicked by the mouse.
 
event< control, mouse_event_handlermouse_double_click
 Occurs when the xtd::forms::control is double clicked by the mouse.
 
event< control, mouse_event_handlermouse_down
 Occurs when the mouse pointer is over the xtd::forms::control and a mouse button is pressed.
 
event< control, event_handlermouse_enter
 Occurs when the mouse pointer enters the xtd::forms::control.
 
event< control, mouse_event_handlermouse_horizontal_wheel
 Occurs when the mouse horizontal wheel moves while the xtd::forms::control has focus.
 
event< control, event_handlermouse_leave
 Occurs when the mouse pointer leaves the xtd::forms::control.
 
event< control, mouse_event_handlermouse_move
 Occurs when the mouse pointer is moved over the xtd::forms::control.
 
event< control, mouse_event_handlermouse_up
 Occurs when the mouse pointer is over the xtd::forms::control and a mouse button is released.
 
event< control, mouse_event_handlermouse_wheel
 Occurs when the mouse wheel moves while the xtd::forms::control has focus.
 
event< control, event_handlermove
 Occurs when the control is moved.
 
event< control, paint_event_handlerpaint
 Occurs when the xtd::forms::control is redrawn.
 
event< control, event_handlerparent_changed
 Occurs when the value of the xtd::forms::control::parent property changes.
 
event< control, event_handlerregion_changed
 Occurs when the value of the xtd::forms::control::region property changes.
 
event< control, event_handlerresize
 Occurs when the xtd::forms::control is resized.
 
event< control, event_handlerright_to_left_changed
 Occurs when the value of the xtd::forms::control::right_to_left property changes.
 
event< control, event_handlersize_changed
 Occurs when the value of the xtd::forms::control::size property changes.
 
event< control, event_handlerstyle_sheet_changed
 Occurs when the value of the xtd::forms::control::style_sheet property changes or when xtd::application::style_sheet property changes.
 
event< control, event_handlersystem_colors_changed
 Occurs when the xtd::drwing::system_colors changes.
 
event< control, event_handlertab_stop_changed
 Occurs when the xtd::forms::control::tab_stop property value changes.
 
event< control, event_handlertext_changed
 Occurs when the value of the xtd::forms::control::text property changes.
 
event< control, event_handlervisible_changed
 Occurs when the value of the xtd::forms::control::visible property changes.
 

Public Constructors

 control ()
 Initializes a new instance of the xtd::forms::control class with default settings.
 
 control (const xtd::string &text)
 Initializes a new instance of the xtd::forms::control class with specific text.
 
 control (const control &parent, const xtd::string &text)
 Initializes a new instance of the xtd::forms::control class as a child control, with specific text.
 
 control (const xtd::string &text, int32 left, int32 top, int32 width, int32 height)
 Initializes a new instance of the control class with specific text, size, and location.
 
 control (const control &parent, const xtd::string &text, int32 left, int32 top, int32 width, int32 height)
 Initializes a new instance of the xtd::forms::control class as a child control, with specific text, size, and location.
 

Public Properties

virtual anchor_styles anchor () const noexcept
 Gets the edges of the container to which a control is bound and determines how a control is resized with its parent.
 
virtual controlanchor (xtd::forms::anchor_styles anchor)
 Gets the edges of the container to which a control is bound and determines how a control is resized with its parent.
 
virtual drawing::point auto_scroll_point () const noexcept
 Gets where this control is scrolled to in scroll_control_into_view(control).
 
virtual bool auto_size () const noexcept
 Gets a value that indicates whether the control resizes based on its contents.
 
virtual controlauto_size (bool auto_size)
 Sets a value that indicates whether the control resizes based on its contents.
 
virtual drawing::color back_color () const noexcept
 Gets the background color for the control.
 
virtual controlback_color (const xtd::drawing::color &color)
 Sets the background color for the control.
 
virtual const xtd::drawing::imagebackground_image () const noexcept
 Gets the background image displayed in the control.
 
virtual controlbackground_image (const xtd::drawing::image &background_image)
 Sets the background image displayed in the control.
 
virtual xtd::forms::image_layout background_image_layout () const noexcept
 Gets the background image layout as defined in the xtd::forms::image_layout enumeration.
 
virtual controlbackground_image_layout (xtd::forms::image_layout background_image_layout)
 Sets the background image layout as defined in the xtd::forms::image_layout enumeration.
 
virtual int32 bottom () const noexcept
 Gets the distance, in pixels, between the bottom edge of the control and the top edge of its container's client area.
 
virtual drawing::rectangle bounds () const noexcept
 Gets the size and location of the control including its nonclient elements, in pixels, relative to the parent control.
 
virtual controlbounds (const xtd::drawing::rectangle &bounds)
 Sets the size and location of the control including its nonclient elements, in pixels, relative to the parent control.
 
virtual bool can_focus () const noexcept
 Gets a value indicating whether the control can receive focus.
 
virtual bool can_select () const noexcept
 Gets a value indicating whether the control can be selected.
 
bool can_raise_events () const noexcept override
 Determines if events can be raised on the control.
 
virtual const drawing::rectangleclient_rectangle () const noexcept
 Gets the rectangle that represents the client area of the control.
 
virtual const drawing::sizeclient_size () const noexcept
 Gets the height and width of the client area of the control.
 
virtual controlclient_size (const xtd::drawing::size &client_size)
 Sets the height and width of the client area of the control.
 
virtual xtd::string company_name () const noexcept
 Gets the name of the company or creator of the application containing the control.
 
virtual std::optional< context_menu_refcontext_menu () const noexcept
 Gets the xtd::forms::context_menu that is displayed in the control.
 
virtual controlcontext_menu (xtd::forms::context_menu &value)
 Sets the xtd::forms::context_menu that is displayed in the control.
 
virtual controlcontext_menu (std::nullptr_t)
 Sets the xtd::forms::context_menu that is displayed in the control.
 
virtual forms::control_appearance control_appearance () const noexcept
 Gets control appearance.
 
virtual controlcontrol_appearance (xtd::forms::control_appearance value)
 Sets control appearance.
 
virtual control_collectioncontrols () noexcept
 Gets the collection of controls contained within the control.
 
virtual const control_collectioncontrols () const noexcept
 Gets the collection of controls contained within the control.
 
virtual bool created () const noexcept
 Gets a value indicating whether the control has been created.
 
virtual forms::cursor cursor () const noexcept
 Gets the cursor that is displayed when the mouse pointer is over the control.
 
virtual controlcursor (const xtd::forms::cursor &cursor)
 Sets the cursor that is displayed when the mouse pointer is over the control.
 
virtual drawing::rectangle display_rectangle () const noexcept
 Gets the rectangle that represents the display area of the control.
 
virtual dock_style dock () const noexcept
 Gets which control borders are docked to its parent control and determines how a control is resized with its parent.
 
virtual controldock (xtd::forms::dock_style dock)
 Sets which control borders are docked to its parent control and determines how a control is resized with its parent.
 
virtual bool double_buffered () const noexcept
 Gets a value indicating whether this control should redraw its surface using a secondary buffer to reduce or prevent flicker.
 
virtual controldouble_buffered (bool double_buffered)
 Sets a value indicating whether this control should redraw its surface using a secondary buffer to reduce or prevent flicker.
 
virtual bool enabled () const noexcept
 Gets a value indicating whether the control can respond to user interaction.
 
virtual controlenabled (bool enabled)
 Sets a value indicating whether the control can respond to user interaction.
 
virtual bool focused () const noexcept
 Gets a value indicating whether the control has input focus.
 
virtual drawing::font font () const noexcept
 Gets the font of the text displayed by the control.
 
virtual controlfont (const xtd::drawing::font &font)
 Sets the font of the text displayed by the control.
 
virtual drawing::color fore_color () const noexcept
 Gets the foreground color of the control.
 
virtual controlfore_color (const xtd::drawing::color &color)
 Sets the foreground color of the control.
 
intptr handle () const override
 Gets the window handle that the control is bound to.
 
virtual int32 height () const noexcept
 Gets the height of the control.
 
virtual controlheight (int32 height)
 Sets the height of the control.
 
bool invoke_required () const noexcept override
 Gets a value indicating whether the caller must call an invoke method when making method calls to the control because the caller is on a different thread than the one the control was created on.
 
bool is_handle_created () const noexcept
 Gets a value indicating whether the control has a handle associated with it.
 
virtual int32 left () const noexcept
 Gets the distance, in pixels, between the left edge of the control and the left edge of its container's client area.
 
virtual controlleft (int32 left)
 Sets the distance, in pixels, between the left edge of the control and the left edge of its container's client area.
 
virtual drawing::point location () const noexcept
 Gets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.
 
virtual controllocation (const xtd::drawing::point &location)
 Sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.
 
virtual forms::padding margin () const noexcept
 Gets the space between controls.
 
virtual controlmargin (const xtd::forms::padding &margin)
 Sets the space between controls.
 
virtual const drawing::sizemaximum_client_size () const noexcept
 Gets the client size that is the upper limit that xtd::forms::control::get_preferred_size can specify.
 
virtual controlmaximum_client_size (const xtd::drawing::size &size)
 Sets the client size that is the upper limit that xtd::forms::control::get_preferred_size can specify.
 
virtual const drawing::sizemaximum_size () const noexcept
 Gets the size that is the upper limit that xtd::forms::control::get_preferred_size can specify.
 
virtual controlmaximum_size (const xtd::drawing::size &size)
 Sets the size that is the upper limit that xtd::forms::control::get_preferred_size can specify.
 
virtual const drawing::sizeminimum_client_size () const noexcept
 Gets the client size that is the lower limit that xtd::forms::control::get_preferred_size can specify.
 
virtual controlminimum_client_size (const xtd::drawing::size &size)
 Sets the client size that is the lower limit that xtd::forms::control::get_preferred_size can specify.
 
virtual const drawing::sizeminimum_size () const noexcept
 Gets the size that is the lower limit that xtd::forms::control::get_preferred_size can specify.
 
virtual controlminimum_size (const xtd::drawing::size &size)
 Sets the size that is the lower limit that xtd::forms::control::get_preferred_size can specify.
 
intptr native_handle () const noexcept
 Gets the native handle that the control is bound to.
 
virtual const xtd::stringname () const noexcept
 Gets the name of the control.
 
virtual controlname (const xtd::string &name)
 Sets the name of the control.
 
virtual forms::padding padding () const noexcept
 Gets padding within the control.
 
virtual controlpadding (const xtd::forms::padding &padding)
 Sets padding within the control.
 
virtual std::optional< control_refparent () const noexcept
 Gets the parent container of the control.
 
virtual controlparent (const control &parent)
 Sets the parent container of the control.
 
virtual controlparent (std::nullptr_t)
 Resets the parent container of the control.
 
virtual xtd::string product_name () const noexcept
 Gets the product name of the assembly containing the control.
 
bool recreating_handle () const noexcept
 Gets a value indicating whether the control is currently re-creating its handle.
 
virtual const xtd::drawing::regionregion () const noexcept
 Gets the window region associated with the control.
 
virtual controlregion (const xtd::drawing::region &value)
 Sets the window region associated with the control.
 
virtual int32 right () const noexcept
 Gets the distance, in pixels, between the right edge of the control and the left edge of its container's client area.
 
virtual xtd::forms::right_to_left right_to_left () const noexcept
 Gets a value indicating whether control's elements are aligned to support locales using right-to-left fonts.
 
virtual controlright_to_left (xtd::forms::right_to_left value)
 Sets a value indicating whether control's elements are aligned to support locales using right-to-left fonts.
 
virtual drawing::size size () const noexcept
 Gets the height and width of the control.
 
virtual controlsize (const drawing::size &size)
 Sets the height and width of the control.
 
virtual style_sheets::style_sheet style_sheet () const noexcept
 Gets the contol style sheet.
 
virtual controlstyle_sheet (const style_sheets::style_sheet &value)
 Sets the contol style sheet.
 
virtual controlstyle_sheet (const xtd::string &value)
 Sets the contol style sheet.
 
virtual controlstyle_sheet (std::nullptr_t)
 Resets the contol style sheet.
 
virtual bool tab_stop () const noexcept
 Gets a value indicating whether the user can give the focus to this control using the TAB key.
 
virtual controltab_stop (bool value)
 Sets a value indicating whether the user can give the focus to this control using the TAB key.
 
virtual std::any tag () const noexcept
 Gets the object that contains data about the control.
 
virtual controltag (std::any tag)
 Sets the object that contains data about the control.
 
virtual const xtd::stringtext () const noexcept
 Gets the text associated with this control.
 
virtual controltext (const xtd::string &text)
 Sets the text associated with this control.
 
intptr toolkit_handle () const noexcept
 Gets the toolkit handle that the control is bound to.
 
virtual int32 top () const noexcept
 Gets the distance, in pixels, between the top edge of the control and the top edge of its container's client area.
 
virtual controltop (int32 top)
 Sets the distance, in pixels, between the top edge of the control and the top edge of its container's client area.
 
virtual std::optional< control_reftop_level_control () const noexcept
 Gets the parent control that is not parented by another Windows Forms control. Typically, this is the outermost Form that the control is contained in.
 
virtual bool visible () const noexcept
 Gets a value indicating whether the control and all its child controls are displayed.
 
virtual controlvisible (bool visible)
 Sets a value indicating whether the control and all its child controls are displayed.
 
virtual int32 width () const noexcept
 Gets the width of the control.
 
virtual controlwidth (int32 width)
 Sets the width of the control.
 

Public Methods

xtd::async_result begin_invoke (delegate< void()> method) override
 Executes the specified delegate asynchronously on the thread that the control's underlying handle was created on.
 
xtd::async_result begin_invoke (delegate< void(std::vector< std::any >)> method, const std::vector< std::any > &args) override
 Executes the specified delegate asynchronously with the specified arguments, on the thread that the control's underlying handle was created on.
 
virtual void bring_to_front ()
 Brings the control to the front of the z-order.
 
int32 compare_to (const control &value) const noexcept override
 
void create_control ()
 Forces the creation of the visible control, including the creation of the handle and any visible child controls.
 
drawing::graphics create_graphics () const
 Creates the xtd::drawing::graphics for the control.
 
virtual void destroy_control ()
 Forces the destruction of the visible control, including the destruction of the handle and any visible child controls.
 
std::optional< object_refend_invoke (xtd::async_result async) override
 Retrieves the return value of the asynchronous operation represented by the async_result_invoke passed.
 
bool equals (const control &value) const noexcept override
 
bool focus ()
 Sets input focus to the control.
 
auto_size_mode get_auto_size_mode () const
 Gets a value indicating how a control will behave when its auto_size property is enabled.
 
size_t get_child_index (intptr child) const
 Retrieves the index of a control within the control collection.
 
size_t get_child_index (intptr child, bool &throw_exception) const
 Retrieves the index of the specified child control within the control collection, and optionally raises an exception if the specified control is not within the control collection.
 
virtual void hide ()
 Conceals the control from the user.
 
virtual void invalidate () const
 Invalidates the entire surface of the control and causes the control to be redrawn.
 
virtual void invalidate (bool invalidate_children) const
 Invalidates a specific region of the control and causes a paint message to be sent to the control. Optionally, invalidates the child controls assigned to the control.
 
virtual void invalidate (const drawing::rectangle &rect) const
 Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control.
 
virtual void invalidate (const drawing::rectangle &rect, bool invalidate_children) const
 Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control. Optionally, invalidates the child controls assigned to the control.
 
virtual void invalidate (const drawing::region &region) const
 Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control.
 
virtual void invalidate (const drawing::region &region, bool invalidate_children) const
 Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control. Optionally, invalidates the child controls assigned to the control.
 
std::optional< object_refinvoke (delegate< void()> method) override
 Executes the specified delegate on the thread that owns the control's underlying window handle.
 
std::optional< object_refinvoke (delegate< void(std::vector< std::any >)> method, const std::vector< std::any > &args) override
 Executes the specified delegate, on the thread that owns the control's underlying window handle, with the specified list of arguments.
 
std::optional< object_refinvoke (delegate< void(std::vector< std::any >)> method, std::any arg) override
 Executes the specified delegate, on the thread that owns the control's underlying window handle, with the specified list of arguments.
 
void perform_layout ()
 Forces the control to apply layout logic to all its child controls.
 
xtd::drawing::point point_to_client (const xtd::drawing::point &p) const
 Computes the location of the specified screen point into client coordinates.
 
xtd::drawing::point point_to_screen (const xtd::drawing::point &p) const
 Computes the location of the specified client point into screen coordinates.
 
bool post_message (intptr hwnd, int32 msg, intptr wparam, intptr lparam) const
 Places (posts) a message in the message queue with specified hwnd, message, wparam and lparam.
 
virtual bool pre_process_message (const xtd::forms::message &message)
 Preprocesses keyboard or input messages within the message loop before they are dispatched.
 
virtual void refresh () const
 Forces the control to invalidate its client area and immediately redraw itself and any child controls.
 
void resume_layout ()
 Resumes usual layout logic.
 
void resume_layout (bool perform_layout)
 Resumes usual layout logic, optionally forcing an immediate layout of pending layout requests.
 
intptr send_message (intptr hwnd, int32 msg, intptr wparam, intptr lparam) const
 Send a message with specified hwnd, message, wparam and lparam.
 
void set_auto_size_mode (auto_size_mode auto_size_mode)
 Sets a value indicating how a control will behave when its auto_size property is enabled.
 
void set_bounds (int32 x, int32 y, int32 width, int32 height)
 Sets the bounds of the control to the specified location and size.
 
void set_bounds (int32 x, int32 y, int32 width, int32 height, bounds_specified specified)
 Sets the specified bounds of the control to the specified location and size.
 
virtual void show ()
 Displays the control to the user.
 
void suspend_layout ()
 Temporarily suspends the layout logic for the control.
 
xtd::string to_string () const noexcept override
 Returns a string containing the name of the control, if any.
 
virtual void update () const
 Causes the control to redraw the invalidated regions within its client area.
 
virtual xtd::async_result begin_invoke (delegate< void()> method)=0
 Asynchronously executes the delegate on the thread that created this object.
 
virtual xtd::async_result begin_invoke (delegate< void(std::vector< std::any >)> value, const std::vector< std::any > &args)=0
 Asynchronously executes the delegate on the thread that created this object.
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
virtual std::optional< object_refinvoke (delegate< void()> value)=0
 Synchronously executes the delegate on the thread that created this object and marshals the call to the creating thread.
 
virtual std::optional< object_refinvoke (delegate< void(std::vector< std::any >)> method, const std::vector< std::any > &args)=0
 Synchronously executes the delegate on the thread that created this object and marshals the call to the creating thread.
 
virtual std::optional< object_refinvoke (delegate< void(std::vector< std::any >)> method, std::any arg)=0
 Synchronously executes the delegate on the thread that created this object and marshals the call to the creating thread.
 
template<typename object_a_t , typename object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 

Operators

controloperator<< (control &child)
 Add child control.
 
controloperator>> (control &child)
 Remove child control.
 

Public Static Properties

static bool check_for_illegal_cross_thread_calls () noexcept
 Gets a value indicating whether to catch calls on the wrong thread that access a xtd::forms::contrtol::handle property when an application is being debugged.
 
static void check_for_illegal_cross_thread_calls (bool value)
 Sets a value indicating whether to catch calls on the wrong thread that access a xtd::forms::contrtol::handle property when an application is being debugged.
 
static forms::keys modifier_keys () noexcept
 Gets a value indicating which of the modifier keys (SHIFT, CTRL, and ALT) is in a pressed state.
 
static forms::mouse_buttons mouse_buttons () noexcept
 Gets a value indicating which of the mouse buttons is in a pressed state.
 
static xtd::drawing::point mouse_position () noexcept
 Gets the position of the mouse cursor in screen coordinates.
 

Public Static Methods

static control create ()
 A factory to create a specified control.
 
static control create (const drawing::point &location)
 A factory to create a specified control with specified location.
 
static control create (const drawing::point &location, const drawing::size &size)
 A factory to create a specified control with specified location, and size.
 
static control create (const drawing::point &location, const drawing::size &size, const xtd::string &name)
 A factory to create a specified control with specified location, size, and name.
 
static control create (const control &paren)
 A factory to create a specified control with specified parent.
 
static control create (const control &parent, const drawing::point &location)
 A factory to create a specified control with specified parent, location, size, and name.
 
static control create (const control &parent, const drawing::point &location, const drawing::size &size)
 A factory to create a specified control with specified parent, location, and size.
 
static control create (const control &parent, const drawing::point &location, const drawing::size &size, const xtd::string &name)
 A factory to create a specified control with specified parent, location, size, and name.
 
template<typename control_t >
static control_t create ()
 A factory to create a specified control.
 
template<typename control_t >
static control_t create (const drawing::point &location)
 A factory to create a specified control with specified location.
 
template<typename control_t >
static control_t create (const drawing::point &location, const drawing::size &size)
 A factory to create a specified control with specified location, and size.
 
template<typename control_t >
static control_t create (const drawing::point &location, const drawing::size &size, const xtd::string &name)
 A factory to create a specified control with specified location, size, and name.
 
template<typename control_t >
static control_t create (const control &parent)
 A factory to create a specified control with specified parent.
 
template<typename control_t >
static control_t create (const control &parent, const drawing::point &location)
 A factory to create a specified control with specified parent, and location.
 
template<typename control_t >
static control_t create (const control &parent, const drawing::point &location, const drawing::size &size)
 A factory to create a specified control with specified parent, location, and size.
 
template<typename control_t >
static control_t create (const control &parent, const drawing::point &location, const drawing::size &size, const xtd::string &name)
 A factory to create a specified control with specified parent, location, size, and name.
 
template<typename control_t >
static control_t create (const xtd::string &text)
 A factory to create a specified control with specified text.
 
template<typename control_t >
static control_t create (const xtd::string &text, const drawing::point &location)
 A factory to create a specified control with specified text, and location.
 
template<typename control_t >
static control_t create (const xtd::string &text, const drawing::point &location, const drawing::size &size)
 A factory to create a specified control with specified text, location, and size.
 
template<typename control_t >
static control_t create (const xtd::string &text, const drawing::point &location, const drawing::size &size, const xtd::string &name)
 A factory to create a specified control with specified text, location,size, and name.
 
template<typename control_t >
static control_t create (const control &parent, const xtd::string &text)
 A factory to create a specified control with specified parent, and text.
 
template<typename control_t >
static control_t create (const control &parent, const xtd::string &text, const drawing::point &location)
 A factory to create a specified control with specified parent, text, and location.
 
template<typename control_t >
static control_t create (const control &parent, const xtd::string &text, const drawing::point &location, const drawing::size &size)
 A factory to create a specified control with specified parent, text, location, and size.
 
template<typename control_t >
static control_t create (const control &parent, const xtd::string &text, const drawing::point &location, const drawing::size &size, const xtd::string &name)
 A factory to create a specified control with specified parent, text, location, size, and name.
 
static std::optional< control_reffrom_child_handle (intptr handle)
 Retrieves the control that contains the specified handle.
 
static std::optional< control_reffrom_handle (intptr handle)
 Returns the control that is currently associated with the specified handle.
 

Protected Properties

xtd::forms::visual_styles::control_state control_state () const noexcept
 Gets state.
 
virtual forms::create_params create_params () const noexcept
 Gets the required creation parameters when the control handle is created.
 
virtual drawing::color default_back_color () const noexcept
 Gets the default background color of the control.
 
virtual forms::cursor default_cursor () const noexcept
 Gets the default cursor for the control.
 
virtual drawing::font default_font () const noexcept
 Gets the default font of the control.
 
virtual drawing::color default_fore_color () const noexcept
 Gets the default foreground color of the control.
 
virtual drawing::size default_size () const noexcept
 Gets the default size of the control.
 

Protected Methods

xtd::uptr< xtd::objectclone () const override
 Creates a new object that is a copy of the current instance.
 
virtual void create_handle ()
 Creates a handle for the control.
 
virtual void destroy_handle ()
 Destroys the handle associated with the control.
 
virtual void def_wnd_proc (message &message)
 Sends the specified message to the default window procedure.
 
bool get_style (control_styles flag) const noexcept
 Retrieves the value of the specified control style bit for the control.
 
virtual drawing::size measure_control () const noexcept
 Measure this control.
 
drawing::size measure_text () const noexcept
 Measure this control text.
 
virtual void on_auto_size_changed (const event_args &e)
 Raises the xtd::forms::control::auto_size_changed event.
 
virtual void on_back_color_changed (const event_args &e)
 Raises the xtd::forms::control::back_color_changed event.
 
virtual void on_background_image_changed (const event_args &e)
 Raises the xtd::forms::control::background_image_changed event.
 
virtual void on_background_image_layout_changed (const event_args &e)
 Raises the xtd::forms::control::background_image_layout_changed event.
 
virtual void on_control_appearance_changed (const event_args &e)
 Raises the control::control_appearance_changed event.
 
virtual void on_click (const event_args &e)
 Raises the xtd::forms::control::click event.
 
virtual void on_client_size_changed (const event_args &e)
 Raises the xtd::forms::control::client_size_changed event.
 
virtual void on_control_added (const control_event_args &e)
 Raises the xtd::forms::control::control_added event.
 
virtual void on_control_removed (const control_event_args &e)
 Raises the xtd::forms::control::control_removed event.
 
virtual void on_create_control ()
 Raises the xtd::forms::control::create_control event.
 
virtual void on_cursor_changed (const event_args &e)
 Raises the xtd::forms::control::cursor_changed event.
 
virtual void on_destroy_control ()
 Raises the xtd::forms::control::destroy_control event.
 
virtual void on_dock_changed (const event_args &e)
 Raises the xtd::forms::control::dock_changed event.
 
virtual void on_double_click (const event_args &e)
 Raises the xtd::forms::control::double_click event.
 
virtual void on_enabled_changed (const event_args &e)
 Raises the xtd::forms::control::enabled_changed event.
 
virtual void on_fore_color_changed (const event_args &e)
 Raises the xtd::forms::control::fore_color_changed event.
 
virtual void on_font_changed (const event_args &e)
 Raises the xtd::forms::control::font_changed event.
 
virtual void on_got_focus (const event_args &e)
 Raises the xtd::forms::control::got_focus event.
 
virtual void on_handle_created (const event_args &e)
 Raises the xtd::forms::control::handle_created event.
 
virtual void on_handle_destroyed (const event_args &e)
 Raises the xtd::forms::control::handle_destroyed event.
 
virtual void on_help_requested (help_event_args &e)
 Raises the xtd::forms::control::help_requested event.
 
virtual void on_key_down (key_event_args &e)
 Raises the xtd::forms::control::key_down event.
 
virtual void on_key_press (key_press_event_args &e)
 Raises the xtd::forms::control::key_press event.
 
virtual void on_key_up (key_event_args &e)
 Raises the xtd::forms::control::key_up event.
 
virtual void on_layout (const event_args &e)
 Raises the xtd::forms::control::layout event.
 
virtual void on_location_changed (const event_args &e)
 Raises the xtd::forms::control::location_changed event.
 
virtual void on_lost_focus (const event_args &e)
 Raises the xtd::forms::control::lost_focus event.
 
virtual void on_mouse_click (const mouse_event_args &e)
 Raises the xtd::forms::control::mouse_click event.
 
virtual void on_mouse_double_click (const mouse_event_args &e)
 Raises the xtd::forms::control::mouse_double_click event.
 
virtual void on_mouse_down (const mouse_event_args &e)
 Raises the xtd::forms::control::mouse_down event.
 
virtual void on_mouse_enter (const event_args &e)
 Raises the xtd::forms::control::mouse_enter event.
 
virtual void on_mouse_horizontal_wheel (const mouse_event_args &e)
 Raises the xtd::forms::control::mouse_horizontal_wheel event.
 
virtual void on_mouse_leave (const event_args &e)
 Raises the xtd::forms::control::mouse_leave event.
 
virtual void on_mouse_move (const mouse_event_args &e)
 Raises the xtd::forms::control::mouse_move event.
 
virtual void on_mouse_up (const mouse_event_args &e)
 Raises the xtd::forms::control::mouse_up event.
 
virtual void on_mouse_wheel (const mouse_event_args &e)
 Raises the xtd::forms::control::mouse_wheel event.
 
virtual void on_move (const event_args &e)
 Raises the xtd::forms::control::move event.
 
virtual void on_paint (paint_event_args &e)
 Raises the xtd::forms::control::paint event.
 
virtual void on_paint_background (paint_event_args &e)
 Paints the background of the xtd::forms::control.
 
virtual void on_parent_back_color_changed (const event_args &e)
 Raises the xtd::forms::control::parent_back_color_changed event.
 
virtual void on_parent_cursor_changed (const event_args &e)
 Raises the xtd::forms::control::parent_cursor_changed event.
 
virtual void on_parent_changed (const event_args &e)
 Raises the xtd::forms::control::parent_changed event.
 
virtual void on_parent_enabled_changed (const event_args &e)
 Raises the xtd::control::enabled_changed event when the xtd::control::enabled property value of the control's container changes..
 
virtual void on_parent_fore_color_changed (const event_args &e)
 Raises the xtd::forms::control::parent_fore_color_changed event.
 
virtual void on_parent_font_changed (const event_args &e)
 Raises the xtd::forms::control::parent_font_changed event.
 
virtual void on_resize (const event_args &e)
 Raises the xtd::forms::control::region event.
 
virtual void on_region_changed (const event_args &e)
 Raises the xtd::forms::control::region_changed event.
 
virtual void on_right_to_left_changed (const event_args &e)
 Raises the xtd::forms::control::right_to_left_changed event.
 
virtual void on_size_changed (const event_args &e)
 Raises the xtd::forms::control::size_changed event.
 
virtual void on_style_sheet_changed (const event_args &e)
 Raises the xtd::forms::control::style_sheet_changed event.
 
virtual void on_system_colors_changed (const event_args &e)
 Raises the control::system_colors_changed event.
 
virtual void on_tab_stop_changed (const event_args &e)
 Raises the xtd::forms::control::tab_stop_changed event.
 
virtual void on_text_changed (const event_args &e)
 Raises the xtd::forms::control::text_changed event.
 
virtual void on_visible_changed (const event_args &e)
 Raises the xtd::forms::control::visible_changed event.
 
void post_recreate_handle () noexcept
 
virtual void recreate_handle ()
 Forces the re-creation of the handle for the control.
 
virtual void set_bounds_core (int32 x, int32 y, int32 width, int32 height, bounds_specified specified)
 Performs the work of setting the specified bounds of this control.
 
void set_can_focus (bool value)
 Sets a value indicating whether the control can receive focus.
 
virtual void set_text (const xtd::string &text)
 Sets the text associated with this control.
 
virtual void set_client_size_core (int32 width, int32 height)
 Sets the size of the client area of the control.
 
void set_parent (intptr handle)
 Sets the parent handle of the control.
 
void set_style (control_styles flag, bool value)
 Sets a specified control_styles flag to either true or false.
 
virtual void wnd_proc (message &m)
 Processes Windows messages.
 

Protected Static Methods

static void set_mouse_buttons (forms::mouse_buttons value)
 Sets a value indicating which of the mouse buttons is in a pressed state.
 

Additional Inherited Members

- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<typename object_t >
xtd::uptr< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
- Public Member Functions inherited from xtd::forms::iwin32_window
- Public Member Functions inherited from xtd::iclonable
- Public Member Functions inherited from xtd::icomparable< control >
virtual int32 compare_to (const control &obj) const noexcept=0
 Compares the current instance with another object of the same type.
 
- Public Member Functions inherited from xtd::iequatable< control >
virtual bool equals (const control &) const noexcept=0
 Indicates whether the current object is equal to another object of the same type.
 
- Public Member Functions inherited from xtd::isynchronize_invoke
- Static Public Member Functions inherited from xtd::object
template<typename object_a_t , typename object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
template<typename object_a_t , typename object_b_t >
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 
- Protected Member Functions inherited from xtd::forms::component
 component ()
 Initialises a new instance of the component class.
 
bool design_mode () const noexcept
 Gets a value that indicates whether the component is currently in design mode.
 

Member Typedef Documentation

◆ context_menu_ref

Represent an xtd::forms::context_menu reference.

Constructor & Destructor Documentation

◆ control() [1/5]

xtd::forms::control::control ( )

Initializes a new instance of the xtd::forms::control class with default settings.

Remarks
The xtd::forms::control class is the base class for all controls used in a Windows Forms application. Because this class is not typically used to create an instance of the class, this constructor is typically not called directly but is instead called by a derived class.

◆ control() [2/5]

xtd::forms::control::control ( const xtd::string text)
explicit

Initializes a new instance of the xtd::forms::control class with specific text.

Parameters
textThe text displayed by the control.
Remarks
The xtd::forms::control class is the base class for all controls used in a Windows Forms application. Because this class is not typically used to create an instance of the class, this constructor is typically not called directly but is instead called by a derived class.
This version of the xtd::forms::control constructor sets the initial xtd::forms::control::text property value to the text parameter value.

◆ control() [3/5]

xtd::forms::control::control ( const control parent,
const xtd::string text 
)

Initializes a new instance of the xtd::forms::control class as a child control, with specific text.

Parameters
parentThe control to be the parent of the control.
textThe text displayed by the control.
Remarks
The xtd::forms::control class is the base class for all controls used in a Windows Forms application. Because this class is not typically used to create an instance of the class, this constructor is typically not called directly but is instead called by a derived class.
This version of the control constructor sets the initial xtd::forms::control::text property value to the text parameter value. The constructor also adds the control to the parent control's control::control_collection.

◆ control() [4/5]

xtd::forms::control::control ( const xtd::string text,
int32  left,
int32  top,
int32  width,
int32  height 
)

Initializes a new instance of the control class with specific text, size, and location.

Parameters
textThe text displayed by the control.
leftThe x position of the control, in pixels, from the left edge of the control's container. The value is assigned to the left property.
topThe y position of the control, in pixels, from the top edge of the control's container. The value is assigned to the top property.
widthThe width of the control, in pixels. The value is assigned to the width property.
heightThe height of the control, in pixels. The value is assigned to the height property.
Remarks
The control class is the base class for all controls used in a Windows Forms application. Because this class is not typically used to create an instance of the class, this constructor is typically not called directly but is instead called by a derived class.
This version of the control constructor sets the initial xtd::forms::control::text property value to the text parameter value. The initial xtd::forms::control::size and xtd::forms::control::location of the control are determined by the left, top, width and height parameter values.

◆ control() [5/5]

xtd::forms::control::control ( const control parent,
const xtd::string text,
int32  left,
int32  top,
int32  width,
int32  height 
)

Initializes a new instance of the xtd::forms::control class as a child control, with specific text, size, and location.

Parameters
parentThe control to be the parent of the control.
textThe text displayed by the control.
leftThe x position of the control, in pixels, from the left edge of the control's container. The value is assigned to the xtd::forms::control::left property.
topThe y position of the control, in pixels, from the top edge of the control's container. The value is assigned to the xtd::forms::control::top property.
widthThe width of the control, in pixels. The value is assigned to the xtd::forms::control::width property.
heightThe height of the control, in pixels. The value is assigned to the xtd::forms::control::height property.
Remarks
The xtd::forms::control class is the base class for all controls used in a Windows Forms application. Because this class is not typically used to create an instance of the class, this constructor is typically not called directly but is instead called by a derived class.
This version of the xtd::forms::control constructor sets the initial xtd::forms::control::text property value to the text parameter value. The constructor also adds the control to the xtd::forms::control::parent control's control::control_collection. The initial xtd::forms::control::size and xtd::forms::control::location of the control are determined by the left, top, width and height parameter values.

Member Function Documentation

◆ anchor() [1/2]

virtual anchor_styles xtd::forms::control::anchor ( ) const
virtualnoexcept

Gets the edges of the container to which a control is bound and determines how a control is resized with its parent.

Returns
A bitwise combination of the xtd::forms::anchor_styles values. The default is xtd::forms::anchor_styles::top and xtd::forms::anchor_styles::left.
Remarks
Use the xtd::forms::control::anchor property to define how a control is automatically resized as its parent control is resized. Anchoring a control to its parent control ensures that the anchored edges remain in the same position relative to the edges of the parent control when the parent control is resized.
You can anchor a control to one or more edges of its container. For example, if you have a form with a button whose xtd::forms::control::anchor property value is set to xtd::forms::canchor_styles::top and xtd::forms::anchor_styles::bottom, the button is stretched to maintain the anchored distance to the top and bottom edges of the form as the height of the form is increased.
Note
The xtd::forms::control::anchor and xtd::forms::control::dock properties are mutually exclusive. Only one can be set at a time, and the last one set takes precedence.
Notes to Inheritors
When overriding the xtd::forms::control::anchor property in a derived class, use the base class's xtd::forms::control::anchor property to extend the base implementation. Otherwise, you must provide all the implementation. You are not required to override both the get and set accessors of the xtd::forms::control::anchor property; you can override only one if needed.
Examples
demo.cpp, and wiggly.cpp.

◆ anchor() [2/2]

virtual control & xtd::forms::control::anchor ( xtd::forms::anchor_styles  anchor)
virtual

Gets the edges of the container to which a control is bound and determines how a control is resized with its parent.

Parameters
anchorA bitwise combination of the xtd::forms::anchor_styles values. The default is xtd::forms::anchor_styles::top and xtd::forms::anchor_styles::left.
Returns
Current control.
Remarks
Use the xtd::forms::control::anchor property to define how a control is automatically resized as its parent control is resized. Anchoring a control to its parent control ensures that the anchored edges remain in the same position relative to the edges of the parent control when the parent control is resized.
You can anchor a control to one or more edges of its container. For example, if you have a form with a button whose xtd::forms::control::anchor property value is set to xtd::forms::anchor_styles::top and xtd::forms::anchor_styles::bottom, the button is stretched to maintain the anchored distance to the top and bottom edges of the form as the height of the form is increased.
Note
The xtd::forms::control::anchor and xtd::forms::control::dock properties are mutually exclusive. Only one can be set at a time, and the last one set takes precedence.
Warning
Set the xtd::forms::control::anchor property after setting the xtd::forms::control::location and xtd::forms::control::size.
Notes to Inheritors
When overriding the anchor property in a derived class, use the base class's anchor property to extend the base implementation. Otherwise, you must provide all the implementation. You are not required to override both the get and set accessors of the anchor property; you can override only one if needed.

◆ auto_scroll_point()

virtual drawing::point xtd::forms::control::auto_scroll_point ( ) const
virtualnoexcept

Gets where this control is scrolled to in scroll_control_into_view(control).

Returns
A xtd::drawing::point specifying the scroll location. The default is the upper-left corner of the control.

◆ auto_size() [1/2]

virtual bool xtd::forms::control::auto_size ( ) const
virtualnoexcept

Gets a value that indicates whether the control resizes based on its contents.

Returns
true if enabled; otherwise, false.
Remarks
This property is not relevant for this class.

Reimplemented in xtd::forms::button_base, and xtd::forms::collapsible_panel.

Examples
change_color.cpp, clock.cpp, demo.cpp, and hello_world_emoticons.cpp.

◆ auto_size() [2/2]

virtual control & xtd::forms::control::auto_size ( bool  auto_size)
virtual

Sets a value that indicates whether the control resizes based on its contents.

Parameters
auto_sizetrue if enabled; otherwise, false.
Returns
Current control.
Remarks
This property is not relevant for this class.

Reimplemented in xtd::forms::button_base.

◆ back_color() [1/2]

virtual drawing::color xtd::forms::control::back_color ( ) const
virtualnoexcept

Gets the background color for the control.

Returns
A xtd::drawing::color that represents the background color of the control. The default is the value of the xtd::forms::control::default_back_color property.
Remarks
The xtd::forms::control::back_color property does not support transparent colors unless the xtd::forms::control_styles::supports_transparent_back_color value of xtd::forms::control_styles is set to true.
The xtd::forms::control::back_color property is an ambient property. An ambient property is a control property that, if not set, is retrieved from the parent control. For example, a button will have the same xtd::forms::control::back_color as its parent form by default. For more information about ambient properties, see the ambient_properties guide.
Examples
animation.cpp, clock.cpp, debug_form.cpp, demo.cpp, lcd_label2.cpp, lcd_label_with_dot_matrix.cpp, lcd_label_with_fourteen_segment.cpp, lcd_label_with_nine_segment.cpp, lcd_label_with_seven_segment.cpp, lcd_label_with_sixteen_segment.cpp, test_forms.cpp, and trace_form.cpp.

◆ back_color() [2/2]

virtual control & xtd::forms::control::back_color ( const xtd::drawing::color color)
virtual

Sets the background color for the control.

Parameters
colorA xtd::drawing::color that represents the background color of the control. The default is the value of the xtd::forms::control::default_back_color property.
Returns
Current control.
Remarks
The xtd::forms::control::back_color property does not support transparent colors unless the xtd::forms::control_styles::supports_transparent_back_color value of xtd::forms::control_styles is set to true.
The xtd::forms::control::back_color property is an ambient property. An ambient property is a control property that, if not set, is retrieved from the parent control. For example, a button will have the same xtd::forms::control::back_color as its parent form by default. For more information about ambient properties, see the ambient_properties guide.
Notes to Inheritors
When overriding the xtd::forms::control::back_color property in a derived class, use the base class's xtd::forms::control::back_color property to extend the base implementation. Otherwise, you must provide all the implementation. You are not required to override both the get and set accessors of the xtd::forms::control::back_color property; you can override only one if needed.

◆ background_image() [1/2]

virtual const xtd::drawing::image & xtd::forms::control::background_image ( ) const
virtualnoexcept

Gets the background image displayed in the control.

Returns
An xtd::drawing::image that represents the image to display in the background of the control.
Remarks
Use the background_image property to place a graphic image onto a control.

◆ background_image() [2/2]

virtual control & xtd::forms::control::background_image ( const xtd::drawing::image background_image)
virtual

Sets the background image displayed in the control.

Parameters
background_imageAn xtd::drawing::image that represents the image to display in the background of the control.
Returns
Current control.
Remarks
Use the background_image property to place a graphic image onto a control.

◆ background_image_layout() [1/2]

virtual xtd::forms::image_layout xtd::forms::control::background_image_layout ( ) const
virtualnoexcept

Gets the background image layout as defined in the xtd::forms::image_layout enumeration.

Returns
One of the values of xtd::forms::image_layout (center , none, stretch, tile, or zoom). tile is the default value.
Remarks
Use the background_image_layout property to specify the position and behavior of an image you have placed onto a control. background_image_layout takes effect only if the background_image property is set.
You can increase performance for large images if you set background_image_layout to something other than tile.

◆ background_image_layout() [2/2]

virtual control & xtd::forms::control::background_image_layout ( xtd::forms::image_layout  background_image_layout)
virtual

Sets the background image layout as defined in the xtd::forms::image_layout enumeration.

Parameters
background_image_layoutOne of the values of xtd::forms::image_layout (center , none, stretch, tile, or zoom). tile is the default value.
Returns
Current control.
Remarks
Use the background_image_layout property to specify the position and behavior of an image you have placed onto a control. background_image_layout takes effect only if the background_image property is set.
You can increase performance for large images if you set background_image_layout to something other than tile.

◆ bottom()

virtual int32 xtd::forms::control::bottom ( ) const
virtualnoexcept

Gets the distance, in pixels, between the bottom edge of the control and the top edge of its container's client area.

Returns
An int32 representing the distance, in pixels, between the bottom edge of the control and the top edge of its container's client area.
Remarks
The value of this property is equal to the sum of the top property value, and the height property value.
The bottom property is a read-only property. You can manipulate this property value by changing the value of the top or height properties or calling the set_bounds, set_bounds_core, update_bounds, or set_client_size_core methods.

◆ bounds() [1/2]

virtual drawing::rectangle xtd::forms::control::bounds ( ) const
virtualnoexcept

Gets the size and location of the control including its nonclient elements, in pixels, relative to the parent control.

Returns
A rectangle in pixels relative to the parent control that represents the size and location of the control including its nonclient elements.
Remarks
The bounds of the control include the nonclient elements such as scroll bars, borders, title bars, and menus.
Examples
line.cpp.

◆ bounds() [2/2]

virtual control & xtd::forms::control::bounds ( const xtd::drawing::rectangle bounds)
virtual

Sets the size and location of the control including its nonclient elements, in pixels, relative to the parent control.

Parameters
boundsA rectangle in pixels relative to the parent control that represents the size and location of the control including its nonclient elements.
Returns
Current control.
Remarks
The bounds of the control include the nonclient elements such as scroll bars, borders, title bars, and menus. The Set_bounds_core method is called to set the bounds property. The bounds property is not always changed through its set method so you should override the set_bounds_core method to ensure that your code is executed when the bounds property is set.

◆ can_focus()

virtual bool xtd::forms::control::can_focus ( ) const
virtualnoexcept

Gets a value indicating whether the control can receive focus.

Returns
true if the control can receive focus; otherwise, false.
Remarks
In order for a control to receive input focus, the control must have a handle assigned to it, and the visible and enabled properties must both be set to true for both the control and all its parent controls, and the control must be a form or the control's outermost parent must be a form.

◆ can_select()

virtual bool xtd::forms::control::can_select ( ) const
virtualnoexcept

Gets a value indicating whether the control can be selected.

Returns
true if the control can be selected; otherwise, false.s
Remarks
This property returns true if the electable value of control_styles is set to true, is contained in another control, the control itself is visible and enabled, and all its parent controls are visible and enabled.
The Windows Forms controls in the following list are not selectable and will return a value of false for the can_select property. controls derived from these controls are also not selectable.

◆ can_raise_events()

bool xtd::forms::control::can_raise_events ( ) const
overridevirtualnoexcept

Determines if events can be raised on the control.

Returns
true if the control can raise events; otherwise, false.

Reimplemented from xtd::forms::component.

◆ client_rectangle()

virtual const drawing::rectangle & xtd::forms::control::client_rectangle ( ) const
virtualnoexcept

Gets the rectangle that represents the client area of the control.

Returns
A rectangle that represents the client area of the control.
Remarks
The client area of a control is the bounds of the control, minus the nonclient elements such as scroll bars, borders, title bars, and menus.
Because client coordinates are relative to the upper-left corner of the client area of the control, the coordinates of the upper-left corner of the rectangle returned by this property are (0,0). You can use this property to obtain the size and coordinates of the client area of the control for tasks such as drawing on the surface of the control.

◆ client_size() [1/2]

virtual const drawing::size & xtd::forms::control::client_size ( ) const
virtualnoexcept

Gets the height and width of the client area of the control.

Returns
A size that represents the dimensions of the client area of the control.
Remarks
The client area of a control is the bounds of the control, minus the nonclient elements such as scroll bars, borders, title bars, and menus.
Examples
application_events.cpp, lcd_label2.cpp, lcd_label_with_dot_matrix.cpp, lcd_label_with_fourteen_segment.cpp, lcd_label_with_nine_segment.cpp, lcd_label_with_seven_segment.cpp, and lcd_label_with_sixteen_segment.cpp.

◆ client_size() [2/2]

virtual control & xtd::forms::control::client_size ( const xtd::drawing::size client_size)
virtual

Sets the height and width of the client area of the control.

Parameters
client_sizeA size that represents the dimensions of the client area of the control.
Returns
Current control.
Remarks
The client area of a control is the bounds of the control, minus the nonclient elements such as scroll bars, borders, title bars, and menus. The set_client_size_core method is called to set the client_size property. The client_size property is not always changed through its set method so you should override the set_client_size_core method to ensure that your code is executed when the client_size property is set.

◆ company_name()

virtual xtd::string xtd::forms::control::company_name ( ) const
virtualnoexcept

Gets the name of the company or creator of the application containing the control.

Returns
The company name or creator of the application containing the control.

◆ context_menu() [1/3]

virtual std::optional< context_menu_ref > xtd::forms::control::context_menu ( ) const
virtualnoexcept

Gets the xtd::forms::context_menu that is displayed in the control.

Returns
A xtd::forms::context_menu that represents the context menu to display in the control.

◆ context_menu() [2/3]

virtual control & xtd::forms::control::context_menu ( xtd::forms::context_menu value)
virtual

Sets the xtd::forms::context_menu that is displayed in the control.

Parameters
valueA xtd::forms::context_menu that represents the context menu to display in the control.
Returns
Current control.

◆ context_menu() [3/3]

virtual control & xtd::forms::control::context_menu ( std::nullptr_t  )
virtual

Sets the xtd::forms::context_menu that is displayed in the control.

Parameters
valueA xtd::forms::context_menu that represents the context menu to display in the control.
Returns
Current control.

◆ control_appearance() [1/2]

virtual forms::control_appearance xtd::forms::control::control_appearance ( ) const
virtualnoexcept

Gets control appearance.

Returns
One of xtd::forms::control_appearance values. THe default is xtd::forms::control_appearance::standard.
Remarks
The control appearance determine how the control is drawed :
  • xtd::control::control_appearance::standard : The appearance of the control is determined by current theme of xtd.
  • xtd::control::control_appearance::system : The appearance of the control is determined by the user's operating system.

Reimplemented in xtd::forms::button_base, xtd::forms::group_box, xtd::forms::label, and xtd::forms::loading_indicator.

◆ control_appearance() [2/2]

virtual control & xtd::forms::control::control_appearance ( xtd::forms::control_appearance  value)
virtual

Sets control appearance.

Parameters
valueOne of xtd::forms::control_appearance values. THe default is xtd::forms::control_appearance::standard.
Remarks
The control appearance determine how the control is drawed :
  • xtd::control::control_appearance::standard : The appearance of the control is determined by current theme of xtd.
  • xtd::control::control_appearance::system : The appearance of the control is determined by the user's operating system.

Reimplemented in xtd::forms::button_base, xtd::forms::group_box, xtd::forms::label, xtd::forms::loading_indicator, xtd::forms::button_base, xtd::forms::group_box, xtd::forms::label, and xtd::forms::loading_indicator.

◆ controls() [1/2]

virtual control_collection & xtd::forms::control::controls ( )
virtualnoexcept

Gets the collection of controls contained within the control.

Returns
A control::control_collection representing the collection of controls contained within the control.
Remarks
A control can act as a parent to a collection of controls. For example, when several controls are added to a form, each of the controls is a member of the control::control_collection assigned to the controls property of the form, which is derived from the control class.
You can manipulate the controls in the control::control_collection assigned to the controls property by using the methods available in the control::control_collection class.
When adding several controls to a parent control, it is recommended that you call the suspend_layout method before initializing the controls to be added. After adding the controls to the parent control, call the resume_layout method. Doing so will increase the performance of applications with many controls.
Use the controls property to iterate through all controls of a form, including nested controls. Use the get_next_control method to retrieve the previous or next child control in the tab order. Use the active_control property to get or set the active control of a container control.
Examples
button2.cpp, and emplace.cpp.

◆ controls() [2/2]

virtual const control_collection & xtd::forms::control::controls ( ) const
virtualnoexcept

Gets the collection of controls contained within the control.

Returns
A control::control_collection representing the collection of controls contained within the control.
Remarks
A control can act as a parent to a collection of controls. For example, when several controls are added to a form, each of the controls is a member of the control::control_collection assigned to the controls property of the form, which is derived from the control class.
You can manipulate the controls in the control::control_collection assigned to the controls property by using the methods available in the control::control_collection class.
When adding several controls to a parent control, it is recommended that you call the suspend_layout method before initializing the controls to be added. After adding the controls to the parent control, call the resume_layout method. Doing so will increase the performance of applications with many controls.
Use the controls property to iterate through all controls of a form, including nested controls. Use the get_next_control method to retrieve the previous or next child control in the tab order. Use the active_control property to get or set the active control of a container control.

◆ created()

virtual bool xtd::forms::control::created ( ) const
virtualnoexcept

Gets a value indicating whether the control has been created.

Returns
true if the control has been created; otherwise, false.
Remarks
The created property returns true if the control was successfully created even though the control's handle might not have been created or recreated yet.

◆ cursor() [1/2]

virtual forms::cursor xtd::forms::control::cursor ( ) const
virtualnoexcept

Gets the cursor that is displayed when the mouse pointer is over the control.

Returns
A xtd::forms::cursor that represents the cursor to display when the mouse pointer is over the control.
Remarks
The xtd::forms::control::cursor property is an ambient property. An ambient property is a control property that, if not set, is retrieved from the parent control. For example, a xtd::forms::button will have the same xtd::forms::control::back_color as its parent xtd::forms::form by default. For more information about ambient properties, see the ambient_properties guide.

◆ cursor() [2/2]

virtual control & xtd::forms::control::cursor ( const xtd::forms::cursor cursor)
virtual

Sets the cursor that is displayed when the mouse pointer is over the control.

Parameters
cursorA xtd::forms::cursor that represents the cursor to display when the mouse pointer is over the control.
Returns
Current control.
Remarks
The xtd::forms::control::cursor property is an ambient property. An ambient property is a control property that, if not set, is retrieved from the parent control. For example, a xtd::forms::button will have the same xtd::forms::control::back_color as its parent xtd::forms::form by default. For more information about ambient properties, see the ambient_properties guide.

◆ display_rectangle()

virtual drawing::rectangle xtd::forms::control::display_rectangle ( ) const
virtualnoexcept

Gets the rectangle that represents the display area of the control.

Returns
A rectangle that represents the display area of the control.

Reimplemented in xtd::forms::scrollable_control.

◆ dock() [1/2]

virtual dock_style xtd::forms::control::dock ( ) const
virtualnoexcept

Gets which control borders are docked to its parent control and determines how a control is resized with its parent.

Returns
One of the xtd::forms::dock_style values. The default is xtd::forms::dock_style::none.
Remarks
Use the xtd::forms::control::dock property to define how a control is automatically resized as its parent control is resized. For example, setting xtd::forms::control::dock to xtd::forms::dock_style::left causes the control to align itself with the left edges of its parent control and to resize as the parent control is resized. Controls are docked in their Z-order, which is the visual layering of controls on a form along the form's Z-axis (depth).
A control can be docked to one edge of its parent container or can be docked to all edges and fill the parent container.
Setting the xtd::forms::control::margin property on a docked control has no effect on the distance of the control from the edges of its container.
Note
The xtd::forms::control::anchor and xtd::forms::control::dock properties are mutually exclusive. Only one can be set at a time, and the last one set takes precedence.
Notes to Inheritors
When overriding the xtd::forms::control::dock property in a derived class, use the base class's xtd::forms::control::dock property to extend the base implementation. Otherwise, you must provide all the implementation. You are not required to override both the get and set methods of the xtd::forms::control::dock property; you can override only one if needed.

Reimplemented in xtd::forms::status_bar, and xtd::forms::tool_bar.

Examples
demo.cpp, lcd_label2.cpp, lcd_label_with_dot_matrix.cpp, lcd_label_with_fourteen_segment.cpp, lcd_label_with_nine_segment.cpp, lcd_label_with_seven_segment.cpp, and lcd_label_with_sixteen_segment.cpp.

◆ dock() [2/2]

virtual control & xtd::forms::control::dock ( xtd::forms::dock_style  dock)
virtual

Sets which control borders are docked to its parent control and determines how a control is resized with its parent.

Parameters
dockOne of the xtd::forms::dock_style values. The default is xtd::forms::dock_style::none.
Returns
Current control.
Remarks
Use the xtd::forms::control::dock property to define how a control is automatically resized as its parent control is resized. For example, setting xtd::forms::control::dock to xtd::forms::dock_style::left causes the control to align itself with the left edges of its parent control and to resize as the parent control is resized. Controls are docked in their Z-order, which is the visual layering of controls on a form along the form's Z-axis (depth).
A control can be docked to one edge of its parent container or can be docked to all edges and fill the parent container.
Setting the xtd::forms::control::margin property on a docked control has no effect on the distance of the control from the edges of its container.
Note
The xtd::forms::control::anchor and xtd::forms::control::dock properties are mutually exclusive. Only one can be set at a time, and the last one set takes precedence.
Notes to Inheritors
When overriding the xtd::forms::control::dock property in a derived class, use the base class's xtd::forms::control::dock property to extend the base implementation. Otherwise, you must provide all the implementation. You are not required to override both the get and set methods of the xtd::forms::control::dock property; you can override only one if needed.

Reimplemented in xtd::forms::splitter, xtd::forms::status_bar, xtd::forms::tool_bar, and xtd::forms::trace_form_base.

◆ double_buffered() [1/2]

virtual bool xtd::forms::control::double_buffered ( ) const
virtualnoexcept

Gets a value indicating whether this control should redraw its surface using a secondary buffer to reduce or prevent flicker.

Returns
true if the surface of the control should be drawn using double buffering; otherwise, false.
Examples
lcd_label2.cpp.

◆ double_buffered() [2/2]

virtual control & xtd::forms::control::double_buffered ( bool  double_buffered)
virtual

Sets a value indicating whether this control should redraw its surface using a secondary buffer to reduce or prevent flicker.

Parameters
double_bufferedtrue if the surface of the control should be drawn using double buffering; otherwise, false.
Returns
Current control.

◆ enabled() [1/2]

virtual bool xtd::forms::control::enabled ( ) const
virtualnoexcept

Gets a value indicating whether the control can respond to user interaction.

Returns
true if the control can respond to user interaction; otherwise, false. The default is true.
Examples
demo.cpp.

◆ enabled() [2/2]

virtual control & xtd::forms::control::enabled ( bool  enabled)
virtual

Sets a value indicating whether the control can respond to user interaction.

Parameters
enabledtrue if the control can respond to user interaction; otherwise, false. The default is true.
Returns
Current control.

◆ focused()

virtual bool xtd::forms::control::focused ( ) const
virtualnoexcept

Gets a value indicating whether the control has input focus.

Returns
true if the control has focus; otherwise, false.

◆ font() [1/2]

virtual drawing::font xtd::forms::control::font ( ) const
virtualnoexcept

Gets the font of the text displayed by the control.

Returns
The font to apply to the text displayed by the control. The default is the value of the default_font property.
Remarks
The xtd::forms::control::font property is an ambient property. An ambient property is a control property that, if not set, is retrieved from the parent control. For example, a xtd::forms::button will have the same xtd::forms::control::back_color as its parent xtd::forms::form by default. For more information about ambient properties, see the ambient_properties guide.

Reimplemented in xtd::forms::font_picker.

Examples
demo.cpp, hello_world_emoticons.cpp, and test_forms.cpp.

◆ font() [2/2]

virtual control & xtd::forms::control::font ( const xtd::drawing::font font)
virtual

Sets the font of the text displayed by the control.

Parameters
fontThe font to apply to the text displayed by the control. The default is the value of the default_font property.
Returns
Current control.
Remarks
The xtd::forms::control::font property is an ambient property. An ambient property is a control property that, if not set, is retrieved from the parent control. For example, a xtd::forms::button will have the same xtd::forms::control::back_color as its parent xtd::forms::form by default. For more information about ambient properties, see the ambient_properties guide.

Reimplemented in xtd::forms::font_picker.

◆ fore_color() [1/2]

virtual drawing::color xtd::forms::control::fore_color ( ) const
virtualnoexcept

Gets the foreground color of the control.

Returns
The foreground color of the control. The default is the value of the default_fore_color property.
Remarks
The xtd::forms::control::fore_color property is an ambient property. An ambient property is a control property that, if not set, is retrieved from the parent control. For example, a xtd::forms::button will have the same xtd::forms::control::back_color as its parent xtd::forms::form by default. For more information about ambient properties, see the ambient_properties guide.
Examples
clock.cpp, demo.cpp, lcd_label2.cpp, lcd_label_with_dot_matrix.cpp, lcd_label_with_fourteen_segment.cpp, lcd_label_with_nine_segment.cpp, lcd_label_with_seven_segment.cpp, lcd_label_with_sixteen_segment.cpp, and test_forms.cpp.

◆ fore_color() [2/2]

virtual control & xtd::forms::control::fore_color ( const xtd::drawing::color color)
virtual

Sets the foreground color of the control.

Parameters
colorThe foreground color of the control. The default is the value of the default_fore_color property.
Returns
Current control.
Remarks
The xtd::forms::control::fore_color property is an ambient property. An ambient property is a control property that, if not set, is retrieved from the parent control. For example, a xtd::forms::button will have the same xtd::forms::control::back_color as its parent xtd::forms::form by default. For more information about ambient properties, see the ambient_properties guide.

◆ handle()

intptr xtd::forms::control::handle ( ) const
overridevirtual

Gets the window handle that the control is bound to.

Returns
An intptr that contains the window handle (HWND) of the control.
Remarks
When the underlying toolkits is native, xtd::forms::control::handle and xtd::forms::control::native_handle are the same, But if the underlying toolkit is not native, the xtd::forms::control::handle matches the toolkit handle while xtd::forms::control::native_handle returns the true native handle.

Implements xtd::forms::iwin32_window.

Examples
painting.cpp.

◆ height() [1/2]

virtual int32 xtd::forms::control::height ( ) const
virtualnoexcept

Gets the height of the control.

Returns
The height of the control in pixels.
Examples
clock.cpp, dot_matrix_display.cpp, fourteen_segment_display.cpp, nine_segment_display.cpp, seven_segment_display.cpp, and sixteen_segment_display.cpp.

◆ height() [2/2]

virtual control & xtd::forms::control::height ( int32  height)
virtual

Sets the height of the control.

Parameters
heightThe height of the control in pixels.
Returns
Current control.

◆ invoke_required()

bool xtd::forms::control::invoke_required ( ) const
overridevirtualnoexcept

Gets a value indicating whether the caller must call an invoke method when making method calls to the control because the caller is on a different thread than the one the control was created on.

Returns
true if the control's xttd::forms::control::handle was created on a different thread than the calling thread (indicating that you must make calls to the control through an invoke method); otherwise, false.

Implements xtd::isynchronize_invoke.

◆ is_handle_created()

bool xtd::forms::control::is_handle_created ( ) const
noexcept

Gets a value indicating whether the control has a handle associated with it.

Returns
true if a handle has been assigned to the control; otherwise, false.
Remarks
Use the is_handle_created property to determine whether create_handle has been called.

◆ left() [1/2]

virtual int32 xtd::forms::control::left ( ) const
virtualnoexcept

Gets the distance, in pixels, between the left edge of the control and the left edge of its container's client area.

Returns
An int32 representing the distance, in pixels, between the left edge of the control and the left edge of its container's client area.

◆ left() [2/2]

virtual control & xtd::forms::control::left ( int32  left)
virtual

Sets the distance, in pixels, between the left edge of the control and the left edge of its container's client area.

Parameters
leftAn int32 representing the distance, in pixels, between the left edge of the control and the left edge of its container's client area.
Returns
Current control.

◆ location() [1/2]

virtual drawing::point xtd::forms::control::location ( ) const
virtualnoexcept

Gets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.

Returns
The point that represents the upper-left corner of the control relative to the upper-left corner of its container.
Examples
color_picker.cpp, debug_message_box.cpp, debug_message_dialog.cpp, demo.cpp, dialog.cpp, enable_changed_event.cpp, font_changed_event.cpp, form_and_main.cpp, form_background_image.cpp, owner_button.cpp, screen.cpp, trace_message_box.cpp, trace_message_dialog.cpp, and wiggly.cpp.

◆ location() [2/2]

virtual control & xtd::forms::control::location ( const xtd::drawing::point location)
virtual

Sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.

Parameters
locationThe point that represents the upper-left corner of the control relative to the upper-left corner of its container.
Returns
Current control.

◆ margin() [1/2]

virtual forms::padding xtd::forms::control::margin ( ) const
virtualnoexcept

Gets the space between controls.

Returns
A padding representing the space between controls.

◆ margin() [2/2]

virtual control & xtd::forms::control::margin ( const xtd::forms::padding margin)
virtual

Sets the space between controls.

Parameters
marginA padding representing the space between controls.
Returns
Current control.

◆ maximum_client_size() [1/2]

virtual const drawing::size & xtd::forms::control::maximum_client_size ( ) const
virtualnoexcept

Gets the client size that is the upper limit that xtd::forms::control::get_preferred_size can specify.

Returns
An ordered pair of type xtd::drawing::size representing the width and height of a rectangle.
Examples
The following code shows how to set minimum size, set maximum size, move and resize a form.
#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/button_images>
#include <xtd/forms/form>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
client_size({220, 115});
maximum_client_size(client_size() + drawing::size {300, 300});
minimum_client_size(client_size());
controls().push_back_range({up_button, left_button, right_button, down_button, shrink_button, grow_button});
text("Form resize example");
key_down += [&](auto sender, auto e) {
if (e.key_code() == keys::right) left(left() + 10);
else if (e.key_code() == keys::left) left(left() - 10);
else if (e.key_code() == keys::down) top(top() + 10);
else if (e.key_code() == keys::up) top(top() - 10);
};
key_press += [&](auto sender, auto e) {
if (e.key_char() == '+') size(size() + drawing::size {10, 10});
else if (e.key_char() == '-') size(size() - drawing::size {10, 10});
};
up_button.auto_repeat(true);
up_button.bounds({45, 10, 25, 25});
up_button.image(button_images::from_name("go-up"));
up_button.click += [&] {
top(top() - 10);
};
left_button.auto_repeat(true);
left_button.bounds({10, 45, 25, 25});
left_button.image(button_images::from_name("go-previous"));
left_button.click += [&] {
left(left() - 10);
};
right_button.auto_repeat(true);
right_button.bounds({80, 45, 25, 25});
right_button.image(button_images::from_name("go-next"));
right_button.click += [&] {
left(left() + 10);
};
down_button.auto_repeat(true);
down_button.bounds({45, 80, 25, 25});
down_button.image(button_images::from_name("go-down"));
down_button.click += [&] {
top(top() + 10);
};
shrink_button.auto_repeat(true);
shrink_button.bounds({150, 45, 25, 25});
shrink_button.image(button_images::from_name("zoom-out"));
shrink_button.click += [&] {
size(size() - drawing::size {10, 10});
};
grow_button.auto_repeat(true);
grow_button.bounds({185, 45, 25, 25});
grow_button.image(button_images::from_name("zoom-in"));
grow_button.click += [&] {
size(size() + drawing::size {10, 10});
};
}
private:
button up_button;
button left_button;
button right_button;
button down_button;
button grow_button;
button shrink_button;
};
auto main() -> int {
application::run(form1 {});
}
Stores an ordered pair of integers, which specify a height and width.
Definition size.hpp:31
Represents a Windows button control.
Definition button.hpp:49
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
@ e
The E key.
@ left
Specifies the xtd::drawing::pen is positioned to the left of the theoretical line.
@ top
Bind control edges to the top of its container.

◆ maximum_client_size() [2/2]

virtual control & xtd::forms::control::maximum_client_size ( const xtd::drawing::size size)
virtual

Sets the client size that is the upper limit that xtd::forms::control::get_preferred_size can specify.

Parameters
sizeAn ordered pair of type xtd::drawing::size representing the width and height of a rectangle.
Examples
The following code shows how to set minimum size, set maximum size, move and resize a form.
#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/button_images>
#include <xtd/forms/form>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
client_size({220, 115});
maximum_client_size(client_size() + drawing::size {300, 300});
minimum_client_size(client_size());
controls().push_back_range({up_button, left_button, right_button, down_button, shrink_button, grow_button});
text("Form resize example");
key_down += [&](auto sender, auto e) {
if (e.key_code() == keys::right) left(left() + 10);
else if (e.key_code() == keys::left) left(left() - 10);
else if (e.key_code() == keys::down) top(top() + 10);
else if (e.key_code() == keys::up) top(top() - 10);
};
key_press += [&](auto sender, auto e) {
if (e.key_char() == '+') size(size() + drawing::size {10, 10});
else if (e.key_char() == '-') size(size() - drawing::size {10, 10});
};
up_button.auto_repeat(true);
up_button.bounds({45, 10, 25, 25});
up_button.image(button_images::from_name("go-up"));
up_button.click += [&] {
top(top() - 10);
};
left_button.auto_repeat(true);
left_button.bounds({10, 45, 25, 25});
left_button.image(button_images::from_name("go-previous"));
left_button.click += [&] {
left(left() - 10);
};
right_button.auto_repeat(true);
right_button.bounds({80, 45, 25, 25});
right_button.image(button_images::from_name("go-next"));
right_button.click += [&] {
left(left() + 10);
};
down_button.auto_repeat(true);
down_button.bounds({45, 80, 25, 25});
down_button.image(button_images::from_name("go-down"));
down_button.click += [&] {
top(top() + 10);
};
shrink_button.auto_repeat(true);
shrink_button.bounds({150, 45, 25, 25});
shrink_button.image(button_images::from_name("zoom-out"));
shrink_button.click += [&] {
size(size() - drawing::size {10, 10});
};
grow_button.auto_repeat(true);
grow_button.bounds({185, 45, 25, 25});
grow_button.image(button_images::from_name("zoom-in"));
grow_button.click += [&] {
size(size() + drawing::size {10, 10});
};
}
private:
button up_button;
button left_button;
button right_button;
button down_button;
button grow_button;
button shrink_button;
};
auto main() -> int {
application::run(form1 {});
}

◆ maximum_size() [1/2]

virtual const drawing::size & xtd::forms::control::maximum_size ( ) const
virtualnoexcept

Gets the size that is the upper limit that xtd::forms::control::get_preferred_size can specify.

Returns
An ordered pair of type xtd::drawing::size representing the width and height of a rectangle.
Examples
The following code shows how to set minimum size, set maximum size, move and resize a form.
#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/button_images>
#include <xtd/forms/form>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
client_size({220, 115});
maximum_client_size(client_size() + drawing::size {300, 300});
minimum_client_size(client_size());
controls().push_back_range({up_button, left_button, right_button, down_button, shrink_button, grow_button});
text("Form resize example");
key_down += [&](auto sender, auto e) {
if (e.key_code() == keys::right) left(left() + 10);
else if (e.key_code() == keys::left) left(left() - 10);
else if (e.key_code() == keys::down) top(top() + 10);
else if (e.key_code() == keys::up) top(top() - 10);
};
key_press += [&](auto sender, auto e) {
if (e.key_char() == '+') size(size() + drawing::size {10, 10});
else if (e.key_char() == '-') size(size() - drawing::size {10, 10});
};
up_button.auto_repeat(true);
up_button.bounds({45, 10, 25, 25});
up_button.image(button_images::from_name("go-up"));
up_button.click += [&] {
top(top() - 10);
};
left_button.auto_repeat(true);
left_button.bounds({10, 45, 25, 25});
left_button.image(button_images::from_name("go-previous"));
left_button.click += [&] {
left(left() - 10);
};
right_button.auto_repeat(true);
right_button.bounds({80, 45, 25, 25});
right_button.image(button_images::from_name("go-next"));
right_button.click += [&] {
left(left() + 10);
};
down_button.auto_repeat(true);
down_button.bounds({45, 80, 25, 25});
down_button.image(button_images::from_name("go-down"));
down_button.click += [&] {
top(top() + 10);
};
shrink_button.auto_repeat(true);
shrink_button.bounds({150, 45, 25, 25});
shrink_button.image(button_images::from_name("zoom-out"));
shrink_button.click += [&] {
size(size() - drawing::size {10, 10});
};
grow_button.auto_repeat(true);
grow_button.bounds({185, 45, 25, 25});
grow_button.image(button_images::from_name("zoom-in"));
grow_button.click += [&] {
size(size() + drawing::size {10, 10});
};
}
private:
button up_button;
button left_button;
button right_button;
button down_button;
button grow_button;
button shrink_button;
};
auto main() -> int {
application::run(form1 {});
}

◆ maximum_size() [2/2]

virtual control & xtd::forms::control::maximum_size ( const xtd::drawing::size size)
virtual

Sets the size that is the upper limit that xtd::forms::control::get_preferred_size can specify.

Parameters
sizeAn ordered pair of type xtd::drawing::size representing the width and height of a rectangle.
Examples
The following code shows how to set minimum size, set maximum size, move and resize a form.
#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/button_images>
#include <xtd/forms/form>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
client_size({220, 115});
maximum_client_size(client_size() + drawing::size {300, 300});
minimum_client_size(client_size());
controls().push_back_range({up_button, left_button, right_button, down_button, shrink_button, grow_button});
text("Form resize example");
key_down += [&](auto sender, auto e) {
if (e.key_code() == keys::right) left(left() + 10);
else if (e.key_code() == keys::left) left(left() - 10);
else if (e.key_code() == keys::down) top(top() + 10);
else if (e.key_code() == keys::up) top(top() - 10);
};
key_press += [&](auto sender, auto e) {
if (e.key_char() == '+') size(size() + drawing::size {10, 10});
else if (e.key_char() == '-') size(size() - drawing::size {10, 10});
};
up_button.auto_repeat(true);
up_button.bounds({45, 10, 25, 25});
up_button.image(button_images::from_name("go-up"));
up_button.click += [&] {
top(top() - 10);
};
left_button.auto_repeat(true);
left_button.bounds({10, 45, 25, 25});
left_button.image(button_images::from_name("go-previous"));
left_button.click += [&] {
left(left() - 10);
};
right_button.auto_repeat(true);
right_button.bounds({80, 45, 25, 25});
right_button.image(button_images::from_name("go-next"));
right_button.click += [&] {
left(left() + 10);
};
down_button.auto_repeat(true);
down_button.bounds({45, 80, 25, 25});
down_button.image(button_images::from_name("go-down"));
down_button.click += [&] {
top(top() + 10);
};
shrink_button.auto_repeat(true);
shrink_button.bounds({150, 45, 25, 25});
shrink_button.image(button_images::from_name("zoom-out"));
shrink_button.click += [&] {
size(size() - drawing::size {10, 10});
};
grow_button.auto_repeat(true);
grow_button.bounds({185, 45, 25, 25});
grow_button.image(button_images::from_name("zoom-in"));
grow_button.click += [&] {
size(size() + drawing::size {10, 10});
};
}
private:
button up_button;
button left_button;
button right_button;
button down_button;
button grow_button;
button shrink_button;
};
auto main() -> int {
application::run(form1 {});
}

◆ minimum_client_size() [1/2]

virtual const drawing::size & xtd::forms::control::minimum_client_size ( ) const
virtualnoexcept

Gets the client size that is the lower limit that xtd::forms::control::get_preferred_size can specify.

Returns
An ordered pair of type xtd::drawing::size representing the width and height of a rectangle.
Examples
The following code shows how to set minimum size, set maximum size, move and resize a form.
#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/button_images>
#include <xtd/forms/form>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
client_size({220, 115});
maximum_client_size(client_size() + drawing::size {300, 300});
minimum_client_size(client_size());
controls().push_back_range({up_button, left_button, right_button, down_button, shrink_button, grow_button});
text("Form resize example");
key_down += [&](auto sender, auto e) {
if (e.key_code() == keys::right) left(left() + 10);
else if (e.key_code() == keys::left) left(left() - 10);
else if (e.key_code() == keys::down) top(top() + 10);
else if (e.key_code() == keys::up) top(top() - 10);
};
key_press += [&](auto sender, auto e) {
if (e.key_char() == '+') size(size() + drawing::size {10, 10});
else if (e.key_char() == '-') size(size() - drawing::size {10, 10});
};
up_button.auto_repeat(true);
up_button.bounds({45, 10, 25, 25});
up_button.image(button_images::from_name("go-up"));
up_button.click += [&] {
top(top() - 10);
};
left_button.auto_repeat(true);
left_button.bounds({10, 45, 25, 25});
left_button.image(button_images::from_name("go-previous"));
left_button.click += [&] {
left(left() - 10);
};
right_button.auto_repeat(true);
right_button.bounds({80, 45, 25, 25});
right_button.image(button_images::from_name("go-next"));
right_button.click += [&] {
left(left() + 10);
};
down_button.auto_repeat(true);
down_button.bounds({45, 80, 25, 25});
down_button.image(button_images::from_name("go-down"));
down_button.click += [&] {
top(top() + 10);
};
shrink_button.auto_repeat(true);
shrink_button.bounds({150, 45, 25, 25});
shrink_button.image(button_images::from_name("zoom-out"));
shrink_button.click += [&] {
size(size() - drawing::size {10, 10});
};
grow_button.auto_repeat(true);
grow_button.bounds({185, 45, 25, 25});
grow_button.image(button_images::from_name("zoom-in"));
grow_button.click += [&] {
size(size() + drawing::size {10, 10});
};
}
private:
button up_button;
button left_button;
button right_button;
button down_button;
button grow_button;
button shrink_button;
};
auto main() -> int {
application::run(form1 {});
}

◆ minimum_client_size() [2/2]

virtual control & xtd::forms::control::minimum_client_size ( const xtd::drawing::size size)
virtual

Sets the client size that is the lower limit that xtd::forms::control::get_preferred_size can specify.

Parameters
sizeAn ordered pair of type xtd::drawing::size representing the width and height of a rectangle.
Examples
The following code shows how to set minimum size, set maximum size, move and resize a form.
#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/button_images>
#include <xtd/forms/form>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
client_size({220, 115});
maximum_client_size(client_size() + drawing::size {300, 300});
minimum_client_size(client_size());
controls().push_back_range({up_button, left_button, right_button, down_button, shrink_button, grow_button});
text("Form resize example");
key_down += [&](auto sender, auto e) {
if (e.key_code() == keys::right) left(left() + 10);
else if (e.key_code() == keys::left) left(left() - 10);
else if (e.key_code() == keys::down) top(top() + 10);
else if (e.key_code() == keys::up) top(top() - 10);
};
key_press += [&](auto sender, auto e) {
if (e.key_char() == '+') size(size() + drawing::size {10, 10});
else if (e.key_char() == '-') size(size() - drawing::size {10, 10});
};
up_button.auto_repeat(true);
up_button.bounds({45, 10, 25, 25});
up_button.image(button_images::from_name("go-up"));
up_button.click += [&] {
top(top() - 10);
};
left_button.auto_repeat(true);
left_button.bounds({10, 45, 25, 25});
left_button.image(button_images::from_name("go-previous"));
left_button.click += [&] {
left(left() - 10);
};
right_button.auto_repeat(true);
right_button.bounds({80, 45, 25, 25});
right_button.image(button_images::from_name("go-next"));
right_button.click += [&] {
left(left() + 10);
};
down_button.auto_repeat(true);
down_button.bounds({45, 80, 25, 25});
down_button.image(button_images::from_name("go-down"));
down_button.click += [&] {
top(top() + 10);
};
shrink_button.auto_repeat(true);
shrink_button.bounds({150, 45, 25, 25});
shrink_button.image(button_images::from_name("zoom-out"));
shrink_button.click += [&] {
size(size() - drawing::size {10, 10});
};
grow_button.auto_repeat(true);
grow_button.bounds({185, 45, 25, 25});
grow_button.image(button_images::from_name("zoom-in"));
grow_button.click += [&] {
size(size() + drawing::size {10, 10});
};
}
private:
button up_button;
button left_button;
button right_button;
button down_button;
button grow_button;
button shrink_button;
};
auto main() -> int {
application::run(form1 {});
}

◆ minimum_size() [1/2]

virtual const drawing::size & xtd::forms::control::minimum_size ( ) const
virtualnoexcept

Gets the size that is the lower limit that xtd::forms::control::get_preferred_size can specify.

Returns
An ordered pair of type xtd::drawing::size representing the width and height of a rectangle.
Examples
The following code shows how to set minimum size, set maximum size, move and resize a form.
#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/button_images>
#include <xtd/forms/form>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
client_size({220, 115});
maximum_client_size(client_size() + drawing::size {300, 300});
minimum_client_size(client_size());
controls().push_back_range({up_button, left_button, right_button, down_button, shrink_button, grow_button});
text("Form resize example");
key_down += [&](auto sender, auto e) {
if (e.key_code() == keys::right) left(left() + 10);
else if (e.key_code() == keys::left) left(left() - 10);
else if (e.key_code() == keys::down) top(top() + 10);
else if (e.key_code() == keys::up) top(top() - 10);
};
key_press += [&](auto sender, auto e) {
if (e.key_char() == '+') size(size() + drawing::size {10, 10});
else if (e.key_char() == '-') size(size() - drawing::size {10, 10});
};
up_button.auto_repeat(true);
up_button.bounds({45, 10, 25, 25});
up_button.image(button_images::from_name("go-up"));
up_button.click += [&] {
top(top() - 10);
};
left_button.auto_repeat(true);
left_button.bounds({10, 45, 25, 25});
left_button.image(button_images::from_name("go-previous"));
left_button.click += [&] {
left(left() - 10);
};
right_button.auto_repeat(true);
right_button.bounds({80, 45, 25, 25});
right_button.image(button_images::from_name("go-next"));
right_button.click += [&] {
left(left() + 10);
};
down_button.auto_repeat(true);
down_button.bounds({45, 80, 25, 25});
down_button.image(button_images::from_name("go-down"));
down_button.click += [&] {
top(top() + 10);
};
shrink_button.auto_repeat(true);
shrink_button.bounds({150, 45, 25, 25});
shrink_button.image(button_images::from_name("zoom-out"));
shrink_button.click += [&] {
size(size() - drawing::size {10, 10});
};
grow_button.auto_repeat(true);
grow_button.bounds({185, 45, 25, 25});
grow_button.image(button_images::from_name("zoom-in"));
grow_button.click += [&] {
size(size() + drawing::size {10, 10});
};
}
private:
button up_button;
button left_button;
button right_button;
button down_button;
button grow_button;
button shrink_button;
};
auto main() -> int {
application::run(form1 {});
}

◆ minimum_size() [2/2]

virtual control & xtd::forms::control::minimum_size ( const xtd::drawing::size size)
virtual

Sets the size that is the lower limit that xtd::forms::control::get_preferred_size can specify.

Parameters
sizeAn ordered pair of type xtd::drawing::size representing the width and height of a rectangle.
Examples
The following code shows how to set minimum size, set maximum size, move and resize a form.
#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/button_images>
#include <xtd/forms/form>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
client_size({220, 115});
maximum_client_size(client_size() + drawing::size {300, 300});
minimum_client_size(client_size());
controls().push_back_range({up_button, left_button, right_button, down_button, shrink_button, grow_button});
text("Form resize example");
key_down += [&](auto sender, auto e) {
if (e.key_code() == keys::right) left(left() + 10);
else if (e.key_code() == keys::left) left(left() - 10);
else if (e.key_code() == keys::down) top(top() + 10);
else if (e.key_code() == keys::up) top(top() - 10);
};
key_press += [&](auto sender, auto e) {
if (e.key_char() == '+') size(size() + drawing::size {10, 10});
else if (e.key_char() == '-') size(size() - drawing::size {10, 10});
};
up_button.auto_repeat(true);
up_button.bounds({45, 10, 25, 25});
up_button.image(button_images::from_name("go-up"));
up_button.click += [&] {
top(top() - 10);
};
left_button.auto_repeat(true);
left_button.bounds({10, 45, 25, 25});
left_button.image(button_images::from_name("go-previous"));
left_button.click += [&] {
left(left() - 10);
};
right_button.auto_repeat(true);
right_button.bounds({80, 45, 25, 25});
right_button.image(button_images::from_name("go-next"));
right_button.click += [&] {
left(left() + 10);
};
down_button.auto_repeat(true);
down_button.bounds({45, 80, 25, 25});
down_button.image(button_images::from_name("go-down"));
down_button.click += [&] {
top(top() + 10);
};
shrink_button.auto_repeat(true);
shrink_button.bounds({150, 45, 25, 25});
shrink_button.image(button_images::from_name("zoom-out"));
shrink_button.click += [&] {
size(size() - drawing::size {10, 10});
};
grow_button.auto_repeat(true);
grow_button.bounds({185, 45, 25, 25});
grow_button.image(button_images::from_name("zoom-in"));
grow_button.click += [&] {
size(size() + drawing::size {10, 10});
};
}
private:
button up_button;
button left_button;
button right_button;
button down_button;
button grow_button;
button shrink_button;
};
auto main() -> int {
application::run(form1 {});
}

◆ native_handle()

intptr xtd::forms::control::native_handle ( ) const
noexcept

Gets the native handle that the control is bound to.

Returns
An intptr that contains the native handle (HWND) of the control.
Remarks
When the underlying toolkits is native, xtd::forms::control::handle and xtd::forms::control::native_handle are the same, But if the underlying toolkit is not native, the xtd::forms::control::handle matches the toolkit handle while xtd::forms::control::native_handle returns the true native handle.

◆ name() [1/2]

virtual const xtd::string & xtd::forms::control::name ( ) const
virtualnoexcept

Gets the name of the control.

Returns
The name of the control. The default is an empty string ("").

Reimplemented in xtd::forms::trace_form_base.

◆ name() [2/2]

virtual control & xtd::forms::control::name ( const xtd::string name)
virtual

Sets the name of the control.

Parameters
nameThe name of the control. The default is an empty string ("").
Returns
Current control.

◆ padding() [1/2]

virtual forms::padding xtd::forms::control::padding ( ) const
virtualnoexcept

Gets padding within the control.

Returns
A padding representing the control's internal spacing characteristics.

◆ padding() [2/2]

virtual control & xtd::forms::control::padding ( const xtd::forms::padding padding)
virtual

Sets padding within the control.

Parameters
paddingA padding representing the control's internal spacing characteristics.
Returns
Current control.

◆ parent() [1/3]

virtual std::optional< control_ref > xtd::forms::control::parent ( ) const
virtualnoexcept

◆ parent() [2/3]

virtual control & xtd::forms::control::parent ( const control parent)
virtual

Sets the parent container of the control.

Parameters
parentA control that represents the parent or container control of the control or nullptr for none.
Returns
Current control.

Reimplemented in xtd::forms::tab_page, and xtd::forms::form.

◆ parent() [3/3]

virtual control & xtd::forms::control::parent ( std::nullptr_t  )
virtual

Resets the parent container of the control.

Parameters
nullptr.
Returns
Current control.

Reimplemented in xtd::forms::tab_page.

◆ product_name()

virtual xtd::string xtd::forms::control::product_name ( ) const
virtualnoexcept

Gets the product name of the assembly containing the control.

Returns
The product name of the assembly containing the control.

◆ recreating_handle()

bool xtd::forms::control::recreating_handle ( ) const
noexcept

Gets a value indicating whether the control is currently re-creating its handle.

Returns
true if the control is currently re-creating its handle; otherwise, false.

◆ region() [1/2]

virtual const xtd::drawing::region & xtd::forms::control::region ( ) const
virtualnoexcept

Gets the window region associated with the control.

Returns
The window xtd::drawing::region associated with the control.
Remarks
The window region is a collection of pixels within the window where the operating system permits drawing. The operating system does not display any portion of a window that lies outside of the window region. The coordinates of a control's region are relative to the upper-left corner of the control, not the client area of the control.
Note
The collection of pixels contained with the region can be noncontiguous.

◆ region() [2/2]

virtual control & xtd::forms::control::region ( const xtd::drawing::region value)
virtual

Sets the window region associated with the control.

Parameters
valueThe window xtd::drawing::region associated with the control.
Returns
Current control.
Remarks
The window region is a collection of pixels within the window where the operating system permits drawing. The operating system does not display any portion of a window that lies outside of the window region. The coordinates of a control's region are relative to the upper-left corner of the control, not the client area of the control.
Note
The collection of pixels contained with the region can be noncontiguous.

◆ right()

virtual int32 xtd::forms::control::right ( ) const
virtualnoexcept

Gets the distance, in pixels, between the right edge of the control and the left edge of its container's client area.

Returns
An int32 representing the distance, in pixels, between the right edge of the control and the left edge of its container's client area.

◆ right_to_left() [1/2]

virtual xtd::forms::right_to_left xtd::forms::control::right_to_left ( ) const
virtualnoexcept

Gets a value indicating whether control's elements are aligned to support locales using right-to-left fonts.

Returns
One of the xtd::forms::right_to_left values. The default is xtd::forms::right_to_left::inherit.
Remarks
The xtd::forms::control::right_to_left property is an ambient property. An ambient property is a control property that, if not set, is retrieved from the parent control. For example, a xtd::forms::button will have the same xtd::forms::control::back_color as its parent xtd::forms::form by default. For more information about ambient properties, see the ambient_properties guide.
The xtd::forms::control::right_to_left property is used for international applications where the language is written from right to left, such as Hebrew or Arabic. When this property is set to xtd::forms::right_to_left::yes, control elements that include text are displayed from right to left.
Note
If the value of the xtd::forms::control::right_to_left property is changed at run time, only raw text without formatting is preserved.
Remarks
The following are a few examples of how control elements are affected by the xtd::forms::control::right_to_left property value of xtd::forms::right_to_left::yes :
Notes to Inheritors
When overriding the xtd::forms::control::right_to_left property in a derived class, use the base class's xtd::forms::control::right_to_left property to extend the base implementation. Otherwise, you must provide all the implementation. You are not required to override both the get and set accessors of the xtd::forms::control::right_to_left property; you can override only one if needed.

◆ right_to_left() [2/2]

virtual control & xtd::forms::control::right_to_left ( xtd::forms::right_to_left  value)
virtual

Sets a value indicating whether control's elements are aligned to support locales using right-to-left fonts.

Parameters
valueOne of the xtd::forms::right_to_left values. The default is xtd::forms::right_to_left::inherit.
Returns
Current control.
Remarks
The xtd::forms::control::right_to_left property is an ambient property. An ambient property is a control property that, if not set, is retrieved from the parent control. For example, a xtd::forms::button will have the same xtd::forms::control::back_color as its parent xtd::forms::form by default. For more information about ambient properties, see the ambient_properties guide.
The xtd::forms::control::right_to_left property is used for international applications where the language is written from right to left, such as Hebrew or Arabic. When this property is set to xtd::forms::right_to_left::yes, control elements that include text are displayed from right to left.
Note
If the value of the xtd::forms::control::right_to_left property is changed at run time, only raw text without formatting is preserved.
Remarks
The following are a few examples of how control elements are affected by the xtd::forms::control::right_to_left property value of xtd::forms::right_to_left::yes :
Notes to Inheritors
When overriding the xtd::forms::control::right_to_left property in a derived class, use the base class's xtd::forms::control::right_to_left property to extend the base implementation. Otherwise, you must provide all the implementation. You are not required to override both the get and set accessors of the xtd::forms::control::right_to_left property; you can override only one if needed.

◆ size() [1/2]

virtual drawing::size xtd::forms::control::size ( ) const
virtualnoexcept

Gets the height and width of the control.

Returns
The size that represents the height and width of the control in pixels.
Examples
demo.cpp, lcd_label_with_dot_matrix.cpp, lcd_label_with_fourteen_segment.cpp, lcd_label_with_nine_segment.cpp, lcd_label_with_seven_segment.cpp, lcd_label_with_sixteen_segment.cpp, screen.cpp, and test_forms.cpp.

◆ size() [2/2]

virtual control & xtd::forms::control::size ( const drawing::size size)
virtual

Sets the height and width of the control.

Parameters
sizeThe size that represents the height and width of the control in pixels.
Returns
Current control.

◆ style_sheet() [1/4]

virtual style_sheets::style_sheet xtd::forms::control::style_sheet ( ) const
virtualnoexcept

Gets the contol style sheet.

Returns
The xtd::forms::style_sheets::style-sheet style sheet associate to this current instance of xtd::forms::control.
Remarks
For more information, see Style sheets overview.

◆ style_sheet() [2/4]

virtual control & xtd::forms::control::style_sheet ( const style_sheets::style_sheet value)
virtual

Sets the contol style sheet.

Parameters
valueThe xtd::forms::style_sheets::style-sheet style sheet associate to this current instance of xtd::forms::control.
Remarks
For more information, see Style sheets overview.

◆ style_sheet() [3/4]

virtual control & xtd::forms::control::style_sheet ( const xtd::string value)
virtual

Sets the contol style sheet.

Parameters
valueThe xtd::forms::style_sheets::style-sheet style sheet associate to this current instance of xtd::forms::control.
Returns
Current control.
Remarks
For more information, see Style sheets overview.

◆ style_sheet() [4/4]

virtual control & xtd::forms::control::style_sheet ( std::nullptr_t  )
virtual

Resets the contol style sheet.

Parameters
valueThe xtd::forms::style_sheets::style-sheet style sheet associate to this current instance of xtd::forms::control.
Returns
Current control.
Remarks
For more information, see Style sheets overview.

◆ tab_stop() [1/2]

virtual bool xtd::forms::control::tab_stop ( ) const
virtualnoexcept

Gets a value indicating whether the user can give the focus to this control using the TAB key.

Returns
true if the user can give the focus to the control using the TAB key; otherwise, false. The default is true.
Note
Note: This property will always return true for an instance of the xtd::forms::form class.
Remarks
When the user presses the TAB key, the input focus is set to the next control in the tab order. Controls with the xtd::forms::control::tab_stop property value of false are not included in the collection of controls in the tab order. The tab order can be manipulated by setting the control's xtd::forms::control::tab_index property value.

◆ tab_stop() [2/2]

virtual control & xtd::forms::control::tab_stop ( bool  value)
virtual

Sets a value indicating whether the user can give the focus to this control using the TAB key.

Parameters
valuetrue if the user can give the focus to the control using the TAB key; otherwise, false. The default is true.
Returns
Current control.
Note
Note: This property will always return true for an instance of the xtd::forms::form class.
Remarks
When the user presses the TAB key, the input focus is set to the next control in the tab order. Controls with the xtd::forms::control::tab_stop property value of false are not included in the collection of controls in the tab order. The tab order can be manipulated by setting the control's xtd::forms::control::tab_index property value.

◆ tag() [1/2]

virtual std::any xtd::forms::control::tag ( ) const
virtualnoexcept

Gets the object that contains data about the control.

Returns
A std::any that contains data about the control. The default is empty.
Remarks
Any type of class can be assigned to this property.
A common use for the tag property is to store data that is closely associated with the control. For example, if you have a control that displays information about a customer, you might store a data_set that contains the customer's order history in that control's tag property so the data can be accessed quickly.

◆ tag() [2/2]

virtual control & xtd::forms::control::tag ( std::any  tag)
virtual

Sets the object that contains data about the control.

Parameters
tagA std::any that contains data about the control. The default is empty.
Returns
Current control.
Remarks
Any type of class can be assigned to this property.
A common use for the tag property is to store data that is closely associated with the control. For example, if you have a control that displays information about a customer, you might store a data_set that contains the customer's order history in that control's tag property so the data can be accessed quickly.

◆ text() [1/2]

◆ text() [2/2]

virtual control & xtd::forms::control::text ( const xtd::string text)
virtual

Sets the text associated with this control.

Parameters
textThe text associated with this control.
Returns
Current control.

Reimplemented in xtd::forms::lcd_label, xtd::forms::checked_list_box, xtd::forms::checked_list_box, xtd::forms::choice, xtd::forms::combo_box, xtd::forms::list_box, xtd::forms::tab_page, xtd::forms::text_box, xtd::forms::command_link_button, and xtd::forms::lcd_label.

◆ toolkit_handle()

intptr xtd::forms::control::toolkit_handle ( ) const
noexcept

Gets the toolkit handle that the control is bound to.

Returns
An intptr that contains the toolkit handle (HWND) of the control.
Remarks
When the underlying toolkits is native, xtd::forms::control::handle and xtd::forms::control::toolkit_handle are the same, But if the underlying toolkit is not native, the xtd::forms::control::handle matches the toolkit handle while xtd::forms::control::toolkit_handle returns the toolkit handle.

◆ top() [1/2]

virtual int32 xtd::forms::control::top ( ) const
virtualnoexcept

Gets the distance, in pixels, between the top edge of the control and the top edge of its container's client area.

Returns
An Int32_t representing the distance, in pixels, between the bottom edge of the control and the top edge of its container's client area.

◆ top() [2/2]

virtual control & xtd::forms::control::top ( int32  top)
virtual

Sets the distance, in pixels, between the top edge of the control and the top edge of its container's client area.

Parameters
topAn Int32_t representing the distance, in pixels, between the bottom edge of the control and the top edge of its container's client area.
Returns
Current control.

◆ top_level_control()

virtual std::optional< control_ref > xtd::forms::control::top_level_control ( ) const
virtualnoexcept

Gets the parent control that is not parented by another Windows Forms control. Typically, this is the outermost Form that the control is contained in.

Returns
The control that represents the top-level control that contains the current control.

◆ visible() [1/2]

virtual bool xtd::forms::control::visible ( ) const
virtualnoexcept

Gets a value indicating whether the control and all its child controls are displayed.

Returns
true if the control and all its child controls are displayed; otherwise, false. The default is true.

◆ visible() [2/2]

virtual control & xtd::forms::control::visible ( bool  visible)
virtual

Sets a value indicating whether the control and all its child controls are displayed.

Parameters
visibletrue if the control and all its child controls are displayed; otherwise, false. The default is true.
Returns
Current control.

Reimplemented in xtd::forms::form.

◆ width() [1/2]

virtual int32 xtd::forms::control::width ( ) const
virtualnoexcept

Gets the width of the control.

Returns
The width of the control in pixels.
Examples
demo.cpp, and wiggly.cpp.

◆ width() [2/2]

virtual control & xtd::forms::control::width ( int32  width)
virtual

Sets the width of the control.

Parameters
widthThe width of the control in pixels.
Returns
Current control.

◆ check_for_illegal_cross_thread_calls() [1/2]

static bool xtd::forms::control::check_for_illegal_cross_thread_calls ( )
staticnoexcept

Gets a value indicating whether to catch calls on the wrong thread that access a xtd::forms::contrtol::handle property when an application is being debugged.

Returns
true if calls on the wrong thread are caught; otherwise, false.
Remarks
When a thread other than the creating thread of a control tries to access one of that control's methods or properties, it often leads to unpredictable results. A common invalid thread activity is a call on the wrong thread that accesses the xtd::forms::control::handle property. Set xtd::forms::control::check_for_illegal_cross_thread_calls to true to find and diagnose this thread activity more easily while debugging.
Warning
Be careful, some OS don't support cross-thread UI operations!

◆ check_for_illegal_cross_thread_calls() [2/2]

static void xtd::forms::control::check_for_illegal_cross_thread_calls ( bool  value)
static

Sets a value indicating whether to catch calls on the wrong thread that access a xtd::forms::contrtol::handle property when an application is being debugged.

Parameters
valuetrue if calls on the wrong thread are caught; otherwise, false.
Remarks
When a thread other than the creating thread of a control tries to access one of that control's methods or properties, it often leads to unpredictable results. A common invalid thread activity is a call on the wrong thread that accesses the xtd::forms::control::handle property. Set xtd::forms::control::check_for_illegal_cross_thread_calls to true to find and diagnose this thread activity more easily while debugging.
Warning
Be careful, some OS don't support cross-thread UI operations!

◆ modifier_keys()

static forms::keys xtd::forms::control::modifier_keys ( )
staticnoexcept

Gets a value indicating which of the modifier keys (SHIFT, CTRL, and ALT) is in a pressed state.

Returns
A bitwise combination of the keys values. The default is none.

◆ mouse_buttons()

static forms::mouse_buttons xtd::forms::control::mouse_buttons ( )
staticnoexcept

Gets a value indicating which of the mouse buttons is in a pressed state.

Returns
A bitwise combination of the mouse_buttons enumeration values. The default is none.

◆ mouse_position()

static xtd::drawing::point xtd::forms::control::mouse_position ( )
staticnoexcept

Gets the position of the mouse cursor in screen coordinates.

Returns
A xtd::drawing::point that contains the coordinates of the mouse cursor relative to the upper-left corner of the screen.
Remarks
The xtd::forms::control::mouse_position property returns a xtd::drawing::point that represents the mouse cursor position at the time the property was referenced. The coordinates indicate the position on the screen, not relative to the control, and are returned regardless of whether the cursor is positioned over the control. The coordinates of the upper-left corner of the screen are 0,0.
The xtd::forms::control::mouse_position property is identical to the xtd::forms::cursor::position property.

◆ begin_invoke() [1/4]

xtd::async_result xtd::forms::control::begin_invoke ( delegate< void()>  method)
overridevirtual

Executes the specified delegate asynchronously on the thread that the control's underlying handle was created on.

Parameters
methodA delegate to a method that takes no parameters.
Returns
An async_result_invoke that represents the result of the begin_invoke(delegate) operation.

Implements xtd::isynchronize_invoke.

◆ begin_invoke() [2/4]

xtd::async_result xtd::forms::control::begin_invoke ( delegate< void(std::vector< std::any >)>  method,
const std::vector< std::any > &  args 
)
overridevirtual

Executes the specified delegate asynchronously with the specified arguments, on the thread that the control's underlying handle was created on.

Parameters
methodA delegate to a method that takes parameters of the same number and type that are contained in the args parameter.
argsAn array of objects to pass as arguments to the given method. This can be empty if no arguments are needed.
Returns
An async_result_invoke that represents the result of the begin_invoke(delegate) operation.

Implements xtd::isynchronize_invoke.

◆ bring_to_front()

virtual void xtd::forms::control::bring_to_front ( )
virtual

Brings the control to the front of the z-order.

Remarks
The control is moved to the front of the z-order. If the control is a child of another control, the child control is moved to the front of the z-order. bring_to_front does not make a control a top-level control, and it does not raise the xtd::forms::control::paint event.

Reimplemented in xtd::forms::form.

◆ create_control()

void xtd::forms::control::create_control ( )

Forces the creation of the visible control, including the creation of the handle and any visible child controls.

Remarks
The create_control method forces a handle to be created for the control and its child controls. This method is used when you need a handle immediately for manipulation of the control or its children; simply calling a control's constructor does not create the Handle.
create_control does not create a control handle if the control's visible property is false. You can either call the create_control method or access the handle property to create the control's handle regardless of the control's visibility, but in this case, no window handles are created for the control's children.

◆ create_graphics()

drawing::graphics xtd::forms::control::create_graphics ( ) const

Creates the xtd::drawing::graphics for the control.

Returns
A xtd::drawing::graphics for the control.
Remarks
The graphics object that you retrieve through the create_graphics method should not normally be retained after the current Windows message has been processed, because anything painted with that object will be erased with the next WM_PAINT message. Therefore you cannot cache the graphics object for reuse, except to use non-visual methods like xtd::drawing::graphics::measure_string. Instead, you must call create_graphics every time that you want to use the graphics object.

◆ destroy_control()

virtual void xtd::forms::control::destroy_control ( )
virtual

Forces the destruction of the visible control, including the destruction of the handle and any visible child controls.

Remarks
The destroy_control method forces a handle to be destroyed for the control and its child controls.
Notes to Inheritors
When overriding destroy_control() in a derived class, be sure to call the base class's destroy_control() method to ensure that the handle is destroyed.

◆ end_invoke()

std::optional< object_ref > xtd::forms::control::end_invoke ( xtd::async_result  async)
overridevirtual

Retrieves the return value of the asynchronous operation represented by the async_result_invoke passed.

Parameters
asyncThe async_result_invoke that represents a specific invoke asynchronous operation, returned when calling begin_invoke(delegate).

Implements xtd::isynchronize_invoke.

◆ focus()

bool xtd::forms::control::focus ( )

Sets input focus to the control.

Returns
true if the input focus request was successful; otherwise, false.
Remarks
The focus method returns true if the control successfully received input focus. The control can have the input focus while not displaying any visual cues of having the focus. This behavior is primarily observed by the unselectable controls listed below, or any controls derived from them.
Examples
wiggly.cpp.

◆ get_auto_size_mode()

auto_size_mode xtd::forms::control::get_auto_size_mode ( ) const

Gets a value indicating how a control will behave when its auto_size property is enabled.

Returns
auto_size_mode One of the xtd::forms::auto_size_mode values.

◆ get_child_index() [1/2]

size_t xtd::forms::control::get_child_index ( intptr  child) const

Retrieves the index of a control within the control collection.

Parameters
childThe control to search for in the control collection.
Returns
A zero-based index value that represents the location of the specified child control within the control collection.
Exceptions
xtd::argument_exceptionThe child control is not in the control::control_collection.

◆ get_child_index() [2/2]

size_t xtd::forms::control::get_child_index ( intptr  child,
bool &  throw_exception 
) const

Retrieves the index of the specified child control within the control collection, and optionally raises an exception if the specified control is not within the control collection.

Parameters
childThe control to search for in the control collection.
throw_exceptiontrue to throw an exception if the control specified in the child parameter is not a control in the control::control_collection; otherwise, false.

◆ hide()

virtual void xtd::forms::control::hide ( )
virtual

Conceals the control from the user.

Remarks
Hiding the control is equivalent to setting the visible property to false. After the hide method is called, the visible property returns a value of false until the show method is called.

◆ invalidate() [1/6]

virtual void xtd::forms::control::invalidate ( ) const
virtual

Invalidates the entire surface of the control and causes the control to be redrawn.

Remarks
Calling the invalidate method does not force a synchronous paint; to force a synchronous paint, call the update method after calling the Invalidate method. When this method is called with no parameters, the entire client area is added to the update region.

◆ invalidate() [2/6]

virtual void xtd::forms::control::invalidate ( bool  invalidate_children) const
virtual

Invalidates a specific region of the control and causes a paint message to be sent to the control. Optionally, invalidates the child controls assigned to the control.

Parameters
invalidate_childrentrue to invalidate the control's child controls; otherwise, false.
Remarks
Calling the invalidate method does not force a synchronous paint; to force a synchronous paint, call the update method after calling the Invalidate method. When this method is called with no parameters, the entire client area is added to the update region.

◆ invalidate() [3/6]

virtual void xtd::forms::control::invalidate ( const drawing::rectangle rect) const
virtual

Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control.

Parameters
rectA xtd::drawing::rectangle that represents the region to invalidate.
Remarks
Calling the invalidate method does not force a synchronous paint; to force a synchronous paint, call the update method after calling the Invalidate method. When this method is called with no parameters, the entire client area is added to the update region.

◆ invalidate() [4/6]

virtual void xtd::forms::control::invalidate ( const drawing::rectangle rect,
bool  invalidate_children 
) const
virtual

Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control. Optionally, invalidates the child controls assigned to the control.

Parameters
rectA xtd::drawing::rectangle that represents the region to invalidate.
invalidate_childrentrue to invalidate the control's child controls; otherwise, false.
Remarks
Calling the invalidate method does not force a synchronous paint; to force a synchronous paint, call the update method after calling the Invalidate method. When this method is called with no parameters, the entire client area is added to the update region.

◆ invalidate() [5/6]

virtual void xtd::forms::control::invalidate ( const drawing::region region) const
virtual

Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control.

Parameters
regionA xtd::drawing::region that represents the region to invalidate.
Remarks
Calling the invalidate method does not force a synchronous paint; to force a synchronous paint, call the update method after calling the Invalidate method. When this method is called with no parameters, the entire client area is added to the update region.

◆ invalidate() [6/6]

virtual void xtd::forms::control::invalidate ( const drawing::region region,
bool  invalidate_children 
) const
virtual

Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control. Optionally, invalidates the child controls assigned to the control.

Parameters
regionA xtd::drawing::region that represents the region to invalidate.
invalidate_childrentrue to invalidate the control's child controls; otherwise, false.
Remarks
Calling the invalidate method does not force a synchronous paint; to force a synchronous paint, call the update method after calling the Invalidate method. When this method is called with no parameters, the entire client area is added to the update region.

◆ invoke() [1/6]

std::optional< object_ref > xtd::forms::control::invoke ( delegate< void()>  method)
overridevirtual

Executes the specified delegate on the thread that owns the control's underlying window handle.

Parameters
methodA delegate that contains a method to be called in the control's thread context.

Implements xtd::isynchronize_invoke.

◆ invoke() [2/6]

std::optional< object_ref > xtd::forms::control::invoke ( delegate< void(std::vector< std::any >)>  method,
const std::vector< std::any > &  args 
)
overridevirtual

Executes the specified delegate, on the thread that owns the control's underlying window handle, with the specified list of arguments.

Parameters
methodA delegate to a method that takes parameters of the same number and type that are contained in the args parameter.
argsAn array of objects to pass as arguments to the specified method. This parameter can be null if the method takes no arguments.

Implements xtd::isynchronize_invoke.

◆ invoke() [3/6]

std::optional< object_ref > xtd::forms::control::invoke ( delegate< void(std::vector< std::any >)>  method,
std::any  arg 
)
overridevirtual

Executes the specified delegate, on the thread that owns the control's underlying window handle, with the specified list of arguments.

Parameters
methodA delegate to a method that takes parameters of the same number and type that are contained in the args parameter.
argsAn array of objects to pass as arguments to the specified method. This parameter can be null if the method takes no arguments.

Implements xtd::isynchronize_invoke.

◆ perform_layout()

void xtd::forms::control::perform_layout ( )

Forces the control to apply layout logic to all its child controls.

Remarks
If the suspend_layout method was called before calling the perform_layout method, the xtd::forms::control::layout event is suppressed.

◆ point_to_client()

xtd::drawing::point xtd::forms::control::point_to_client ( const xtd::drawing::point p) const

Computes the location of the specified screen point into client coordinates.

Parameters
pThe screen coordinate xtd::drawing::point to convert.
Returns
A xtd::drawing::point that represents the converted xtd::drawing::point, p, in client coordinates.

◆ point_to_screen()

xtd::drawing::point xtd::forms::control::point_to_screen ( const xtd::drawing::point p) const

Computes the location of the specified client point into screen coordinates.

Parameters
pThe client coordinate xtd::drawing::point to convert.
Returns
A xtd::drawing::point that represents the converted xtd::drawing::point, p, in screen coordinates.

◆ post_message()

bool xtd::forms::control::post_message ( intptr  hwnd,
int32  msg,
intptr  wparam,
intptr  lparam 
) const

Places (posts) a message in the message queue with specified hwnd, message, wparam and lparam.

Parameters
hwndThe window handle of the message.
msgThe ID number for the message.
wparamThe WParam field of the message.
lparamThe LParam field of the message.
Returns
true if message posted; otherwhise false.

◆ pre_process_message()

virtual bool xtd::forms::control::pre_process_message ( const xtd::forms::message message)
virtual

Preprocesses keyboard or input messages within the message loop before they are dispatched.

Parameters
messageA xtd::forms::message, passed by reference, that represents the message to process. The possible values are WM_KEYDOWN, WM_SYSKEYDOWN, WM_CHAR, and WM_SYSCHAR.
Returns
true if the message was processed by the control; otherwise, false.
Remarks
pre_process_message is called by the application's message loop to preprocess input messages before they are dispatched. Possible values for the msg parameter are WM_KEYDOWN, WM_SYSKEYDOWN, WM_CHAR, and WM_SYSCHAR.

Reimplemented in xtd::forms::form.

◆ refresh()

virtual void xtd::forms::control::refresh ( ) const
virtual

Forces the control to invalidate its client area and immediately redraw itself and any child controls.

Notes to Inheritors
When overriding refresh() in a derived class, be sure to call the base class's refresh() method so the control and its child controls are invalidated and redrawn.

◆ resume_layout() [1/2]

void xtd::forms::control::resume_layout ( )

Resumes usual layout logic.

Remarks
Calling the resume_layout method forces an immediate layout if there are any pending layout requests.
The suspend_layout and resume_layout methods are used in tandem to suppress multiple layout events while you adjust multiple attributes of the control. For example, you would typically call the suspend_layout method, then set the size, location, anchor, or dock properties of the control, and then call the resume_layout method to enable the changes to take effect.
There must be no pending calls to suspend_layout for resume_layout to be successfully called.

◆ resume_layout() [2/2]

void xtd::forms::control::resume_layout ( bool  perform_layout)

Resumes usual layout logic, optionally forcing an immediate layout of pending layout requests.

Parameters
perform_layouttrue to execute pending layout requests; otherwise, false.
Remarks
Calling the resume_layout method forces an immediate layout if there are any pending layout requests. When the perform_layout parameter is set to true, an immediate layout occurs if there are any pending layout requests.
The suspend_layout and resume_layout methods are used in tandem to suppress multiple xtd::forms::control::layout events while you adjust multiple attributes of the control. For example, you would typically call the suspend_layout method, then set the size, location, anchor, or dock properties of the control, and then call the resume_layout method to enable the changes to take effect.
There must be no pending calls to suspend_layout for resume_layout to be successfully called.
Note
When adding several controls to a parent control, it is recommended that you call the suspend_layout method before initializing the controls to be added. After adding the controls to the parent control, call the resume_layout method. This will increase the performance of applications with many controls.

◆ send_message()

intptr xtd::forms::control::send_message ( intptr  hwnd,
int32  msg,
intptr  wparam,
intptr  lparam 
) const

Send a message with specified hwnd, message, wparam and lparam.

Parameters
hwndThe window handle of the message.
msgThe ID number for the message.
wparamThe WParam field of the message.
lparamThe LParam field of the message.
Returns
The return value of the message.

◆ set_auto_size_mode()

void xtd::forms::control::set_auto_size_mode ( auto_size_mode  auto_size_mode)

Sets a value indicating how a control will behave when its auto_size property is enabled.

Parameters
auto_size_modeOne of the xtd::forms::auto_size_mode values.

◆ set_bounds() [1/2]

void xtd::forms::control::set_bounds ( int32  x,
int32  y,
int32  width,
int32  height 
)

Sets the bounds of the control to the specified location and size.

Parameters
xThe new left property value of the control.
yThe new top property value of the control.
widthThe new width property value of the control.
heightThe new height property value of the control.

◆ set_bounds() [2/2]

void xtd::forms::control::set_bounds ( int32  x,
int32  y,
int32  width,
int32  height,
bounds_specified  specified 
)

Sets the specified bounds of the control to the specified location and size.

Parameters
xThe new left property value of the control.
yThe new top property value of the control.
widthThe new width property value of the control.
heightThe new height property value of the control.
specifiedA bitwise combination of the xtd::forms::bounds_specified values. For any parameter not specified, the current value will be used.

◆ show()

virtual void xtd::forms::control::show ( )
virtual

Displays the control to the user.

Remarks
Showing the control is equivalent to setting the visible property to true. After the show method is called, the visible property returns a value of true until the hide method is called.

◆ suspend_layout()

void xtd::forms::control::suspend_layout ( )

Temporarily suspends the layout logic for the control.

Remarks
The layout logic of the control is suspended until the resume_layout method is called.
The suspend_layout and resume_layout methods are used in tandem to suppress multiple xtd::forms::control::layout events while you adjust multiple attributes of the control. For example, you would typically call the suspend_layout method, then set the size, location, anchor, or dock properties of the control, and then call the resume_layout method to enable the changes to take effect.
There must be no pending calls to suspend_layout for resume_layout to be successfully called.
Note
When adding several controls to a parent control, it is recommended that you call the suspend_layout method before initializing the controls to be added. After adding the controls to the parent control, call the resume_layout method. This will increase the performance of applications with many controls.

◆ to_string()

xtd::string xtd::forms::control::to_string ( ) const
overridevirtualnoexcept

Returns a string containing the name of the control, if any.

Returns
A string containing the name of the control, if any, or class name if the control is unnamed.

Reimplemented from xtd::object.

Reimplemented in xtd::forms::month_calendar, xtd::forms::numeric_up_down, xtd::forms::progress_bar, xtd::forms::radio_button, xtd::forms::track_bar, and xtd::forms::up_down_button.

◆ update()

virtual void xtd::forms::control::update ( ) const
virtual

Causes the control to redraw the invalidated regions within its client area.

Remarks
Executes any pending requests for painting.
There are two ways to repaint a form and its contents:
  • You can use one of the overloads of the invalidate method with the update method.
  • You can call the refresh method, which forces the control to redraw itself and all its children. This is equivalent to setting the invalidate method to true and using it with update.
The invalidate method governs what gets painted or repainted. The update method governs when the painting or repainting occurs. If you use the invalidate and update methods together rather than calling refresh, what gets repainted depends on which overload of invalidate you use. The update method just forces the control to be painted immediately, but the invalidate method governs what gets painted when you call the update method.

◆ operator<<()

control & xtd::forms::control::operator<< ( control child)

Add child control.

Parameters
parentA control that represents the parent or container control of the control.
childA control to add to parent.
Returns
Current control.

◆ operator>>()

control & xtd::forms::control::operator>> ( control child)

Remove child control.

Parameters
parentA control that represents the parent or container control of the control.
childA control to remove to parent.
Returns
Current control.

◆ create() [1/24]

static control xtd::forms::control::create ( )
static

A factory to create a specified control.

Returns
New control created.

◆ create() [2/24]

static control xtd::forms::control::create ( const drawing::point location)
static

A factory to create a specified control with specified location.

Parameters
locationA xtd::drawing::point that represent location of the control.
Returns
New control created.

◆ create() [3/24]

static control xtd::forms::control::create ( const drawing::point location,
const drawing::size size 
)
static

A factory to create a specified control with specified location, and size.

Parameters
locationA xtd::drawing::point that represent location of the control.
sizeA xtd::drawing::size that represent size of the control.
Returns
New control created.

◆ create() [4/24]

static control xtd::forms::control::create ( const drawing::point location,
const drawing::size size,
const xtd::string name 
)
static

A factory to create a specified control with specified location, size, and name.

Parameters
locationA xtd::drawing::point that represent location of the control.
sizeA xtd::drawing::size that represent size of the control.
nameThe name of the control.
Returns
New control created.

◆ create() [5/24]

static control xtd::forms::control::create ( const control paren)
static

A factory to create a specified control with specified parent.

Parameters
parentThe parent that contains the new created control.
Returns
New control created.

◆ create() [6/24]

static control xtd::forms::control::create ( const control parent,
const drawing::point location 
)
static

A factory to create a specified control with specified parent, location, size, and name.

Parameters
parentThe parent that contains the new created control.
locationA xtd::drawing::point that represent location of the control.
sizeA xtd::drawing::size that represent size of the control.
nameThe name of the control.
Returns
New control created.

◆ create() [7/24]

static control xtd::forms::control::create ( const control parent,
const drawing::point location,
const drawing::size size 
)
static

A factory to create a specified control with specified parent, location, and size.

Parameters
parentThe parent that contains the new created control.
locationA xtd::drawing::point that represent location of the control.
sizeA xtd::drawing::size that represent size of the control.
Returns
New control created.

◆ create() [8/24]

static control xtd::forms::control::create ( const control parent,
const drawing::point location,
const drawing::size size,
const xtd::string name 
)
static

A factory to create a specified control with specified parent, location, size, and name.

Parameters
parentThe parent that contains the new created control.
locationA xtd::drawing::point that represent location of the control.
sizeA xtd::drawing::size that represent size of the control.
nameThe name of the control.
Returns
New control created.

◆ create() [9/24]

template<typename control_t >
static control_t xtd::forms::control::create ( )
inlinestatic

A factory to create a specified control.

Returns
New control created.

◆ create() [10/24]

template<typename control_t >
static control_t xtd::forms::control::create ( const drawing::point location)
inlinestatic

A factory to create a specified control with specified location.

Parameters
locationA xtd::drawing::point that represent location of the control.
Returns
New control created.

◆ create() [11/24]

template<typename control_t >
static control_t xtd::forms::control::create ( const drawing::point location,
const drawing::size size 
)
inlinestatic

A factory to create a specified control with specified location, and size.

Parameters
locationA xtd::drawing::point that represent location of the control.
sizeA xtd::drawing::size that represent size of the control.
Returns
New control created.

◆ create() [12/24]

template<typename control_t >
static control_t xtd::forms::control::create ( const drawing::point location,
const drawing::size size,
const xtd::string name 
)
inlinestatic

A factory to create a specified control with specified location, size, and name.

Parameters
locationA xtd::drawing::point that represent location of the control.
sizeA xtd::drawing::size that represent size of the control.
nameThe name of the control.
Returns
New control created.

◆ create() [13/24]

template<typename control_t >
static control_t xtd::forms::control::create ( const control parent)
inlinestatic

A factory to create a specified control with specified parent.

Parameters
parentThe parent that contains the new created control.
Returns
New control created.

◆ create() [14/24]

template<typename control_t >
static control_t xtd::forms::control::create ( const control parent,
const drawing::point location 
)
inlinestatic

A factory to create a specified control with specified parent, and location.

Parameters
parentThe parent that contains the new created control.
locationA xtd::drawing::point that represent location of the control.
Returns
New control created.

◆ create() [15/24]

template<typename control_t >
static control_t xtd::forms::control::create ( const control parent,
const drawing::point location,
const drawing::size size 
)
inlinestatic

A factory to create a specified control with specified parent, location, and size.

Parameters
parentThe parent that contains the new created control.
locationA xtd::drawing::point that represent location of the control.
sizeA xtd::drawing::size that represent size of the control.
Returns
New control created.

◆ create() [16/24]

template<typename control_t >
static control_t xtd::forms::control::create ( const control parent,
const drawing::point location,
const drawing::size size,
const xtd::string name 
)
inlinestatic

A factory to create a specified control with specified parent, location, size, and name.

Parameters
parentThe parent that contains the new created control.
locationA xtd::drawing::point that represent location of the control.
sizeA xtd::drawing::size that represent size of the control.
nameThe name of the control.
Returns
New control created.

◆ create() [17/24]

template<typename control_t >
static control_t xtd::forms::control::create ( const xtd::string text)
inlinestatic

A factory to create a specified control with specified text.

Parameters
textA string that represent text of the control.
Returns
New control created.

◆ create() [18/24]

template<typename control_t >
static control_t xtd::forms::control::create ( const xtd::string text,
const drawing::point location 
)
inlinestatic

A factory to create a specified control with specified text, and location.

Parameters
textA string that represent text of the control.
locationA xtd::drawing::point that represent location of the control.
Returns
New control created.

◆ create() [19/24]

template<typename control_t >
static control_t xtd::forms::control::create ( const xtd::string text,
const drawing::point location,
const drawing::size size 
)
inlinestatic

A factory to create a specified control with specified text, location, and size.

Parameters
textA string that represent text of the control.
locationA xtd::drawing::point that represent location of the control.
sizeA xtd::drawing::size that represent size of the control.
Returns
New control created.

◆ create() [20/24]

template<typename control_t >
static control_t xtd::forms::control::create ( const xtd::string text,
const drawing::point location,
const drawing::size size,
const xtd::string name 
)
inlinestatic

A factory to create a specified control with specified text, location,size, and name.

Parameters
textA string that represent text of the control.
locationA xtd::drawing::point that represent location of the control.
sizeA xtd::drawing::size that represent size of the control.
nameThe name of the control.
Returns
New control created.

◆ create() [21/24]

template<typename control_t >
static control_t xtd::forms::control::create ( const control parent,
const xtd::string text 
)
inlinestatic

A factory to create a specified control with specified parent, and text.

Parameters
parentThe parent that contains the new created control.
textA string that represent text of the control.
Returns
New control created.

◆ create() [22/24]

template<typename control_t >
static control_t xtd::forms::control::create ( const control parent,
const xtd::string text,
const drawing::point location 
)
inlinestatic

A factory to create a specified control with specified parent, text, and location.

Parameters
parentThe parent that contains the new created control.
textA string that represent text of the control.
locationA xtd::drawing::point that represent location of the control.
Returns
New control created.

◆ create() [23/24]

template<typename control_t >
static control_t xtd::forms::control::create ( const control parent,
const xtd::string text,
const drawing::point location,
const drawing::size size 
)
inlinestatic

A factory to create a specified control with specified parent, text, location, and size.

Parameters
parentThe parent that contains the new created control.
textA string that represent text of the control.
locationA xtd::drawing::point that represent location of the control.
sizeA xtd::drawing::size that represent size of the control.
Returns
New control created.

◆ create() [24/24]

template<typename control_t >
static control_t xtd::forms::control::create ( const control parent,
const xtd::string text,
const drawing::point location,
const drawing::size size,
const xtd::string name 
)
inlinestatic

A factory to create a specified control with specified parent, text, location, size, and name.

Parameters
parentThe parent that contains the new created control.
textA string that represent text of the control.
locationA xtd::drawing::point that represent location of the control.
sizeA xtd::drawing::size that represent size of the control.
nameThe name of the control.
Returns
New control created.

◆ from_child_handle()

static std::optional< control_ref > xtd::forms::control::from_child_handle ( intptr  handle)
static

Retrieves the control that contains the specified handle.

Parameters
handleThe window handle (HWND) to search for.
Returns
The control that represents the control associated with the specified handle; returns null if no control with the specified handle is found.
Remarks
This method searches up the window handle parent chain until it finds a handle that is associated with a control. This method is more reliable than the from_handle method, because it correctly returns controls that own more than one handle.

◆ from_handle()

static std::optional< control_ref > xtd::forms::control::from_handle ( intptr  handle)
static

Returns the control that is currently associated with the specified handle.

Parameters
handleThe window handle (HWND) to search for.
Returns
A control that represents the control associated with the specified handle; returns null if no control with the specified handle is found.

◆ control_state()

xtd::forms::visual_styles::control_state xtd::forms::control::control_state ( ) const
protectednoexcept

Gets state.

Returns
One of xtd::forms::visual_styles::control_state values.

◆ create_params()

virtual forms::create_params xtd::forms::control::create_params ( ) const
protectedvirtualnoexcept

Gets the required creation parameters when the control handle is created.

Returns
A create_params that contains the required creation parameters when the handle to the control is created.
Remarks
The create_params property should not be overridden and used to adjust the properties of your derived control. Properties such as the create_params::caption, create_params::width, and create_params::height should be set by the corresponding properties in your control such as control::text, control::width and control::height. The create_params should only be extended when you are wrapping a standard Windows control class or to set styles not provided by the forms namespace.
Notes for inheritors
When overriding the create_params property in a derived class, use the base class's create_params property to extend the base implementation. Otherwise, you must provide all the implementation.

Reimplemented in xtd::forms::button, xtd::forms::button_base, xtd::forms::check_box, xtd::forms::checked_list_box, xtd::forms::choice, xtd::forms::collapsible_panel, xtd::forms::color_picker, xtd::forms::combo_box, xtd::forms::command_link_button, xtd::forms::date_time_picker, xtd::forms::domain_up_down, xtd::forms::font_picker, xtd::forms::form, xtd::forms::group_box, xtd::forms::h_scroll_bar, xtd::forms::label, xtd::forms::light_button, xtd::forms::list_box, xtd::forms::loading_indicator, xtd::forms::month_calendar, xtd::forms::numeric_up_down, xtd::forms::panel, xtd::forms::picture_box, xtd::forms::popup_panel, xtd::forms::progress_bar, xtd::forms::radio_button, xtd::forms::scroll_bar, xtd::forms::scrollable_control, xtd::forms::status_bar, xtd::forms::tab_control, xtd::forms::tab_page, xtd::forms::text_box, xtd::forms::text_box_base, xtd::forms::toggle_button, xtd::forms::tool_bar, xtd::forms::track_bar, xtd::forms::up_down_base, xtd::forms::up_down_button, xtd::forms::user_control, and xtd::forms::v_scroll_bar.

◆ default_back_color()

virtual drawing::color xtd::forms::control::default_back_color ( ) const
protectedvirtualnoexcept

Gets the default background color of the control.

Returns
The default background color of the control. The default is control.
Remarks
This is the default back_color property value of a generic top-level control. Derived classes can have different defaults.

Reimplemented in xtd::forms::date_time_picker, xtd::forms::domain_up_down, xtd::forms::list_box, xtd::forms::list_control, xtd::forms::month_calendar, xtd::forms::numeric_up_down, and xtd::forms::text_box.

◆ default_cursor()

virtual forms::cursor xtd::forms::control::default_cursor ( ) const
protectedvirtualnoexcept

Gets the default cursor for the control.

Returns
An object of type xtd::forms::cursor representing the current default cursor.

Reimplemented in xtd::forms::splitter, and xtd::forms::text_box_base.

◆ default_font()

virtual drawing::font xtd::forms::control::default_font ( ) const
protectedvirtualnoexcept

Gets the default font of the control.

Returns
The default font of the control. The value returned will vary depending on the user's operating system the local culture setting of their system.

Reimplemented in xtd::forms::status_bar, and xtd::forms::tool_bar.

Examples
test_forms.cpp.

◆ default_fore_color()

virtual drawing::color xtd::forms::control::default_fore_color ( ) const
protectedvirtualnoexcept

Gets the default foreground color of the control.

Returns
The default foreground color of the control. The default is control_text.

Reimplemented in xtd::forms::date_time_picker, xtd::forms::domain_up_down, xtd::forms::list_box, xtd::forms::list_control, xtd::forms::month_calendar, xtd::forms::numeric_up_down, and xtd::forms::text_box.

◆ default_size()

◆ clone()

xtd::uptr< xtd::object > xtd::forms::control::clone ( ) const
overrideprotectedvirtual

◆ create_handle()

virtual void xtd::forms::control::create_handle ( )
protectedvirtual

Creates a handle for the control.

Remarks
You typically should not call the create_handle method directly. The preferred method is to call the create_control method, which forces a handle to be created for the control and its child controls when the control is created.
Notes to Inheritors
When overriding create_handle() in a derived class, be sure to call the base class's create_handle() method to ensure that the handle is created.

◆ destroy_handle()

virtual void xtd::forms::control::destroy_handle ( )
protectedvirtual

Destroys the handle associated with the control.

Notes to Inheritors
When overriding destroy_handle() in a derived class, be sure to call the base class's destroy_handle() method to ensure that the handle is destroyed.

Reimplemented in xtd::forms::tab_page.

◆ def_wnd_proc()

virtual void xtd::forms::control::def_wnd_proc ( message message)
protectedvirtual

Sends the specified message to the default window procedure.

Parameters
messageThe Windows Message to process.

◆ get_style()

bool xtd::forms::control::get_style ( control_styles  flag) const
protectednoexcept

Retrieves the value of the specified control style bit for the control.

Parameters
flagThe control_styles bit to return the value from.
Returns
true if the specified control style bit is set to true; otherwise, false.
Remarks
Control style bit flags are used to categorize supported behavior. A control can enable a style by calling the set_style method and passing in the appropriate control_styles bit and the bool value to set the bit to. To determine the value assigned to a specified control_styles bit, use the get_style method and pass in the control_styles member to evaluate.

◆ measure_control()

◆ measure_text()

drawing::size xtd::forms::control::measure_text ( ) const
protectednoexcept

Measure this control text.

Returns
The drawing::size size of this control text.

◆ on_auto_size_changed()

virtual void xtd::forms::control::on_auto_size_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::auto_size_changed event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_back_color_changed()

virtual void xtd::forms::control::on_back_color_changed ( const event_args e)
protectedvirtual

◆ on_background_image_changed()

virtual void xtd::forms::control::on_background_image_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::background_image_changed event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_background_image_layout_changed()

virtual void xtd::forms::control::on_background_image_layout_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::background_image_layout_changed event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_control_appearance_changed()

virtual void xtd::forms::control::on_control_appearance_changed ( const event_args e)
protectedvirtual

Raises the control::control_appearance_changed event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_click()

virtual void xtd::forms::control::on_click ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::click event.

Parameters
eAn xtd::event_args that contains the event data.

Reimplemented in xtd::forms::button.

◆ on_client_size_changed()

virtual void xtd::forms::control::on_client_size_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::client_size_changed event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_control_added()

virtual void xtd::forms::control::on_control_added ( const control_event_args e)
protectedvirtual

◆ on_control_removed()

virtual void xtd::forms::control::on_control_removed ( const control_event_args e)
protectedvirtual

◆ on_create_control()

virtual void xtd::forms::control::on_create_control ( )
protectedvirtual

Raises the xtd::forms::control::create_control event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_cursor_changed()

virtual void xtd::forms::control::on_cursor_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::cursor_changed event.

Parameters
eAn xtd::event_args that contains the event data.

Reimplemented in xtd::forms::link_label.

◆ on_destroy_control()

virtual void xtd::forms::control::on_destroy_control ( )
protectedvirtual

Raises the xtd::forms::control::destroy_control event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_dock_changed()

virtual void xtd::forms::control::on_dock_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::dock_changed event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_double_click()

virtual void xtd::forms::control::on_double_click ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::double_click event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_enabled_changed()

virtual void xtd::forms::control::on_enabled_changed ( const event_args e)
protectedvirtual

◆ on_fore_color_changed()

virtual void xtd::forms::control::on_fore_color_changed ( const event_args e)
protectedvirtual

◆ on_font_changed()

virtual void xtd::forms::control::on_font_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::font_changed event.

Parameters
eAn xtd::event_args that contains the event data.

Reimplemented in xtd::forms::button_base, xtd::forms::group_box, and xtd::forms::label.

◆ on_got_focus()

virtual void xtd::forms::control::on_got_focus ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::got_focus event.

Parameters
eAn xtd::event_args that contains the event data.

Reimplemented in xtd::forms::radio_button.

◆ on_handle_created()

◆ on_handle_destroyed()

virtual void xtd::forms::control::on_handle_destroyed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::handle_destroyed event.

Parameters
eAn xtd::event_args that contains the event data.

Reimplemented in xtd::forms::form, xtd::forms::status_bar, and xtd::forms::tool_bar.

◆ on_help_requested()

virtual void xtd::forms::control::on_help_requested ( help_event_args e)
protectedvirtual

Raises the xtd::forms::control::help_requested event.

Parameters
eA xtd::forms::help_event_args that contains the event data.

◆ on_key_down()

virtual void xtd::forms::control::on_key_down ( key_event_args e)
protectedvirtual

Raises the xtd::forms::control::key_down event.

Parameters
eAn xtd::event_args that contains the event data.
Examples
test_forms.cpp.

◆ on_key_press()

virtual void xtd::forms::control::on_key_press ( key_press_event_args e)
protectedvirtual

Raises the xtd::forms::control::key_press event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_key_up()

virtual void xtd::forms::control::on_key_up ( key_event_args e)
protectedvirtual

Raises the xtd::forms::control::key_up event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_layout()

◆ on_location_changed()

virtual void xtd::forms::control::on_location_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::location_changed event.

Parameters
eAn xtd::event_args that contains the event data.

Reimplemented in xtd::forms::form.

◆ on_lost_focus()

virtual void xtd::forms::control::on_lost_focus ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::lost_focus event.

Parameters
eAn xtd::event_args that contains the event data.

Reimplemented in xtd::forms::domain_up_down, xtd::forms::numeric_up_down, and xtd::forms::radio_button.

◆ on_mouse_click()

virtual void xtd::forms::control::on_mouse_click ( const mouse_event_args e)
protectedvirtual

Raises the xtd::forms::control::mouse_click event.

Parameters
eAn xtd::event_args that contains the event data.

Reimplemented in xtd::forms::link_label.

◆ on_mouse_double_click()

virtual void xtd::forms::control::on_mouse_double_click ( const mouse_event_args e)
protectedvirtual

Raises the xtd::forms::control::mouse_double_click event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_mouse_down()

virtual void xtd::forms::control::on_mouse_down ( const mouse_event_args e)
protectedvirtual

◆ on_mouse_enter()

virtual void xtd::forms::control::on_mouse_enter ( const event_args e)
protectedvirtual

◆ on_mouse_horizontal_wheel()

virtual void xtd::forms::control::on_mouse_horizontal_wheel ( const mouse_event_args e)
protectedvirtual

Raises the xtd::forms::control::mouse_horizontal_wheel event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_mouse_leave()

virtual void xtd::forms::control::on_mouse_leave ( const event_args e)
protectedvirtual

◆ on_mouse_move()

virtual void xtd::forms::control::on_mouse_move ( const mouse_event_args e)
protectedvirtual

Raises the xtd::forms::control::mouse_move event.

Parameters
eAn xtd::event_args that contains the event data.

Reimplemented in xtd::forms::radio_button, xtd::forms::splitter, and xtd::forms::link_label.

◆ on_mouse_up()

virtual void xtd::forms::control::on_mouse_up ( const mouse_event_args e)
protectedvirtual

◆ on_mouse_wheel()

virtual void xtd::forms::control::on_mouse_wheel ( const mouse_event_args e)
protectedvirtual

Raises the xtd::forms::control::mouse_wheel event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_move()

virtual void xtd::forms::control::on_move ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::move event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_paint()

◆ on_paint_background()

virtual void xtd::forms::control::on_paint_background ( paint_event_args e)
protectedvirtual

Paints the background of the xtd::forms::control.

Parameters
eAn xtd::event_args that contains the event data.
Remarks
The xtd::forms::control::on_paint_background method enables derived classes to handle Windows background erase requests.

◆ on_parent_back_color_changed()

virtual void xtd::forms::control::on_parent_back_color_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::parent_back_color_changed event.

Parameters
eAn xtd::event_args that contains the event data.

Reimplemented in xtd::forms::button_base.

◆ on_parent_cursor_changed()

virtual void xtd::forms::control::on_parent_cursor_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::parent_cursor_changed event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_parent_changed()

virtual void xtd::forms::control::on_parent_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::parent_changed event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_parent_enabled_changed()

virtual void xtd::forms::control::on_parent_enabled_changed ( const event_args e)
protectedvirtual

Raises the xtd::control::enabled_changed event when the xtd::control::enabled property value of the control's container changes..

Parameters
eAn xtd::event_args that contains the event data.

Reimplemented in xtd::forms::seven_segment_display.

◆ on_parent_fore_color_changed()

virtual void xtd::forms::control::on_parent_fore_color_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::parent_fore_color_changed event.

Parameters
eAn xtd::event_args that contains the event data.

Reimplemented in xtd::forms::button_base.

◆ on_parent_font_changed()

virtual void xtd::forms::control::on_parent_font_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::parent_font_changed event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_resize()

virtual void xtd::forms::control::on_resize ( const event_args e)
protectedvirtual

◆ on_region_changed()

virtual void xtd::forms::control::on_region_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::region_changed event.

Parameters
eAn xtd::event_args that contains the event data.

Reimplemented in xtd::forms::form, and xtd::forms::popup_panel.

◆ on_right_to_left_changed()

virtual void xtd::forms::control::on_right_to_left_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::right_to_left_changed event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_size_changed()

virtual void xtd::forms::control::on_size_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::size_changed event.

Parameters
eAn xtd::event_args that contains the event data.

Reimplemented in xtd::forms::lcd_label.

◆ on_style_sheet_changed()

virtual void xtd::forms::control::on_style_sheet_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::style_sheet_changed event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_system_colors_changed()

virtual void xtd::forms::control::on_system_colors_changed ( const event_args e)
protectedvirtual

Raises the control::system_colors_changed event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_tab_stop_changed()

virtual void xtd::forms::control::on_tab_stop_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::tab_stop_changed event.

Parameters
eAn xtd::event_args that contains the event data.

◆ on_text_changed()

virtual void xtd::forms::control::on_text_changed ( const event_args e)
protectedvirtual

◆ on_visible_changed()

virtual void xtd::forms::control::on_visible_changed ( const event_args e)
protectedvirtual

Raises the xtd::forms::control::visible_changed event.

Parameters
eAn xtd::event_args that contains the event data.

◆ recreate_handle()

virtual void xtd::forms::control::recreate_handle ( )
protectedvirtual

Forces the re-creation of the handle for the control.

Remarks
The recreate_handle method is called whenever parameters are needed for a new control, but using a call from update_styles to create_params is insufficient. This method also calls destroy_handle and create_handle and sets recreating_handle to true.

◆ set_bounds_core()

virtual void xtd::forms::control::set_bounds_core ( int32  x,
int32  y,
int32  width,
int32  height,
bounds_specified  specified 
)
protectedvirtual

Performs the work of setting the specified bounds of this control.

Parameters
xThe new left property value of the control.
yThe new top property value of the control.
widthThe new width property value of the control.
heightThe new height property value of the control.
specifiedA bitwise combination of the bounds_specified values.
Remarks
Typically, the parameters that correspond to the bounds not included in the specified parameter are passed in with their current values. For example, the height, width, or the y or y properties of the location property can be passed in with a reference to the current instance of the control. However all values passed in are honored and applied to the control.
The specified parameter represents the elements of the controls Bounds changed by your application. For example, if you change the size of the control, the specified parameter value is the size value of bounds_specified. However, if the size is adjusted in response to the dock property being set, the specified parameter value is the none value of bounds_specified.
Notes to Inheritors
When overriding set_bounds_core(int32, int32, int32, int32, bounds_specified) in a derived class, be sure to call the base class's set_bounds_core(int32, int32, int32, int32, bounds_specified) method to force the bounds of the control to change. Derived classes can add size restrictions to the set_bounds_core(int32, int32, int32, int32, bounds_specified) method.

Reimplemented in xtd::forms::choice, xtd::forms::seven_segment_display, and xtd::forms::track_bar.

◆ set_can_focus()

void xtd::forms::control::set_can_focus ( bool  value)
protected

Sets a value indicating whether the control can receive focus.

Parameters
valuetrue if the control can receive focus; otherwise, false.
Remarks
In order for a control to receive input focus, the control must have a handle assigned to it, and the visible and enabled properties must both be set to true for both the control and all its parent controls, and the control must be a form or the control's outermost parent must be a form.

◆ set_text()

virtual void xtd::forms::control::set_text ( const xtd::string text)
protectedvirtual

Sets the text associated with this control.

Parameters
textThe text associated with this control.
Returns
Current control.

◆ set_client_size_core()

virtual void xtd::forms::control::set_client_size_core ( int32  width,
int32  height 
)
protectedvirtual

Sets the size of the client area of the control.

Parameters
widthThe client area width, in pixels.
heightThe client area height, in pixels.
Remarks
The client area starts at the (0, 0) location and extends to the (width, height) location.
Typically, you should not set the client_size of the control.
Notes to Inheritors
When overriding set_client_size_core(int32, int32) in a derived class, be sure to call the base class's set_client_size_core(int32, int32) method so that the client_size property is adjusted.

Reimplemented in xtd::forms::choice, xtd::forms::seven_segment_display, and xtd::forms::track_bar.

◆ set_parent()

void xtd::forms::control::set_parent ( intptr  handle)
protected

Sets the parent handle of the control.

Parameters
handleThe parent handle.

◆ set_style()

void xtd::forms::control::set_style ( control_styles  flag,
bool  value 
)
protected

Sets a specified control_styles flag to either true or false.

Parameters
flagThe control_styles bit to set.
valuetrue to apply the specified style to the control; otherwise, false.
Remarks
Control style bit flags are used to categorize supported behavior. A control can enable a style by calling the set_style method and passing in the appropriate control_styles bit (or bits) and the bool value to set the bit(s) to. To determine the value assigned to a specified control_styles bit, use the get_style method and pass in the control_styles member to evaluate.
Warning
Setting the control style bits can substantially change the behavior of the control. Review the control_styles enumeration documentation to understand the effects of changing the control style bits before calling the set_style method.

◆ wnd_proc()

virtual void xtd::forms::control::wnd_proc ( message m)
protectedvirtual

◆ set_mouse_buttons()

static void xtd::forms::control::set_mouse_buttons ( forms::mouse_buttons  value)
staticprotected

Sets a value indicating which of the mouse buttons is in a pressed state.

Parameters
valueA bitwise combination of the mouse_buttons enumeration values. The default is none.

◆ begin_invoke() [3/4]

virtual xtd::async_result xtd::isynchronize_invoke::begin_invoke ( delegate< void()>  method)
virtual

Asynchronously executes the delegate on the thread that created this object.

Parameters
methodA xtd::delegate to a method without paramter.
Returns
An xtd::iasync_result interface that represents the asynchronous operation started by calling this method.
Remarks
The method delegate is executed on the thread that created the object, instead of the thread on which xtd::isynchronize_invoke::begin_invoke was called.
The delegate is called asynchronously, and this method returns immediately. You can call this method from any thread. If you need the return value from a process started with this method, call xtd::isynchronize_invoke::end_invoke to get the value.

Implements xtd::isynchronize_invoke.

◆ begin_invoke() [4/4]

virtual xtd::async_result xtd::isynchronize_invoke::begin_invoke ( delegate< void(std::vector< std::any >)>  value,
const std::vector< std::any > &  args 
)
virtual

Asynchronously executes the delegate on the thread that created this object.

Parameters
methodA xtd::delegate to a method that takes parameters of the same number and type that are contained in args.
argsAn array of type Object to pass as arguments to the given method. This can be empty if no arguments are needed.
Returns
An xtd::iasync_result interface that represents the asynchronous operation started by calling this method.
Remarks
The method delegate is executed on the thread that created the object, instead of the thread on which xtd::isynchronize_invoke::begin_invoke was called.
The delegate is called asynchronously, and this method returns immediately. You can call this method from any thread. If you need the return value from a process started with this method, call xtd::isynchronize_invoke::end_invoke to get the value.

Implements xtd::isynchronize_invoke.

◆ equals() [1/2]

virtual bool xtd::object::equals ( const object obj) const
virtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.
Examples
The following code example compares the current instance with another object.
#include <xtd/console>
using namespace xtd;
auto main() -> int {
auto object1 = new_ptr<object>();
auto object2 = new_ptr<object>();
auto object3 = object2;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
object3 = object1;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
}
// This code produces the following output :
//
// false
// false
// true
// true
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...

Reimplemented from xtd::object.

◆ equals() [2/2]

template<typename object_a_t , typename object_b_t >
static bool xtd::object::equals ( const object_a_t &  object_a,
const object_b_t &  object_b 
)
inlinestaticnoexcept

Determines whether the specified object instances are considered equal.

Parameters
object_aThe first object to compare.
object_bThe second object to compare.
Returns
true if object_a is the same instance as object_b or if both are null references or if object_a(object_b) returns true. otherwise, false.
Examples
The following code example compares different objects.
#include <xtd/console>
using namespace xtd;
auto main() -> int {
string s1 = "Tom";
string s2 = "Carol";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "Tom";
s2 = "Tom";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "";
s2 = "Tom";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "Carol";
s2 = "";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "";
s2 = "";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
}
// This code produces the following output :
//
// object::equals("Tom", "Carol") => false
// object::equals("Tom", "Tom") => true
// object::equals("", "Tom") => false
// object::equals("Carol", "") => false
// object::equals("", "") => true
virtual bool equals(const object &obj) const noexcept
Determines whether the specified object is equal to the current object.

◆ invoke() [4/6]

virtual std::optional< object_ref > xtd::isynchronize_invoke::invoke ( delegate< void()>  value)
virtual

Synchronously executes the delegate on the thread that created this object and marshals the call to the creating thread.

Parameters
methodA xtd::delegate that contains a method to call, in the context of the thread for the control.
Returns
An xtd::object that represents the return value from the delegate being invoked, or null if the delegate has no return value.
Remarks
Unlike xtd::isynchronize_invoke::begin_invoke, this method operates synchronously, that is, it waits until the process completes before returning. Exceptions raised during the call are propagated back to the caller.
Use this method when calling a method from a different thread to marshal the call to the proper thread.

Implements xtd::isynchronize_invoke.

◆ invoke() [5/6]

virtual std::optional< object_ref > xtd::isynchronize_invoke::invoke ( delegate< void(std::vector< std::any >)>  method,
const std::vector< std::any > &  args 
)
virtual

Synchronously executes the delegate on the thread that created this object and marshals the call to the creating thread.

Parameters
methodA xtd::delegate that contains a method to call, in the context of the thread for the control.
argsAn array of type xtd::object that represents the arguments to pass to the given method. This can be empty if no arguments are needed.
Returns
An xtd::object that represents the return value from the delegate being invoked, or null if the delegate has no return value.
Remarks
Unlike xtd::isynchronize_invoke::begin_invoke, this method operates synchronously, that is, it waits until the process completes before returning. Exceptions raised during the call are propagated back to the caller.
Use this method when calling a method from a different thread to marshal the call to the proper thread.

Implements xtd::isynchronize_invoke.

◆ invoke() [6/6]

virtual std::optional< object_ref > xtd::isynchronize_invoke::invoke ( delegate< void(std::vector< std::any >)>  method,
std::any  arg 
)
virtual

Synchronously executes the delegate on the thread that created this object and marshals the call to the creating thread.

Parameters
methodA xtd::delegate that contains a method to call, in the context of the thread for the control.
argAn xtd::object that represents the argument to pass to the given method.
Returns
An xtd::object that represents the return value from the delegate being invoked, or null if the delegate has no return value.
Remarks
Unlike xtd::isynchronize_invoke::begin_invoke, this method operates synchronously, that is, it waits until the process completes before returning. Exceptions raised during the call are propagated back to the caller.
Use this method when calling a method from a different thread to marshal the call to the proper thread.

Implements xtd::isynchronize_invoke.

Member Data Documentation

◆ auto_size_changed

event<control, event_handler> xtd::forms::control::auto_size_changed

Occurs when the value of the xtd::forms::control::auto_size property changes.

Remarks
This event is raised if the xtd::forms::control::auto_size property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

◆ back_color_changed

event<control, event_handler> xtd::forms::control::back_color_changed

Occurs when the value of the xtd::forms::control::back_color property changes.

Remarks
This event is raised if the xtd::forms::control::back_color property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

◆ background_image_changed

event<control, event_handler> xtd::forms::control::background_image_changed

Occurs when the value of the xtd::forms::control::background_image property changes.

Remarks
This event is raised if the xtd::forms::control::background_image property is changed by either a programmatic modification or user interaction
For more information about handling events, see Handling and Raising Events.

◆ background_image_layout_changed

event<control, event_handler> xtd::forms::control::background_image_layout_changed

Occurs when the value of the xtd::forms::control::background_image_layout property changes.

Remarks
This event is raised if the xtd::forms::control::background_image_layout property is changed by either a programmatic modification or user interaction
For more information about handling events, see Handling and Raising Events.

◆ control_appearance_changed

event<control, event_handler> xtd::forms::control::control_appearance_changed

Occurs when the value of the xtd::forms::control::control_appearance property changes.

Remarks
This event is raised if the control_appearance property is changed by either a programmatic modification or user interaction
For more information about handling events, see Handling and Raising Events.

◆ click

event<control, event_handler> xtd::forms::control::click

Occurs when the xtd::forms::control is clicked.

Remarks
The xtd::forms::control::click event passes an xtd::event_args to its event handler, so it only indicates that a click has occurred. If you need more specific mouse information (button, number of clicks, wheel rotation, or location), use the xtd::forms::control::mouse_click event. However, the xtd::forms::control::mouse_click event will not be raised if the click is caused by action other than that of the mouse, such as pressing the ENTER key.
A double-click is determined by the mouse settings of the user's operating system. The user can set the time between clicks of a mouse button that should be considered a double-click rather than two clicks. The xtd::forms::control::click event is raised every time a control is double-clicked. For example, if you have event handlers for the xtd::forms::control::click and xtd::forms::control::double_click events of a xtd::forms::form, the xtd::forms::control::click and xtd::forms::control::double_click events are raised when the form is double-clicked and both methods are called. If a control is double-clicked and that control does not support the xtd::forms::control::double_click event, the xtd::forms::control::click event might be raised twice.
You must set the standard_click value of xtd::forms::control_styles to true for this event to be raised.
Note
The following events are not raised for the xtd::forms::tab_control class unless there is at least one xtd::forms::tab_page in the xtd::forms::tab_control. xtd::forms::tab_control::tab_pages collection: xtd::forms::control::click, xtd::forms::control::double_click, xtd::forms::control::mouse_down, xtd::forms::control::mouse_up, xtd::forms::control::mouse_hover, xtd::forms::control::mouse_enter, xtd::forms::control::mouse_leave and xtd::forms::control::mouse_move. If there is at least one xtd::forms::tab_page in the collection, and the user interacts with the tab control's header (where the xtd::forms::tab_page names appear), the xtd::forms::tab_control raises the appropriate event. However, if the user interaction is within the client area of the tab page, the xtd::forms::tab_page raises the appropriate event.
Notes to Inheritors
Inheriting from a standard Windows Forms control and changing the standard_click or standard_double_click values of xtd::forms::control_styles to true can cause unexpected behavior or have no effect at all if the control does not support the click or xtd::forms::control::double_click events.
Remarks
The following table lists Windows Forms controls and which event (xtd::forms::control::click or xtd::forms::control::double_click) is raised in response to the mouse action specified.
Control Left Mouse Click Left Mouse Double Click Right Mouse Click Right Mouse Click Middle Mouse Click Middle Mouse Double Click XButton1 Mouse Click XButton1 Mouse Double-Click XButton2 Mouse Click XButton2 Mouse Double-Click
xtd::forms::month_calendar, xtd::forms::date_time_picker, xtd::forms::h_scroll_bar, xtd::forms::v_scroll_bar none none none none none none none none none none
xtd::forms::button, xtd::forms::check_box, xtd::forms::color_picker, xtd::forms::command_link_button, xtd::forms::font_picker, xtd::forms::rich_text_box, xtd::forms::radio_button, xtd::forms::switch_button, xtd::forms::toggle_button click click, click none none none none none none none none
xtd::forms::list_box, xtd::forms::checked_list_box, xtd::forms::choice, xtd::forms::combo_box click click, double_click none none none none none none none none
xtd::forms::text_box, xtd::forms::domain_up_down, xtd::forms::numeric_up_down click click, double_click none none none none none none none none
* xtd::forms::tree_view, * xtd::forms::list_view click click, double_click click click, double_click none none none none none none
xtd::forms::progress_bar, xtd::forms::track_bar click click, click click click, click click click, click click click, click click click, click
xtd::forms::form, xtd::forms::collapsible_panel, xtd::forms::data_grid, xtd::forms::dot_matrix_display, xtd::forms::label, xtd::forms::lcd_label, xtd::forms::link_label, xtd::forms::nine_segment_display, xtd::forms::seven_segment_display, xtd::forms::sixteen_segment_display, xtd::forms::panel, xtd::forms::group_box, xtd::forms::picture_box, xtd::forms::splitter, xtd::forms::status_bar, xtd::forms::tool_bar, xtd::forms::tab_page, ** xtd::forms::tab_control click click, double_click click click, double_click click click, double_click click click, double_click click click, double_click

* The mouse pointer must be over a child object (xtd::forms::tree_node or xtd::forms::list_view_item).
** The xtd::forms::tab_control must have at least one xtd::forms::tab_page in its xtd::forms::tab_pages collection.
Examples
The following code example demonstrates the use of control mouse events.
#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/diagnostics/trace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Mouse events example");
click += [&] {
};
double_click += [&] {
};
mouse_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_double_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_double_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_down += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_down={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_enter += [&] {
};
mouse_horizontal_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_horizontal_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_leave += [&] {
};
mouse_move += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_move={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_up += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_up={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
}
};
auto main() -> int {
application::run(form1 {});
}
static void write_line()
Writes a line terminator to the trace listeners in the listeners collection.
Definition trace.hpp:343
Provides data for the xtd::forms::control::mouse_up, xtd::forms::control::mouse_down,...
Definition mouse_event_args.hpp:34
Represents a form that displays trace form. This class cannot be inherited.
Definition trace_form.hpp:36
Remarks
For more information about handling events, see Handling and Raising Events.
Examples
clock.cpp, demo.cpp, dialog.cpp, emplace.cpp, form2.cpp, form_and_main.cpp, and form_background_image.cpp.

◆ client_size_changed

event<control, event_handler> xtd::forms::control::client_size_changed

Occurs when the value of the xtd::forms::control::client_size property changes.

Remarks
This event is raised if the xtd::forms::control::client_size property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

◆ cursor_changed

event<control, event_handler> xtd::forms::control::cursor_changed

Occurs when the value of the xtd::forms::control::cursor property changes.

Remarks
This event is raised if the xtd::forms::control::cursor property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

◆ control_added

event<control, control_event_handler> xtd::forms::control::control_added

Occurs when a new xtd::forms::control::control is added to the xtd::forms::control::control_collection.

Remarks
For more information about handling events, see Handling and Raising Events.

◆ control_removed

event<control, control_event_handler> xtd::forms::control::control_removed

Occurs when a new xtd::forms::control:: is removed to the xtd::forms::control::control_collection.

Remarks
For more information about handling events, see Handling and Raising Events.

◆ dock_changed

event<control, event_handler> xtd::forms::control::dock_changed

Occurs when the value of the xtd::forms::control::dock property changes.

Remarks
This event is raised if the xtd::forms::control::dock property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

◆ double_click

event<control, event_handler> xtd::forms::control::double_click

Occurs when the xtd::forms::control is double-clicked.

Remarks
A double-click is determined by the mouse settings of the user's operating system. The user can set the time between clicks of a mouse button that should be considered a double-click rather than two clicks. The click event is raised every time a control is double-clicked. For example, if you have event handlers for the xtd::forms::control::click and xtd::forms::control::double_click events of a xtd::forms::form, the xtd::forms::control::click and xtd::forms::control::double_click events are raised when the form is double-clicked and both methods are called. If a control is double-clicked and that control does not support the xtd::forms::control::double_click event, the click event might be raised twice.
You must set the standard_double_click and standard_click value of xtd::forms::control_styles to true for this event to be raised.
Note
The following events are not raised for the xtd::forms::tab_control class unless there is at least one xtd::forms::tab_page in the xtd::forms::tab_control. xtd::forms::tab_control::tab_pages collection: xtd::forms::control::click, xtd::forms::control::double_click, xtd::forms::control::mouse_down, xtd::forms::control::mouse_up, xtd::forms::control::mouse_hover, xtd::forms::control::mouse_enter, xtd::forms::control::mouse_leave and xtd::forms::control::mouse_move. If there is at least one xtd::forms::tab_page in the collection, and the user interacts with the tab control's header (where the xtd::forms::tab_page names appear), the xtd::forms::tab_control raises the appropriate event. However, if the user interaction is within the client area of the tab page, the xtd::forms::tab_page raises the appropriate event.
Notes to Inheritors
Inheriting from a standard Windows Forms control and changing the standard_click or standard_double_click values of xtd::forms::control_styles to true can cause unexpected behavior or have no effect at all if the control does not support the xtd::forms::control::click or xtd::forms::control::double_click events.
Remarks
The following table lists Windows Forms controls and which event (xtd::forms::control::click or xtd::forms::control::double_click) is raised in response to the mouse action specified.
Control Left Mouse Click Left Mouse Double Click Right Mouse Click Right Mouse Click Middle Mouse Click Middle Mouse Double Click XButton1 Mouse Click XButton1 Mouse Double-Click XButton2 Mouse Click XButton2 Mouse Double-Click
xtd::forms::month_calendar, xtd::forms::date_time_picker, xtd::forms::h_scroll_bar, xtd::forms::v_scroll_bar none none none none none none none none none none
xtd::forms::button, xtd::forms::check_box, xtd::forms::color_picker, xtd::forms::command_link_button, xtd::forms::font_picker, xtd::forms::rich_text_box, xtd::forms::radio_button, xtd::forms::switch_button, xtd::forms::toggle_button click click, click none none none none none none none none
xtd::forms::list_box, xtd::forms::checked_list_box, xtd::forms::choice, xtd::forms::combo_box click click, double_click none none none none none none none none
xtd::forms::text_box, xtd::forms::domain_up_down, xtd::forms::numeric_up_down click click, double_click none none none none none none none none
* xtd::forms::tree_view, * xtd::forms::list_view click click, double_click click click, double_click none none none none none none
xtd::forms::progress_bar, xtd::forms::track_bar click click, click click click, click click click, click click click, click click click, click
xtd::forms::form, xtd::forms::collapsible_panel, xtd::forms::data_grid, xtd::forms::dot_matrix_display, xtd::forms::label, xtd::forms::lcd_label, xtd::forms::link_label, xtd::forms::nine_segment_display, xtd::forms::seven_segment_display, xtd::forms::sixteen_segment_display, xtd::forms::panel, xtd::forms::group_box, xtd::forms::picture_box, xtd::forms::splitter, xtd::forms::status_bar, xtd::forms::tool_bar, xtd::forms::tab_page, ** xtd::forms::tab_control click click, double_click click click, double_click click click, double_click click click, double_click click click, double_click

* The mouse pointer must be over a child object (xtd::forms::tree_node or xtd::forms::list_view_item).
** The xtd::forms::tab_control must have at least one xtd::forms::tab_page in its xtd::forms::tab_pages collection.
Examples
The following code example demonstrates the use of control mouse events.
#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/diagnostics/trace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Mouse events example");
click += [&] {
};
double_click += [&] {
};
mouse_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_double_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_double_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_down += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_down={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_enter += [&] {
};
mouse_horizontal_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_horizontal_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_leave += [&] {
};
mouse_move += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_move={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_up += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_up={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
}
};
auto main() -> int {
application::run(form1 {});
}
Remarks
For more information about handling events, see Handling and Raising Events.

◆ got_focus

event<control, event_handler> xtd::forms::control::got_focus

Occurs when the xtd::forms::control receives focus.

Remarks
When you change the focus by using the keyboard (TAB, SHIFT+TAB, and so on), by calling the select or select_next_control methods, or by setting the container_control::active_control property to the current form, focus events occur in the following order:
  1. xtd::forms::control::enter event
  2. xtd::forms::control::got_focus event
  3. xtd::forms::control::leave event
  4. xtd::forms::control::validating event
  5. xtd::forms::control::validated event
  6. xtd::forms::control::lost_focus event
When you change the focus by using the mouse or by calling the focus method, focus events occur in the following order:
  1. xtd::forms::control::enter event
  2. xtd::forms::control::got_focus event
  3. xtd::forms::control::lost_focus event
  4. xtd::forms::control::leave event
  5. xtd::forms::control::validating event
  6. xtd::forms::control::validated event
If the causes_validation property is set to false, the xtd::forms::control::validating and xtd::forms::control::validated events are suppressed.
Note The xtd::forms::control::got_focus and xtd::forms::control::lost_focus events are low-level focus events that are tied to the WM_KILLFOCUS and WM_SETFOCUS Windows messages. Typically, the xtd::forms::control::got_focus and xtd::forms::control::lost_focus events are only used when updating when writing custom controls. Instead the enter and leave events should be used for all controls except the xtd::forms::form class, which uses the activated and deactivate events.
Warning
Do not attempt to set focus from within the xtd::forms::control::enter, xtd::forms::control::got_focus, xtd::forms::control::leave, xtd::forms::control::lost_focus, xtd::forms::control::validating, or xtd::forms::control::validated event handlers. Doing so can cause your application or the operating system to stop responding.
Remarks
For more information about handling events, see Handling and Raising Events.

◆ handle_created

event<control, event_handler> xtd::forms::control::handle_created

Occurs when a handle is created for the xtd::forms::control.

Remarks
A handle is created when the xtd::forms::control is displayed for the first time. For example, if a xtd::forms::control is created that has visible set to false, the xtd::forms::control::handle_created event will not be raised until visible is set to true.
For more information about handling events, see Handling and Raising Events.

◆ handle_destroyed

event<control, event_handler> xtd::forms::control::handle_destroyed

Occurs when the control's handle is in the process of being destroyed.

Remarks
During the xtd::forms::control::handle_destroyed event, the control is still a valid Windows control and the handle can be recreated by calling the recreate_handle method.
For more information about handling events, see Handling and Raising Events.

◆ enabled_changed

event<control, event_handler> xtd::forms::control::enabled_changed

Occurs when the value of the xtd::forms::control::enabled property changes.

Remarks
This event is raised if the xtd::forms::control::enabled property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

◆ fore_color_changed

event<control, event_handler> xtd::forms::control::fore_color_changed

Occurs when the value of the xtd::forms::control::fore_color property changes.

Remarks
This event is raised if the xtd::forms::control::fore_color property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

◆ font_changed

event<control, event_handler> xtd::forms::control::font_changed

Occurs when the value of the xtd::forms::control::font property changes.

Remarks
This event is raised if the xtd::forms::control::font property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

◆ help_requested

event<control, help_event_handler> xtd::forms::control::help_requested

Occurs when the user requests help for a xtd::forms::control.

Remarks
The xtd::forms::control::help_requested event is commonly raised when the user presses the F1 key or an associated context-sensitive help button is clicked.
For more information about handling events, see Handling and Raising Events.

◆ key_down

event<control, key_event_handler> xtd::forms::control::key_down

Occurs when a key is pressed while the xtd::forms::control has focus.

Remarks
Key events occur in the following order:
  1. xtd::forms::control::key_down event
  1. xtd::forms::control::key_press event
  1. xtd::forms::control::key_up event
To handle keyboard events only at the form level and not enable other controls to receive keyboard events, set the xtd::forms::key_press_event_args::handled property in your form's xtd::forms::control::key_press event-handling method to true. Certain keys, such as the TAB, RETURN, ESC, and arrow keys are handled by controls automatically. To have these keys raise the xtd::forms::control::key_down event, you must override the is_input_key method in each control on your form. The code for the override of the is_input_key would need to determine if one of the special keys is pressed and return a value of true. Instead of overriding the is_input_key method, you can handle the preview_key_down event and set the is_input_key property to true.
Examples
The following code example demonstrates the use of control keyboard events.
#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/ctrace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Key events example");
control1.dock(dock_style::fill);
control1.parent(*this);
control1.key_down += [&](object & sender, key_event_args & e) {
ctrace << string::format("key_down={{key_code={}, key_data=[{}], value=0x{:X4}, modifiers=[{}]}}", e.key_code(), e.key_data(), e.key_value(), e.modifiers()) << environment::new_line;
};
control1.key_press += [&](object & sender, key_press_event_args & e) {
ctrace << string::format("key_press={{key_char={}}}", e.key_char() == 0 ? "[none]" : string::format("'{}'", e.key_char())) << environment::new_line;
};
control1.key_up += [&](object & sender, key_event_args & e) {
ctrace << string::format("key_up={{key_code={}, key_data=[{}], value=0x{:X4}, modifiers=[{}]}}", e.key_code(), e.key_data(), e.key_value(), e.modifiers()) << environment::new_line;
if (e.modifiers() == keys::none) ctrace << environment::new_line;
};
}
private:
control control1;
};
auto main() -> int {
application::run(form1 {});
}
Represents text as a sequence of character units.
Definition basic_string.hpp:79
The environment class.
Definition environment.hpp:67
Provides data for the xtd::forms::control::key_down or xtd::forms::control::key_up event.
Definition key_event_args.hpp:25
Provides data for the xtd::forms::control::key_press event.
Definition key_press_event_args.hpp:26
std::ostream ctrace(nullptr)
Provides an std::ostream for xtd::diagnostics::trace.
xtd::string format(const xtd::string &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition format.hpp:20
Remarks
For more information about handling events, see Handling and Raising Events.

◆ key_press

event<control, key_press_event_handler> xtd::forms::control::key_press

Occurs when a character. space or backspace key is pressed while the xtd::forms::control has focus.

Remarks
Key events occur in the following order:
  1. xtd::forms::control::key_down event
  1. xtd::forms::control::key_press event
  1. xtd::forms::control::key_up event
The xtd::forms::control::key_press event is not raised by non-character keys other than space and backspace; however, the non-character keys do raise the xtd::forms::control::key_down and xtd::forms::control::key_up events.
Use the xtd::forms::key_press_event_args::key_char property to sample keystrokes at run time and to consume or modify a subset of common keystrokes.
To handle keyboard events only at the form level and not enable other controls to receive keyboard events, set the xtd::forms::key_press_event_args::handled property in your form's xtd::forms::control::key_press event-handling method to true.
Examples
The following code example demonstrates the use of control keyboard events.
#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/ctrace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Key events example");
control1.dock(dock_style::fill);
control1.parent(*this);
control1.key_down += [&](object & sender, key_event_args & e) {
ctrace << string::format("key_down={{key_code={}, key_data=[{}], value=0x{:X4}, modifiers=[{}]}}", e.key_code(), e.key_data(), e.key_value(), e.modifiers()) << environment::new_line;
};
control1.key_press += [&](object & sender, key_press_event_args & e) {
ctrace << string::format("key_press={{key_char={}}}", e.key_char() == 0 ? "[none]" : string::format("'{}'", e.key_char())) << environment::new_line;
};
control1.key_up += [&](object & sender, key_event_args & e) {
ctrace << string::format("key_up={{key_code={}, key_data=[{}], value=0x{:X4}, modifiers=[{}]}}", e.key_code(), e.key_data(), e.key_value(), e.modifiers()) << environment::new_line;
if (e.modifiers() == keys::none) ctrace << environment::new_line;
};
}
private:
control control1;
};
auto main() -> int {
application::run(form1 {});
}
Remarks
For more information about handling events, see Handling and Raising Events.

◆ key_up

event<control, key_event_handler> xtd::forms::control::key_up

Occurs when a key is released while the xtd::forms::control has focus.

Remarks
Key events occur in the following order:
  1. xtd::forms::control::key_down event
  1. xtd::forms::control::key_press event
  1. xtd::forms::control::key_up event
To handle keyboard events only at the form level and not enable other controls to receive keyboard events, set the xtd::forms::key_press_event_args::handled property in your form's xtd::forms::control::key_press event-handling method to true. Certain keys, such as the TAB, RETURN, ESC, and arrow keys are handled by controls automatically. To have these keys raise the xtd::forms::control::key_down event, you must override the is_input_key method in each control on your form. The code for the override of the is_input_key would need to determine if one of the special keys is pressed and return a value of true. Instead of overriding the is_input_key method, you can handle the preview_key_down event and set the is_input_key property to true.
Examples
The following code example demonstrates the use of control keyboard events.
#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/ctrace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Key events example");
control1.dock(dock_style::fill);
control1.parent(*this);
control1.key_down += [&](object & sender, key_event_args & e) {
ctrace << string::format("key_down={{key_code={}, key_data=[{}], value=0x{:X4}, modifiers=[{}]}}", e.key_code(), e.key_data(), e.key_value(), e.modifiers()) << environment::new_line;
};
control1.key_press += [&](object & sender, key_press_event_args & e) {
ctrace << string::format("key_press={{key_char={}}}", e.key_char() == 0 ? "[none]" : string::format("'{}'", e.key_char())) << environment::new_line;
};
control1.key_up += [&](object & sender, key_event_args & e) {
ctrace << string::format("key_up={{key_code={}, key_data=[{}], value=0x{:X4}, modifiers=[{}]}}", e.key_code(), e.key_data(), e.key_value(), e.modifiers()) << environment::new_line;
if (e.modifiers() == keys::none) ctrace << environment::new_line;
};
}
private:
control control1;
};
auto main() -> int {
application::run(form1 {});
}
Remarks
For more information about handling events, see Handling and Raising Events.

◆ layout

event<control, event_handler> xtd::forms::control::layout

Occurs when a xtd::forms::control should reposition its child controls.

Remarks
The xtd::forms::control::layout event occurs when child controls are added or removed, when the bounds of the control changes, and when other changes occur that can affect the layout of the control. The xtd::forms::control::layout event can be suppressed using the suspend_layout and resume_layout methods. Suspending layout enables you to perform multiple actions on a control without having to perform a layout for each change. For example, if you resize and move a control, each operation would raise a xtd::forms::control::layout event.
For more information about handling events, see Handling and Raising Events.

◆ location_changed

event<control, event_handler> xtd::forms::control::location_changed

Occurs when the value of the xtd::forms::control::location property changes.

Remarks
This event is raised if the xtd::forms::control::location property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

◆ lost_focus

event<control, event_handler> xtd::forms::control::lost_focus

Occurs when the xtd::forms::control loses focus.

Remarks
When you change the focus by using the keyboard (TAB, SHIFT+TAB, and so on), by calling the select or select_next_control methods, or by setting the container_control::active_control property to the current form, focus events occur in the following order:
  1. xtd::forms::control::enter event
  2. xtd::forms::control::got_focus event
  3. xtd::forms::control::leave event
  4. xtd::forms::control::validating event
  5. xtd::forms::control::validated event
  6. xtd::forms::control::lost_focus event
When you change the focus by using the mouse or by calling the focus method, focus events occur in the following order:
  1. xtd::forms::control::enter event
  2. xtd::forms::control::got_focus event
  3. xtd::forms::control::lost_focus event
  4. xtd::forms::control::leave event
  5. xtd::forms::control::validating event
  6. xtd::forms::control::validated event
If the causes_validation property is set to false, the xtd::forms::control::validating and xtd::forms::control::validated events are suppressed.
If the cancel property of the xtd::forms::cancel_event_args is set to true in the validating event delegate, all events that would usually occur after the validating event are suppressed.
Note The xtd::forms::control::got_focus and xtd::forms::control::lost_focus events are low-level focus events that are tied to the WM_KILLFOCUS and WM_SETFOCUS Windows messages. Typically, the xtd::forms::control::got_focus and xtd::forms::control::lost_focus events are only used when updating when writing custom controls. Instead the enter and leave events should be used for all controls except the xtd::forms::form class, which uses the activated and deactivate events.
Warning
Do not attempt to set focus from within the xtd::forms::control::enter, xtd::forms::control::got_focus, xtd::forms::control::leave, xtd::forms::control::lost_focus, xtd::forms::control::validating, or xtd::forms::control::validated event handlers. Doing so can cause your application or the operating system to stop responding.
Remarks
For more information about handling events, see Handling and Raising Events.

◆ mouse_click

event<control, mouse_event_handler> xtd::forms::control::mouse_click

Occurs when the xtd::forms::control is clicked by the mouse.

Remarks
Depressing a mouse button when the cursor is over a control typically raises the following series of events from the control:
  1. xtd::forms::control::mouse_down event
  2. xtd::forms::control::click event
  3. xtd::forms::control::mouse_click event
  4. xtd::forms::control::mouse_up event
For this to occur, the various events cannot be disabled in the control's class.
Two single clicks that occur close enough in time, as determined by the mouse settings of the user's operating system, will generate a xtd::forms::control::mouse_double_click event instead of the second xtd::forms::control::mouse_click event.
important
click events are logically higher-level events of a control. They are often raised by other actions, such as pressing the ENTER key when the control has focus.
Examples
The following code example demonstrates the use of control mouse events.
#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/diagnostics/trace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Mouse events example");
click += [&] {
};
double_click += [&] {
};
mouse_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_double_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_double_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_down += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_down={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_enter += [&] {
};
mouse_horizontal_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_horizontal_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_leave += [&] {
};
mouse_move += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_move={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_up += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_up={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
}
};
auto main() -> int {
application::run(form1 {});
}
Remarks
For more information about handling events, see Handling and Raising Events.
Examples
form_click.cpp.

◆ mouse_double_click

event<control, mouse_event_handler> xtd::forms::control::mouse_double_click

Occurs when the xtd::forms::control is double clicked by the mouse.

Remarks
The xtd::forms::control::mouse_double_click event occurs when the user depresses a mouse button twice in quick succession when the cursor is over the control. The time interval that separates two single clicks from a double-click is determined by the mouse settings of the user's operating system.
The following series of events is raised by the control when such a user action takes place:
  1. xtd::forms::control::mouse_down event
  2. xtd::forms::control::click event
  3. xtd::forms::control::mouse_click event
  4. xtd::forms::control::mouse_up event
  5. xtd::forms::control::mouse_down event
  6. xtd::forms::control::double_click event
  7. xtd::forms::control::mouse_click event
  8. xtd::forms::control::mouse_up event
For this to occur, the various events cannot be disabled in the control's class.
important
xtd::forms::control::double_click events are logically higher-level events of a control. They may be raised by other user actions, such as shortcut key combinations.
Examples
The following code example demonstrates the use of control mouse events.
#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/diagnostics/trace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Mouse events example");
click += [&] {
};
double_click += [&] {
};
mouse_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_double_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_double_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_down += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_down={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_enter += [&] {
};
mouse_horizontal_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_horizontal_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_leave += [&] {
};
mouse_move += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_move={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_up += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_up={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
}
};
auto main() -> int {
application::run(form1 {});
}
Remarks
For more information about handling events, see Handling and Raising Events.

◆ mouse_down

event<control, mouse_event_handler> xtd::forms::control::mouse_down

Occurs when the mouse pointer is over the xtd::forms::control and a mouse button is pressed.

Remarks
Mouse events occur in the following order:
  1. xtd::forms::control::mouse_enter
  2. xtd::forms::control::mouse_move
  3. xtd::forms::control::mouse_hover / xtd::forms::control::mouse_down / xtd::forms::control::mouse_wheel / xtd::forms::control::mouse_horizontal_wheel
  4. xtd::forms::control::mouse_up
  5. xtd::forms::control::mouse_leave
Note
The following events are not raised for the tab_control class unless there is at least one tab_page in the tab_control::tab_pages collection: xtd::forms::control::click, xtd::forms::control::double_click, xtd::forms::control::mouse_down, xtd::forms::control::mouse_up, xtd::forms::control::mouse_hover, xtd::forms::control::mouse_enter, xtd::forms::control::mouse_leave and xtd::forms::control::mouse_move. If there is at least one tab_page in the collection, and the user interacts with the tab control's header (where the tab_page names appear), the tab_control raises the appropriate event. However, if the user interaction is within the client area of the tab page, the tab_page raises the appropriate event.
Examples
The following code example demonstrates the use of control mouse events.
#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/diagnostics/trace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Mouse events example");
click += [&] {
};
double_click += [&] {
};
mouse_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_double_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_double_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_down += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_down={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_enter += [&] {
};
mouse_horizontal_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_horizontal_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_leave += [&] {
};
mouse_move += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_move={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_up += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_up={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
}
};
auto main() -> int {
application::run(form1 {});
}
Remarks
For more information about handling events, see Handling and Raising Events.
Examples
lcd_label2.cpp.

◆ mouse_enter

event<control, event_handler> xtd::forms::control::mouse_enter

Occurs when the mouse pointer enters the xtd::forms::control.

Remarks
Mouse events occur in the following order:
  1. xtd::forms::control::mouse_enter
  2. xtd::forms::control::mouse_move
  3. xtd::forms::control::mouse_hover / xtd::forms::control::mouse_down / xtd::forms::control::mouse_wheel / xtd::forms::control::mouse_horizontal_wheel
  4. xtd::forms::control::mouse_up
  5. xtd::forms::control::mouse_leave
Note
The following events are not raised for the tab_control class unless there is at least one tab_page in the tab_control::tab_pages collection: xtd::forms::control::click, xtd::forms::control::double_click, xtd::forms::control::mouse_down, xtd::forms::control::mouse_up, xtd::forms::control::mouse_hover, xtd::forms::control::mouse_enter, xtd::forms::control::mouse_leave and xtd::forms::control::mouse_move. If there is at least one tab_page in the collection, and the user interacts with the tab control's header (where the tab_page names appear), the tab_control raises the appropriate event. However, if the user interaction is within the client area of the tab page, the tab_page raises the appropriate event.
Examples
The following code example demonstrates the use of control mouse events.
#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/diagnostics/trace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Mouse events example");
click += [&] {
};
double_click += [&] {
};
mouse_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_double_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_double_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_down += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_down={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_enter += [&] {
};
mouse_horizontal_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_horizontal_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_leave += [&] {
};
mouse_move += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_move={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_up += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_up={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
}
};
auto main() -> int {
application::run(form1 {});
}
Remarks
For more information about handling events, see Handling and Raising Events.

◆ mouse_horizontal_wheel

event<control, mouse_event_handler> xtd::forms::control::mouse_horizontal_wheel

Occurs when the mouse horizontal wheel moves while the xtd::forms::control has focus.

Remarks
When handling the xtd::forms::control::mouse_horizontal_wheel event it is important to follow the user interface (UI) standards associated with the mouse wheel. The mouse_event_args::delta property value indicates the amount the mouse wheel has been moved.
Mouse events occur in the following order:
  1. xtd::forms::control::mouse_enter
  2. xtd::forms::control::mouse_move
  3. xtd::forms::control::mouse_hover / xtd::forms::control::mouse_down / xtd::forms::control::mouse_wheel / xtd::forms::control::mouse_horizontal_wheel
  4. xtd::forms::control::mouse_up
  5. xtd::forms::control::mouse_leave
Note
The following events are not raised for the tab_control class unless there is at least one tab_page in the tab_control::tab_pages collection: xtd::forms::control::click, xtd::forms::control::double_click, xtd::forms::control::mouse_down, xtd::forms::control::mouse_up, xtd::forms::control::mouse_hover, xtd::forms::control::mouse_enter, xtd::forms::control::mouse_leave and xtd::forms::control::mouse_move. If there is at least one tab_page in the collection, and the user interacts with the tab control's header (where the tab_page names appear), the tab_control raises the appropriate event. However, if the user interaction is within the client area of the tab page, the tab_page raises the appropriate event.
Examples
The following code example demonstrates the use of control mouse events.
#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/diagnostics/trace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Mouse events example");
click += [&] {
};
double_click += [&] {
};
mouse_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_double_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_double_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_down += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_down={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_enter += [&] {
};
mouse_horizontal_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_horizontal_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_leave += [&] {
};
mouse_move += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_move={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_up += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_up={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
}
};
auto main() -> int {
application::run(form1 {});
}
Remarks
For more information about handling events, see Handling and Raising Events.

◆ mouse_leave

event<control, event_handler> xtd::forms::control::mouse_leave

Occurs when the mouse pointer leaves the xtd::forms::control.

Remarks
Mouse events occur in the following order:
  1. xtd::forms::control::mouse_enter
  2. xtd::forms::control::mouse_move
  3. xtd::forms::control::mouse_hover / xtd::forms::control::mouse_down / xtd::forms::control::mouse_wheel / xtd::forms::control::mouse_horizontal_wheel
  4. xtd::forms::control::mouse_up
  5. xtd::forms::control::mouse_leave
Note
The following events are not raised for the tab_control class unless there is at least one tab_page in the tab_control::tab_pages collection: xtd::forms::control::click, xtd::forms::control::double_click, xtd::forms::control::mouse_down, xtd::forms::control::mouse_up, xtd::forms::control::mouse_hover, xtd::forms::control::mouse_enter, xtd::forms::control::mouse_leave and xtd::forms::control::mouse_move. If there is at least one tab_page in the collection, and the user interacts with the tab control's header (where the tab_page names appear), the tab_control raises the appropriate event. However, if the user interaction is within the client area of the tab page, the tab_page raises the appropriate event.
Examples
The following code example demonstrates the use of control mouse events.
#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/diagnostics/trace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Mouse events example");
click += [&] {
};
double_click += [&] {
};
mouse_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_double_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_double_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_down += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_down={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_enter += [&] {
};
mouse_horizontal_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_horizontal_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_leave += [&] {
};
mouse_move += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_move={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_up += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_up={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
}
};
auto main() -> int {
application::run(form1 {});
}
Remarks
For more information about handling events, see Handling and Raising Events.

◆ mouse_move

event<control, mouse_event_handler> xtd::forms::control::mouse_move

Occurs when the mouse pointer is moved over the xtd::forms::control.

Remarks
Mouse events occur in the following order:
  1. xtd::forms::control::mouse_enter
  2. xtd::forms::control::mouse_move
  3. xtd::forms::control::mouse_hover / xtd::forms::control::mouse_down / xtd::forms::control::mouse_wheel / xtd::forms::control::mouse_horizontal_wheel
  4. xtd::forms::control::mouse_up
  5. xtd::forms::control::mouse_leave
Note
The following events are not raised for the tab_control class unless there is at least one tab_page in the tab_control::tab_pages collection: xtd::forms::control::click, xtd::forms::control::double_click, xtd::forms::control::mouse_down, xtd::forms::control::mouse_up, xtd::forms::control::mouse_hover, xtd::forms::control::mouse_enter, xtd::forms::control::mouse_leave and xtd::forms::control::mouse_move. If there is at least one tab_page in the collection, and the user interacts with the tab control's header (where the tab_page names appear), the tab_control raises the appropriate event. However, if the user interaction is within the client area of the tab page, the tab_page raises the appropriate event.
Examples
The following code example demonstrates the use of control mouse events.
#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/diagnostics/trace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Mouse events example");
click += [&] {
};
double_click += [&] {
};
mouse_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_double_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_double_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_down += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_down={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_enter += [&] {
};
mouse_horizontal_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_horizontal_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_leave += [&] {
};
mouse_move += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_move={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_up += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_up={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
}
};
auto main() -> int {
application::run(form1 {});
}
Remarks
For more information about handling events, see Handling and Raising Events.

◆ mouse_up

event<control, mouse_event_handler> xtd::forms::control::mouse_up

Occurs when the mouse pointer is over the xtd::forms::control and a mouse button is released.

Remarks
Mouse events occur in the following order:
  1. xtd::forms::control::mouse_enter
  2. xtd::forms::control::mouse_move
  3. xtd::forms::control::mouse_hover / xtd::forms::control::mouse_down / xtd::forms::control::mouse_wheel / xtd::forms::control::mouse_horizontal_wheel
  4. xtd::forms::control::mouse_up
  5. xtd::forms::control::mouse_leave
Note
The following events are not raised for the tab_control class unless there is at least one tab_page in the tab_control::tab_pages collection: xtd::forms::control::click, xtd::forms::control::double_click, xtd::forms::control::mouse_down, xtd::forms::control::mouse_up, xtd::forms::control::mouse_hover, xtd::forms::control::mouse_enter, xtd::forms::control::mouse_leave and xtd::forms::control::mouse_move. If there is at least one tab_page in the collection, and the user interacts with the tab control's header (where the tab_page names appear), the tab_control raises the appropriate event. However, if the user interaction is within the client area of the tab page, the tab_page raises the appropriate event.
Examples
The following code example demonstrates the use of control mouse events.
#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/diagnostics/trace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Mouse events example");
click += [&] {
};
double_click += [&] {
};
mouse_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_double_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_double_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_down += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_down={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_enter += [&] {
};
mouse_horizontal_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_horizontal_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_leave += [&] {
};
mouse_move += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_move={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_up += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_up={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
}
};
auto main() -> int {
application::run(form1 {});
}
Remarks
For more information about handling events, see Handling and Raising Events.

◆ mouse_wheel

event<control, mouse_event_handler> xtd::forms::control::mouse_wheel

Occurs when the mouse wheel moves while the xtd::forms::control has focus.

Remarks
When handling the xtd::forms::control::mouse_wheel event it is important to follow the user interface (UI) standards associated with the mouse wheel. The mouse_event_args::delta property value indicates the amount the mouse wheel has been moved. The UI should scroll when the accumulated delta is plus or minus 120. The UI should scroll the number of logical lines returned by the system_information::mouse_wheel_scroll_lines property for every delta value reached. You can also scroll more smoothly in smaller that 120 unit increments, however the ratio should remain constant, that is system_information::mouse_wheel_scroll_lines lines scrolled per 120 delta units of wheel movement.
Mouse events occur in the following order:
  1. xtd::forms::control::mouse_enter
  2. xtd::forms::control::mouse_move
  3. xtd::forms::control::mouse_hover / xtd::forms::control::mouse_down / xtd::forms::control::mouse_wheel / xtd::forms::control::mouse_horizontal_wheel
  4. xtd::forms::control::mouse_up
  5. xtd::forms::control::mouse_leave
Note
The following events are not raised for the tab_control class unless there is at least one tab_page in the tab_control::tab_pages collection: xtd::forms::control::click, xtd::forms::control::double_click, xtd::forms::control::mouse_down, xtd::forms::control::mouse_up, xtd::forms::control::mouse_hover, xtd::forms::control::mouse_enter, xtd::forms::control::mouse_leave and xtd::forms::control::mouse_move. If there is at least one tab_page in the collection, and the user interacts with the tab control's header (where the tab_page names appear), the tab_control raises the appropriate event. However, if the user interaction is within the client area of the tab page, the tab_page raises the appropriate event.
Examples
The following code example demonstrates the use of control mouse events.
#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/diagnostics/trace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Mouse events example");
click += [&] {
};
double_click += [&] {
};
mouse_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_double_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_double_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_down += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_down={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_enter += [&] {
};
mouse_horizontal_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_horizontal_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_leave += [&] {
};
mouse_move += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_move={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_up += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_up={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
}
};
auto main() -> int {
application::run(form1 {});
}
Remarks
For more information about handling events, see Handling and Raising Events.

◆ move

event<control, event_handler> xtd::forms::control::move

Occurs when the control is moved.

Remarks
For more information about handling events, see Handling and Raising Events.

◆ paint

event<control, paint_event_handler> xtd::forms::control::paint

Occurs when the xtd::forms::control is redrawn.

Remarks
The xtd::forms::control::paint event is raised when the control is redrawn. It passes an instance of paint_event_args to the method(s) that handles the xtd::forms::control::paint event. The xtd::forms::control::paint event is raised when the control is redrawn. It passes an instance of paint_event_args to the method(s) that handles the xtd::forms::control::paint event.
When creating a new custom control or an inherited control with a different visual appearance, you must provide code to render the control by overriding the on_paint method.
Examples
The following code example demonstrates the use of control paint events.
#include <xtd/drawing/drawing_2d/linear_gradient_brush>
#include <xtd/drawing/drawing_2d/radial_gradient_brush>
#include <xtd/drawing/brushes>
#include <xtd/forms/application>
#include <xtd/forms/form>
using namespace xtd;
using namespace xtd::collections::generic;
using namespace xtd::drawing;
using namespace xtd::drawing::drawing_2d;
using namespace xtd::forms;
namespace form_paint_example {
class form1 : public form {
public:
form1() {
text("Paint example");
client_size({640, 480});
minimum_client_size({350, 320});
paint += [](object & sender, paint_event_args & e) {
e.graphics().clear(color::cyan);
e.graphics().draw_string("Drawing with graphics", drawing::font("Arial", 34, font_style::regular), brushes::dark_cyan(), {20.0f, 20.0f, e.clip_rectangle().width() - 180.0f, e.clip_rectangle().height() - 40.0f});
e.graphics().fill_ellipse(radial_gradient_brush(point {e.clip_rectangle().width() - 100, 100}, color::white, color::yellow, 75), e.clip_rectangle().width() - 150, 50, 100, 100);
e.graphics().draw_ellipse(pen(color::yellow_green, 2), e.clip_rectangle().width() - 150, 50, 100, 100);
e.graphics().fill_rectangle(brushes::spring_green(), 0, e.clip_rectangle().height() - 100, e.clip_rectangle().width(), 100);
e.graphics().fill_rectangle(brushes::red(), e.clip_rectangle().width() / 2 - 140, e.clip_rectangle().height() - 180, 280, 150);
e.graphics().fill_rectangle(brushes::black(), e.clip_rectangle().width() / 2 - 30, e.clip_rectangle().height() - 140, 60, 110);
e.graphics().fill_rectangle(brushes::white(), e.clip_rectangle().width() / 2 - 120, e.clip_rectangle().height() - 140, 70, 60);
e.graphics().fill_rectangle(brushes::white(), e.clip_rectangle().width() / 2 + 50, e.clip_rectangle().height() - 140, 70, 60);
e.graphics().fill_polygon(linear_gradient_brush(rectangle {e.clip_rectangle().width() / 2 - 160, e.clip_rectangle().height() - 300, 320, 120}, color::brown, color::sandy_brown, linear_gradient_mode::backward_diagonal), list<point> {{e.clip_rectangle().width() / 2, e.clip_rectangle().height() - 300}, {e.clip_rectangle().width() / 2 + 160, e.clip_rectangle().height() - 180}, {e.clip_rectangle().width() / 2 - 160, e.clip_rectangle().height() - 180},});
};
}
};
}
auto main() -> int {
application::run(form_paint_example::form1 {});
}
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:71
Encapsulates a xtd::drawing::brush with a linear gradient. This class cannot be inherited.
Definition linear_gradient_brush.hpp:31
Encapsulates a xtd::drawing::brush with a radial gradient. This class cannot be inherited.
Definition radial_gradient_brush.hpp:30
Defines a particular format for text, including font face, size, and style attributes....
Definition font.hpp:45
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition pen.hpp:35
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.hpp:54
Stores a set of four integers that represent the location and size of a rectangle.
Definition rectangle.hpp:44
Provides data for the xtd::forms::control::paint event.
Definition paint_event_args.hpp:30
@ width
Specifies that the width of the control is defined.
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:15
The xtd::drawing::drawing_2d namespace provides advanced two-dimensional and vector graphics function...
Definition compositing_mode.hpp:12
Remarks
For more information about handling events, see Handling and Raising Events.

◆ parent_changed

event<control, event_handler> xtd::forms::control::parent_changed

Occurs when the value of the xtd::forms::control::parent property changes.

Remarks
This event is raised if the xtd::forms::control::parent property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

◆ region_changed

event<control, event_handler> xtd::forms::control::region_changed

Occurs when the value of the xtd::forms::control::region property changes.

Remarks
This event is raised if the xtd::forms::control::region property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

◆ resize

event<control, event_handler> xtd::forms::control::resize

Occurs when the xtd::forms::control is resized.

Remarks
To determine the size of the resized control, you can cast the sender parameter of the registered control_event_handler method to a control and get its size property (or height and width properties individually).
To handle custom layouts, use the xtd::forms::control::layout event instead of the xtd::forms::control::resize event. The xtd::forms::control::layout event is raised in response to a xtd::forms::control::resize event, but also in response to other changes that affect the layout of the control.
Examples
The following code example demonstrates the use of control xtd::forms::control::resize event.
#include <xtd/drawing/color_converter>
#include <xtd/forms/application>
#include <xtd/forms/dot_matrix_display>
#include <xtd/forms/form>
#include <xtd/forms/timer>
using namespace xtd;
using namespace xtd::collections::generic;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
dot_matrix_display1.height(250);
dot_matrix_display1.location({(client_size().width() - dot_matrix_display1.width()) / 2, (client_size().height() - dot_matrix_display1.height()) / 2});
dot_matrix_display1.parent(*this);
dot_matrix_display1.fore_color(color::red);
dot_matrix_display1.anchor(anchor_styles::top | anchor_styles::bottom);
timer1.interval(300_ms);
timer1.enabled(true);
timer1.tick += [&] {
dot_matrix_display1.dot_matrix_style(dot_matrix_styles[(counter / chase.size()) % dot_matrix_styles.size()]);
dot_matrix_display1.set_dots(chase[counter++ % chase.size()]);
};
back_color(color_converter::average(color::black, dot_matrix_display1.fore_color(), 0.20));
text("Dot matrix display example");
resize += [&] {
dot_matrix_display1.left((client_size().width() - dot_matrix_display1.width()) / 2);
};
}
private:
int counter = 0;
{},
{{3, 3}},
{{3, 3}, {2, 2}, {2, 3}, {2, 4}, {3, 2}, {3, 4}, {4, 2}, {4, 3}, {4, 4}},
{{3, 3}, {2, 2}, {2, 3}, {2, 4}, {3, 2}, {3, 4}, {4, 2}, {4, 3}, {4, 4}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {2, 1}, {2, 5}, {3, 1}, {3, 5}, {4, 1}, {4, 5}, {5, 1}, {5, 2}, {5, 3}, {5, 4}, {5, 5}},
{{3, 3}, {2, 2}, {2, 3}, {2, 4}, {3, 2}, {3, 4}, {4, 2}, {4, 3}, {4, 4}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {2, 1}, {2, 5}, {3, 1}, {3, 5}, {4, 1}, {4, 5}, {5, 1}, {5, 2}, {5, 3}, {5, 4}, {5, 5}, {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {1, 0}, {1, 6}, {2, 0}, {2, 6}, {3, 0}, {3, 6}, {4, 0}, {4, 6}, {5, 0}, {5, 6}, {6, 0}, {6, 1}, {6, 2}, {6, 3}, {6, 4}, {6, 5}, {6, 6}},
};
dot_matrix_display dot_matrix_display1;
list<dot_matrix_style> dot_matrix_styles = {
dot_matrix_style::standard,
dot_matrix_style::square
};
timer timer1;
};
auto main() -> int {
application::run(form1 {});
}
virtual int32 height() const noexcept
Gets the height of the control.
Represents a dot matrix display class.
Definition dot_matrix_display.hpp:32
Implements a timer that raises an event at user-defined intervals. This timer is optimized for use in...
Definition timer.hpp:38
@ chase
Defines a chase unit. Relative to width of the "0" (zero).
Remarks
For more information about handling events, see Handling and Raising Events.

◆ right_to_left_changed

event<control, event_handler> xtd::forms::control::right_to_left_changed

Occurs when the value of the xtd::forms::control::right_to_left property changes.

Remarks
This event is raised if the xtd::forms::control::right_to_left property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

◆ size_changed

event<control, event_handler> xtd::forms::control::size_changed

Occurs when the value of the xtd::forms::control::size property changes.

Remarks
This event is raised if the xtd::forms::control::size property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

◆ style_sheet_changed

event<control, event_handler> xtd::forms::control::style_sheet_changed

Occurs when the value of the xtd::forms::control::style_sheet property changes or when xtd::application::style_sheet property changes.

Remarks
This event is raised if the xtd::forms::control::style_sheet property is changed or when xtd::application::style_sheet property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

◆ system_colors_changed

event<control, event_handler> xtd::forms::control::system_colors_changed

Occurs when the xtd::drwing::system_colors changes.

Remarks
This event is raised if the xtd::drawing::system_colors is changed. For example when automatic dark mode switching on macOS.
For more information about handling events, see Handling and Raising Events.

◆ tab_stop_changed

event<control, event_handler> xtd::forms::control::tab_stop_changed

Occurs when the xtd::forms::control::tab_stop property value changes.

Remarks
This event is raised if the xtd::forms::control::tab_stop property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

◆ text_changed

event<control, event_handler> xtd::forms::control::text_changed

Occurs when the value of the xtd::forms::control::text property changes.

Remarks
This event is raised if the xtd::forms::control::text property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.
Examples
wiggly.cpp.

◆ visible_changed

event<control, event_handler> xtd::forms::control::visible_changed

Occurs when the value of the xtd::forms::control::visible property changes.

Remarks
This event is raised if the xtd::forms::control::visible property is changed by either a programmatic modification or user interaction.
For more information about handling events, see Handling and Raising Events.

The documentation for this class was generated from the following file: