xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
Classes | Public Attributes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
xtd::forms::control Class Reference

#include <control.h>

Definition

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

Namespace
xtd::forms
Library
xtd.forms
Remarks
To create your own control class, inherit from the xtd::forms::user_control, control classes, or from the other Windows Forms provided controls.
The 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 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 back_color, that is communicated to a child control. For example, a button will have the same back_color as its parent form by default. Ambient properties provided by the control class include: cursor, font, back_color, fore_color, and 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 demonstrate the use of control control.
#include <xtd/xtd>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
namespace examples {
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;
};
}
int main() {
application::run(examples::form1());
}
colors for all the standard colors. This class cannot be inherited.
Definition colors.h:20
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.h:67
Represents a window or dialog box that makes up an application's user interface.
Definition form.h:40
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition bitmap.h:11
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition system_report.h:17
Examples
control.cpp.

Inherits xtd::forms::component, and xtd::forms::iwin32_window.

Inherited by 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::picture_box, xtd::forms::progress_bar, xtd::forms::scroll_bar, xtd::forms::scrollable_control, xtd::forms::seven_segment_display, xtd::forms::splitter, xtd::forms::tab_control, xtd::forms::text_box_base, and xtd::forms::track_bar.

Classes

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

Public Attributes

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

Public Member Functions

 control ()
 Initializes a new instance of the control class with default settings.
 
 control (const control &parent, const xtd::ustring &text)
 Initializes a new instance of the control class as a child control, with specific text.
 
 control (const control &parent, const xtd::ustring &text, int32_t left, int32_t top, int32_t width, int32_t height)
 Initializes a new instance of the control class as a child control, with specific text, size, and location.
 
 control (const xtd::ustring &text)
 Initializes a new instance of the control class with specific text.
 
 control (const xtd::ustring &text, int32_t left, int32_t top, int32_t width, int32_t height)
 Initializes a new instance of the control class with specific text, size, and location.
 
virtual anchor_styles anchor () const
 Gets the edges of the container to which a control is bound and determines how a control is resized with its parent.
 
virtual controlanchor (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
 Gets where this control is scrolled to in scroll_control_into_view(control).
 
virtual bool auto_size () const
 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
 Gets the background color for the control.
 
virtual controlback_color (const drawing::color &color)
 Sets the background color for the control.
 
virtual const xtd::drawing::imagebackground_image () const
 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
 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.
 
std::shared_ptr< xtd::iasync_resultbegin_invoke (delegate< void()> value)
 Executes the specified delegate asynchronously on the thread that the control's underlying handle was created on.
 
std::shared_ptr< xtd::iasync_resultbegin_invoke (delegate< void(std::vector< std::any >)> value, const std::vector< std::any > &args)
 Executes the specified delegate asynchronously with the specified arguments, on the thread that the control's underlying handle was created on.
 
virtual int32_t bottom () const
 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
 Gets the size and location of the control including its nonclient elements, in pixels, relative to the parent control.
 
virtual controlbounds (const drawing::rectangle &bounds)
 Sets the size and location of the control including its nonclient elements, in pixels, relative to the parent control.
 
virtual void bring_to_front ()
 Brings the control to the front of the z-order.
 
virtual bool can_focus () const
 Gets a value indicating whether the control can receive focus.
 
bool can_raise_events () const override
 Determines if events can be raised on the control.
 
virtual bool can_select () const
 Gets a value indicating whether the control can be selected.
 
virtual const drawing::rectangleclient_rectangle () const
 Gets the rectangle that represents the client area of the control.
 
virtual const drawing::sizeclient_size () const
 Gets the height and width of the client area of the control.
 
virtual controlclient_size (const drawing::size &client_size)
 Sets the height and width of the client area of the control.
 
virtual xtd::ustring company_name () const
 Gets the name of the company or creator of the application containing the control.
 
virtual control_collectioncontrols ()
 Gets the collection of controls contained within the control.
 
virtual const control_collectioncontrols () const
 Gets the collection of controls contained within the control.
 
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 create_handle ()
 Creates a handle for the control.
 
virtual bool created ()
 Gets a value indicating whether the control has been created.
 
virtual forms::cursor cursor () const
 Gets the cursor that is displayed when the mouse pointer is over the control.
 
virtual controlcursor (const forms::cursor &cursor)
 Sets the cursor that is displayed when the mouse pointer is over the control.
 
virtual drawing::color default_back_color () const
 Gets the default background color of the control.
 
virtual forms::cursor default_cursor () const
 Gets the default cursor for the control.
 
virtual drawing::font default_font () const
 Gets the default font of the control.
 
virtual drawing::color default_fore_color () const
 Gets the default foreground color of the control.
 
virtual drawing::size default_size () const
 Gets the default size of the control.
 
virtual void destroy_control ()
 Forces the destruction of the visible control, including the destruction of the handle and any visible child controls.
 
virtual void destroy_handle ()
 Destroys the handle associated with the control.
 
virtual drawing::rectangle display_rectangle () const
 Gets the rectangle that represents the display area of the control.
 
virtual dock_style dock () const
 Gets or sets which control borders are docked to its parent control and determines how a control is resized with its parent.
 
virtual controldock (dock_style dock)
 Sets or 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
 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
 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.
 
void end_invoke (std::shared_ptr< xtd::iasync_result > async)
 Retrieves the return value of the asynchronous operation represented by the async_result_invoke passed.
 
bool focus ()
 Sets input focus to the control.
 
virtual bool focused () const
 Gets a value indicating whether the control has input focus.
 
virtual drawing::font font () const
 Gets the font of the text displayed by the control.
 
virtual controlfont (const drawing::font &font)
 Sets the font of the text displayed by the control.
 
virtual drawing::color fore_color () const
 Gets the foreground color of the control.
 
virtual controlfore_color (const drawing::color &color)
 Sets the foreground color of the control.
 
size_t get_child_index (intptr_t child) const
 Retrieves the index of a control within the control collection.
 
size_t get_child_index (intptr_t 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.
 
intptr_t handle () const override
 Gets the window handle that the control is bound to.
 
virtual int32_t height () const
 Gets the height of the control.
 
virtual controlheight (int32_t height)
 Sets the height of the control.
 
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.
 
void invoke (delegate< void()> value)
 Executes the specified delegate on the thread that owns the control's underlying window handle.
 
void invoke (delegate< void(std::vector< std::any >)> value, const std::vector< std::any > &args)
 Executes the specified delegate, on the thread that owns the control's underlying window handle, with the specified list of arguments.
 
bool is_handle_created () const
 Gets a value indicating whether the control has a handle associated with it.
 
virtual int32_t left () const
 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_t 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
 Gets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.
 
virtual controllocation (const 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
 Gets the space between controls.
 
virtual controlmargin (const forms::padding &margin)
 Sets the space between controls.
 
virtual const drawing::sizemaximum_size () const
 Gets the size that is the upper limit that xtd::forms::control::get_preferred_size can specify.
 
virtual controlmaximum_size (const drawing::size &size)
 Sets the size that is the upper limit that xtd::forms::control::get_preferred_size can specify.
 
virtual const drawing::sizeminimum_size () const
 Gets the size that is the lower limit that xtd::forms::control::get_preferred_size can specify.
 
virtual controlminimum_size (const drawing::size &size)
 Sets the size that is the lower limit that xtd::forms::control::get_preferred_size can specify.
 
virtual const xtd::ustringname () const
 Gets the name of the control.
 
virtual controlname (const xtd::ustring &name)
 Sets the name of the control.
 
virtual forms::padding padding () const
 Gets padding within the control.
 
virtual controlpadding (const forms::padding &padding)
 Sets padding within the control.
 
virtual std::optional< control_refparent () const
 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.
 
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)
 Computes the location of the specified screen point into client coordinates.
 
xtd::drawing::point point_to_screen (const xtd::drawing::point &p)
 Computes the location of the specified client point into screen coordinates.
 
virtual bool pre_process_message (xtd::forms::message &message)
 Preprocesses keyboard or input messages within the message loop before they are dispatched.
 
virtual xtd::ustring product_name () const
 Gets the product name of the assembly containing the control.
 
bool recreating_handle () const
 Gets a value indicating whether the control is currently re-creating its handle.
 
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.
 
virtual int32_t right () const
 Gets the distance, in pixels, between the right edge of the control and the left edge of its container's client area.
 
intptr_t send_message (intptr_t hwnd, int32_t msg, intptr_t wparam, intptr_t 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_t x, int32_t y, int32_t width, int32_t height)
 Sets the bounds of the control to the specified location and size.
 
void set_bounds (int32_t x, int32_t y, int32_t width, int32_t 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.
 
virtual const drawing::sizesize () const
 Gets the height and width of the control.
 
virtual controlsize (const drawing::size &size)
 Sets the height and width of the control.
 
void suspend_layout ()
 Temporarily suspends the layout logic for the control.
 
virtual std::any tag () const
 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::ustringtext () const
 Gets the text associated with this control.
 
virtual controltext (const xtd::ustring &text)
 Sets the text associated with this control.
 
xtd::ustring to_string () const noexcept override
 Returns a string containing the name of the control, if any.
 
virtual int32_t top () const
 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_t 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
 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 void update () const
 Causes the control to redraw the invalidated regions within its client area.
 
virtual bool visible () const
 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_t width () const
 Gets the width of the control.
 
virtual controlwidth (int32_t width)
 Sets the width of the control.
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const
 Gets the type of the current instance.
 
virtual xtd::ustring to_string () const noexcept
 Returns a std::string that represents the current object.
 
virtual intptr_t handle () const =0
 Gets the handle to the window represented by the implementer.
 

Static Public Member Functions

template<typename control_t >
static std::unique_ptr< control_t > create (const control &parent, const drawing::point &location={-1, -1}, const drawing::size &size={-1, -1}, const drawing::color &back_color=drawing::color::empty, const drawing::color &fore_color=drawing::color::empty)
 A factory to create a specified control with specified parent, location ,size back_color and fore_color.
 
template<typename control_t >
static std::unique_ptr< control_t > create (const control &parent, const xtd::ustring &text, const drawing::point &location={-1, -1}, const drawing::size &size={-1, -1}, const drawing::color &back_color=drawing::color::empty, const drawing::color &fore_color=drawing::color::empty)
 A factory to create a specified control with specified parent, text, location ,size back_color and fore_color.
 
template<typename control_t >
static std::unique_ptr< control_t > create (const drawing::point &location={-1, -1}, const drawing::size &size={-1, -1}, const drawing::color &back_color=drawing::color::empty, const drawing::color &fore_color=drawing::color::empty)
 A factory to create a specified control with specified location ,size back_color and fore_color.
 
template<typename control_t >
static std::unique_ptr< control_t > create (const xtd::ustring &text, const drawing::point &location={-1, -1}, const drawing::size &size={-1, -1}, const drawing::color &back_color=drawing::color::empty, const drawing::color &fore_color=drawing::color::empty)
 A factory to create a specified control with specified text, location ,size back_color and fore_color.
 
static std::optional< control_reffrom_child_handle (intptr_t handle)
 Retrieves the control that contains the specified handle.
 
static std::optional< control_reffrom_handle (intptr_t handle)
 Returns the control that is currently associated with the specified handle.
 
static forms::keys modifier_keys ()
 Gets a value indicating which of the modifier keys (SHIFT, CTRL, and ALT) is in a pressed state.
 
static forms::mouse_buttons mouse_buttons ()
 Gets a value indicating which of the mouse buttons is in a pressed state.
 
- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

Protected Member Functions

virtual forms::create_params create_params () const
 Gets the required creation parameters when the control handle is created.
 
virtual void def_wnd_proc (message &message)
 Sends the specified message to the default window procedure.
 
bool get_style (control_styles flag) const
 Retrieves the value of the specified control style bit for the control.
 
virtual drawing::size measure_control () const
 Measure this control.
 
drawing::size measure_text () const
 Measure this control text.
 
virtual void on_auto_size_changed (const event_args &e)
 Raises the control::auto_size_changed event.
 
virtual void on_back_color_changed (const event_args &e)
 Raises the control::back_color_changed event.
 
virtual void on_background_image_changed (const event_args &e)
 Raises the control::background_image_changed event.
 
virtual void on_background_image_layout_changed (const event_args &e)
 Raises the control::background_image_layout_changed event.
 
virtual void on_click (const event_args &e)
 Raises the control::click event.
 
virtual void on_client_size_changed (const event_args &e)
 Raises the control::client_size_changed event.
 
virtual void on_control_added (const control_event_args &e)
 Raises the control::control_added event.
 
virtual void on_control_removed (const control_event_args &e)
 Raises the control::control_removed event.
 
virtual void on_create_control ()
 Raises the control::create_control event.
 
virtual void on_cursor_changed (const event_args &e)
 Raises the control::cursor_changed event.
 
virtual void on_dock_changed (const event_args &e)
 Raises the control::dock_changed event.
 
virtual void on_double_click (const event_args &e)
 Raises the double_click event.
 
virtual void on_enabled_changed (const event_args &e)
 Raises the control::enabled_changed event.
 
virtual void on_font_changed (const event_args &e)
 Raises the control::font_changed event.
 
virtual void on_fore_color_changed (const event_args &e)
 Raises the control::fore_color_changed event.
 
virtual void on_got_focus (const event_args &e)
 Raises the control::got_focus event.
 
virtual void on_handle_created (const event_args &e)
 Raises the control::handle_created event.
 
virtual void on_handle_destroyed (const event_args &e)
 Raises the control::handle_destroyed event.
 
virtual void on_key_down (key_event_args &e)
 Raises the control::key_down event.
 
virtual void on_key_press (key_press_event_args &e)
 Raises the control::key_press event.
 
virtual void on_key_up (key_event_args &e)
 Raises the control::key_up event.
 
virtual void on_layout (const event_args &e)
 Raises the control::layout event.
 
virtual void on_location_changed (const event_args &e)
 Raises the control::location_changed event.
 
virtual void on_lost_focus (const event_args &e)
 Raises the control::lost_focus event.
 
virtual void on_mouse_click (const mouse_event_args &e)
 Raises the control::mouse_click event.
 
virtual void on_mouse_double_click (const mouse_event_args &e)
 Raises the control::mouse_double_click event.
 
virtual void on_mouse_down (const mouse_event_args &e)
 Raises the control::mouse_down event.
 
virtual void on_mouse_enter (const event_args &e)
 Raises the control::mouse_enter event.
 
virtual void on_mouse_horizontal_wheel (const mouse_event_args &e)
 Raises the control::mouse_horizontal_wheel event.
 
virtual void on_mouse_leave (const event_args &e)
 Raises the control::mouse_leave event.
 
virtual void on_mouse_move (const mouse_event_args &e)
 Raises the control::mouse_move event.
 
virtual void on_mouse_up (const mouse_event_args &e)
 Raises the control::mouse_up event.
 
virtual void on_mouse_wheel (const mouse_event_args &e)
 Raises the control::mouse_wheel event.
 
virtual void on_paint (paint_event_args &e)
 Raises the control::paint event.
 
virtual void on_parent_back_color_changed (const event_args &e)
 Raises the control::parent_back_color_changed event.
 
virtual void on_parent_changed (const event_args &e)
 Raises the control::parent_changed event.
 
virtual void on_parent_cursor_changed (const event_args &e)
 Raises the control::parent_cursor_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_font_changed (const event_args &e)
 Raises the control::parent_font_changed event.
 
virtual void on_parent_fore_color_changed (const event_args &e)
 Raises the control::parent_fore_color_changed event.
 
virtual void on_resize (const event_args &e)
 Raises the control::resize event.
 
virtual void on_size_changed (const event_args &e)
 Raises the control::size_changed event.
 
virtual void on_text_changed (const event_args &e)
 Raises the control::text_changed event.
 
virtual void on_visible_changed (const event_args &e)
 Raises the control::visible_changed event.
 
virtual void recreate_handle ()
 Forces the re-creation of the handle for the control.
 
virtual void set_bounds_core (int32_t x, int32_t y, int32_t width, int32_t height, bounds_specified specified)
 Performs the work of setting the specified bounds of this control.
 
virtual void set_client_size_core (int32_t width, int32_t height)
 Sets the size of the client area 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 Member Functions inherited from xtd::forms::component
 component ()=default
 Initialises a new instance of the component class.
 
virtual bool can_raise_events () const
 Gets a value indicating whether the component can raise an event.
 
bool design_mode () const
 Gets a value that indicates whether the component is currently in design mode.
 

Constructor & Destructor Documentation

◆ control() [1/5]

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

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

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.

◆ control() [2/5]

xtd::forms::control::control ( const xtd::ustring text)
inlineexplicit

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

Parameters
textThe text displayed by the control.
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 text property value to the text parameter value.

◆ control() [3/5]

xtd::forms::control::control ( const control parent,
const xtd::ustring text 
)
inlineexplicit

Initializes a new instance of the 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 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 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::ustring text,
int32_t  left,
int32_t  top,
int32_t  width,
int32_t  height 
)
inlineexplicit

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 text property value to the text parameter value. The initial size and 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::ustring text,
int32_t  left,
int32_t  top,
int32_t  width,
int32_t  height 
)
inlineexplicit

Initializes a new instance of the 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 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 text property value to the text parameter value. The constructor also adds the control to the parent control's control::control_collection. The initial size and 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
inlinevirtual

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 anchor_styles values. The default is top and left.
Remarks
Use the 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 anchor property value is set to top and 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 anchor and 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 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.

◆ anchor() [2/2]

virtual control & xtd::forms::control::anchor ( 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 anchor_styles values. The default is top and left.
Returns
Current control.
Remarks
Use the 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 anchor property value is set to top and 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 anchor and 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 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
inlinevirtual

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

Returns
A 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
inlinevirtual

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.

◆ 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
virtual

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 default_back_color property.
Remarks
The back_color property does not support transparent colors unless the supports_transparent_back_color value of xtd::forms::control_styles is set to true.
The 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 back_color as its parent form by default.
Examples
debug_form.cpp, and lcd_label2.cpp.

◆ back_color() [2/2]

virtual control & xtd::forms::control::back_color ( const 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 default_back_color property.
Returns
Current control.
Remarks
The back_color property does not support transparent colors unless the supports_transparent_back_color value of xtd::forms::control_styles is set to true.
The 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 back_color as its parent form by default.
Notes to Inheritors
When overriding the back_color property in a derived class, use the base class's 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 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
inlinevirtual

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
inlinevirtual

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.

◆ begin_invoke() [1/2]

std::shared_ptr< xtd::iasync_result > xtd::forms::control::begin_invoke ( delegate< void()>  value)
inline

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

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

◆ begin_invoke() [2/2]

std::shared_ptr< xtd::iasync_result > xtd::forms::control::begin_invoke ( delegate< void(std::vector< std::any >)>  value,
const std::vector< std::any > &  args 
)

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

Parameters
valueA 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.

◆ bottom()

virtual int32_t xtd::forms::control::bottom ( ) const
inlinevirtual

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_t 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
inlinevirtual

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.

◆ bounds() [2/2]

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

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.

◆ 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 paint event.

Reimplemented in xtd::forms::form.

◆ can_focus()

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

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_raise_events()

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

Determines if events can be raised on the control.

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

Reimplemented from xtd::forms::component.

◆ can_select()

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

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.

◆ client_rectangle()

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

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
inlinevirtual

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
lcd_label2.cpp.

◆ client_size() [2/2]

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

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::ustring xtd::forms::control::company_name ( ) const
inlinevirtual

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.

◆ controls() [1/2]

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

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.

◆ controls() [2/2]

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

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.

◆ create() [1/4]

template<typename control_t >
static std::unique_ptr< control_t > xtd::forms::control::create ( const control parent,
const drawing::point location = {-1, -1},
const drawing::size size = {-1, -1},
const drawing::color back_color = drawing::color::empty,
const drawing::color fore_color = drawing::color::empty 
)
inlinestatic

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

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.
back_colorA xtd::drawing::color that represent background color of the control.
fore_colorA xtd::drawing::color that represent foreground color of the control.
Returns
New control created.

◆ create() [2/4]

template<typename control_t >
static std::unique_ptr< control_t > xtd::forms::control::create ( const control parent,
const xtd::ustring text,
const drawing::point location = {-1, -1},
const drawing::size size = {-1, -1},
const drawing::color back_color = drawing::color::empty,
const drawing::color fore_color = drawing::color::empty 
)
inlinestatic

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

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.
back_colorA xtd::drawing::color that represent background color of the control.
fore_colorA xtd::drawing::color that represent foreground color of the control.
Returns
New control created.

◆ create() [3/4]

template<typename control_t >
static std::unique_ptr< control_t > xtd::forms::control::create ( const drawing::point location = {-1, -1},
const drawing::size size = {-1, -1},
const drawing::color back_color = drawing::color::empty,
const drawing::color fore_color = drawing::color::empty 
)
inlinestatic

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

Parameters
locationA xtd::drawing::point that represent location of the control.
sizeA xtd::drawing::size that represent size of the control.
back_colorA xtd::drawing::color that represent background color of the control.
fore_colorA xtd::drawing::color that represent foreground color of the control.
Returns
New control created.

◆ create() [4/4]

template<typename control_t >
static std::unique_ptr< control_t > xtd::forms::control::create ( const xtd::ustring text,
const drawing::point location = {-1, -1},
const drawing::size size = {-1, -1},
const drawing::color back_color = drawing::color::empty,
const drawing::color fore_color = drawing::color::empty 
)
inlinestatic

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

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.
back_colorA xtd::drawing::color that represent background color of the control.
fore_colorA xtd::drawing::color that represent foreground color of the control.
Returns
New control created.

◆ 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_handle()

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

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.

◆ create_params()

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

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::list_box, xtd::forms::loading_indicator, xtd::forms::numeric_up_down, xtd::forms::panel, xtd::forms::picture_box, xtd::forms::progress_bar, xtd::forms::radio_button, xtd::forms::scroll_bar, xtd::forms::scrollable_control, xtd::forms::tab_control, xtd::forms::tab_page, xtd::forms::text_box, xtd::forms::toggle_button, xtd::forms::track_bar, xtd::forms::up_down_base, xtd::forms::up_down_button, xtd::forms::user_control, and xtd::forms::v_scroll_bar.

◆ created()

virtual bool xtd::forms::control::created ( )
inlinevirtual

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
virtual

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.

◆ cursor() [2/2]

virtual control & xtd::forms::control::cursor ( const 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.

◆ 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.

◆ default_back_color()

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

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::numeric_up_down, and xtd::forms::text_box.

◆ default_cursor()

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

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
virtual

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.

◆ default_fore_color()

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

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::numeric_up_down, and xtd::forms::text_box.

◆ default_size()

virtual drawing::size xtd::forms::control::default_size ( ) const
inlinevirtual

◆ 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.

◆ destroy_handle()

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

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.

◆ display_rectangle()

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

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
inlinevirtual

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

Returns
One of the dock_style values. The default is none.
Remarks
Use the dock property to define how a control is automatically resized as its parent control is resized. For example, setting dock to 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 margin property on a docked control has no effect on the distance of the control from the edges of its container.
Note
The anchor and 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 dock property in a derived class, use the base class's 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 dock property; you can override only one if needed.
Examples
hello_world_label.cpp, and lcd_label2.cpp.

◆ dock() [2/2]

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

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

Parameters
dockOne of the dock_style values. The default is none.
Returns
Current control.
Remarks
Use the dock property to define how a control is automatically resized as its parent control is resized. For example, setting dock to 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 margin property on a docked control has no effect on the distance of the control from the edges of its container.
Note
The anchor and 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 dock property in a derived class, use the base class's 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 dock property; you can override only one if needed.

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

◆ double_buffered() [1/2]

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

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.

◆ double_buffered() [2/2]

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

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
inlinevirtual

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.

◆ 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.

◆ end_invoke()

void xtd::forms::control::end_invoke ( std::shared_ptr< xtd::iasync_result async)

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).

◆ 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.

◆ focused()

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

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
virtual

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.

Reimplemented in xtd::forms::font_picker.

Examples
hello_world_label.cpp.

◆ font() [2/2]

virtual control & xtd::forms::control::font ( const 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.

Reimplemented in xtd::forms::font_picker.

◆ fore_color() [1/2]

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

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.
Examples
debug_form.cpp, hello_world_label.cpp, and lcd_label2.cpp.

◆ fore_color() [2/2]

virtual control & xtd::forms::control::fore_color ( const 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.

◆ from_child_handle()

static std::optional< control_ref > xtd::forms::control::from_child_handle ( intptr_t  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_t  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.

◆ get_child_index() [1/2]

size_t xtd::forms::control::get_child_index ( intptr_t  child) const
inline

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_t  child,
bool &  throw_exception 
) const
inline

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. @param throw_exception true to throw an exception if the control specified in the child parameter is not a control in the control::control_collection; otherwise, false.

◆ get_style()

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

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.

◆ handle()

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

Gets the window handle that the control is bound to.

Returns
An intptr_t that contains the window handle (HWND) of the control.

Implements xtd::forms::iwin32_window.

◆ height() [1/2]

virtual int32_t xtd::forms::control::height ( ) const
inlinevirtual

Gets the height of the control.

Returns
The height of the control in pixels.
Examples
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_t  height)
inlinevirtual

Sets the height of the control.

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

◆ hide()

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

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/4]

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

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/4]

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

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/4]

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

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/4]

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.

◆ invoke() [1/2]

void xtd::forms::control::invoke ( delegate< void()>  value)
inline

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

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

◆ invoke() [2/2]

void xtd::forms::control::invoke ( delegate< void(std::vector< std::any >)>  value,
const std::vector< std::any > &  args 
)
inline

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

Parameters
valueA 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.

◆ is_handle_created()

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

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_t xtd::forms::control::left ( ) const
inlinevirtual

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_t 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_t  left)
inlinevirtual

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_t 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
inlinevirtual

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, and screen.cpp.

◆ location() [2/2]

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

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
inlinevirtual

Gets the space between controls.

Returns
A padding representing the space between controls.

◆ margin() [2/2]

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

Sets the space between controls.

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

◆ maximum_size() [1/2]

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

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/xtd>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
client_size({220, 115});
maximum_size(size() + drawing::size {300, 300});
minimum_size(size());
controls().push_back_range({up_button, left_button, right_button, down_button, grow_button, shrink_button});
text("Form resize example");
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);
};
grow_button.auto_repeat(true);
grow_button.bounds({150, 45, 25, 25});
grow_button.image(button_images::from_name("zoom-in"));
grow_button.click += [&] {
size(size() + drawing::size {10, 10});
};
shrink_button.auto_repeat(true);
shrink_button.bounds({185, 45, 25, 25});
shrink_button.image(button_images::from_name("zoom-out"));
shrink_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;
};
int main() {
application::run(form1());
}
Stores an ordered pair of integers, which specify a height and width.
Definition size.h:25
Represents a Windows button control.
Definition button.h:54
size_t size
Represents a size of any object in bytes.
Definition types.h:171
@ left
Specifies the xtd::drawing::pen is positioned to the left of the theoretical line.
@ top
The operating system is closing all applications before shutting down.

◆ maximum_size() [2/2]

virtual control & xtd::forms::control::maximum_size ( const 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/xtd>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
client_size({220, 115});
maximum_size(size() + drawing::size {300, 300});
minimum_size(size());
controls().push_back_range({up_button, left_button, right_button, down_button, grow_button, shrink_button});
text("Form resize example");
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);
};
grow_button.auto_repeat(true);
grow_button.bounds({150, 45, 25, 25});
grow_button.image(button_images::from_name("zoom-in"));
grow_button.click += [&] {
size(size() + drawing::size {10, 10});
};
shrink_button.auto_repeat(true);
shrink_button.bounds({185, 45, 25, 25});
shrink_button.image(button_images::from_name("zoom-out"));
shrink_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;
};
int main() {
application::run(form1());
}

◆ measure_control()

virtual drawing::size xtd::forms::control::measure_control ( ) const
protectedvirtual

◆ measure_text()

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

Measure this control text.

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

◆ minimum_size() [1/2]

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

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/xtd>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
client_size({220, 115});
maximum_size(size() + drawing::size {300, 300});
minimum_size(size());
controls().push_back_range({up_button, left_button, right_button, down_button, grow_button, shrink_button});
text("Form resize example");
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);
};
grow_button.auto_repeat(true);
grow_button.bounds({150, 45, 25, 25});
grow_button.image(button_images::from_name("zoom-in"));
grow_button.click += [&] {
size(size() + drawing::size {10, 10});
};
shrink_button.auto_repeat(true);
shrink_button.bounds({185, 45, 25, 25});
shrink_button.image(button_images::from_name("zoom-out"));
shrink_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;
};
int main() {
application::run(form1());
}

◆ minimum_size() [2/2]

virtual control & xtd::forms::control::minimum_size ( const 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/xtd>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
client_size({220, 115});
maximum_size(size() + drawing::size {300, 300});
minimum_size(size());
controls().push_back_range({up_button, left_button, right_button, down_button, grow_button, shrink_button});
text("Form resize example");
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);
};
grow_button.auto_repeat(true);
grow_button.bounds({150, 45, 25, 25});
grow_button.image(button_images::from_name("zoom-in"));
grow_button.click += [&] {
size(size() + drawing::size {10, 10});
};
shrink_button.auto_repeat(true);
shrink_button.bounds({185, 45, 25, 25});
shrink_button.image(button_images::from_name("zoom-out"));
shrink_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;
};
int main() {
application::run(form1());
}

◆ modifier_keys()

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

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 ( )
inlinestatic

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.

◆ name() [1/2]

virtual const xtd::ustring & xtd::forms::control::name ( ) const
inlinevirtual

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::ustring name)
inlinevirtual

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
inlinevirtual

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 forms::padding padding)
inlinevirtual

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
inlinevirtual

Gets the parent container of the control.

Returns
A control that represents the parent or container control of the control.
Examples
color_picker.cpp, and lcd_label2.cpp.

◆ 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::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.

◆ 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 layout event is suppressed.

◆ point_to_client()

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

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)

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.

◆ pre_process_message()

virtual bool xtd::forms::control::pre_process_message ( 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.

◆ product_name()

virtual xtd::ustring xtd::forms::control::product_name ( ) const
inlinevirtual

Gets the product name of the assembly containing the control.

Returns
The product name of the assembly containing the control.

◆ 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.

Reimplemented in xtd::forms::tab_control.

◆ recreating_handle()

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

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.

◆ 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 ( )
inline

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)
inline

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 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.

◆ right()

virtual int32_t xtd::forms::control::right ( ) const
inlinevirtual

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_t representing the distance, in pixels, between the right edge of the control and the left edge of its container's client area.

◆ send_message()

intptr_t xtd::forms::control::send_message ( intptr_t  hwnd,
int32_t  msg,
intptr_t  wparam,
intptr_t  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_t  x,
int32_t  y,
int32_t  width,
int32_t  height 
)
inline

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_t  x,
int32_t  y,
int32_t  width,
int32_t  height,
bounds_specified  specified 
)
inline

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.

◆ set_bounds_core()

virtual void xtd::forms::control::set_bounds_core ( int32_t  x,
int32_t  y,
int32_t  width,
int32_t  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_t, int32_t, int32_t, int32_t, bounds_specified) in a derived class, be sure to call the base class's set_bounds_core(int32_t, int32_t, int32_t, int32_t, bounds_specified) method to force the bounds of the control to change. Derived classes can add size restrictions to the set_bounds_core(int32_t, int32_t, int32_t, int32_t, bounds_specified) method.

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

◆ set_client_size_core()

virtual void xtd::forms::control::set_client_size_core ( int32_t  width,
int32_t  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_t, int32_t) in a derived class, be sure to call the base class's set_client_size_core(int32_t, int32_t) method so that the client_size property is adjusted.

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

◆ set_style()

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

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.

◆ show()

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

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.
Examples
application_context.cpp.

◆ size() [1/2]

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

Gets the height and width of the control.

Returns
The size that represents the height and width of the control in pixels.
Examples
screen.cpp.

◆ size() [2/2]

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

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.

◆ suspend_layout()

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

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 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.

◆ tag() [1/2]

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

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)
inlinevirtual

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]

virtual const xtd::ustring & xtd::forms::control::text ( ) const
inlinevirtual

Gets the text associated with this control.

Returns
The text associated with this control.

Reimplemented in xtd::forms::lcd_label, and xtd::forms::text_box.

Examples
application_context.cpp, hello_world_label.cpp, lcd_label2.cpp, screen.cpp, and timer.cpp.

◆ text() [2/2]

virtual control & xtd::forms::control::text ( const xtd::ustring 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, and xtd::forms::lcd_label.

◆ to_string()

xtd::ustring 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::numeric_up_down, xtd::forms::progress_bar, xtd::forms::radio_button, xtd::forms::track_bar, and xtd::forms::up_down_button.

◆ top() [1/2]

virtual int32_t xtd::forms::control::top ( ) const
inlinevirtual

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_t  top)
inlinevirtual

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
virtual

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.

◆ 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.

◆ visible() [1/2]

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

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_t xtd::forms::control::width ( ) const
inlinevirtual

Gets the width of the control.

Returns
The width of the control in pixels.

◆ width() [2/2]

virtual control & xtd::forms::control::width ( int32_t  width)
inlinevirtual

Sets the width of the control.

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

◆ wnd_proc()

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

Processes Windows messages.

Parameters
mThe Windows Message to process.
Remarks
All messages are sent to the wnd_proc method after getting filtered through the pre_process_message method.
Notes to Inheritors
Inheriting controls should call the base class's wnd_proc(message&) method to process any messages that they do not handle.

Reimplemented in xtd::forms::checked_list_box, xtd::forms::choice, xtd::forms::collapsible_panel, xtd::forms::color_picker, xtd::forms::combo_box, xtd::forms::date_time_picker, xtd::forms::font_picker, xtd::forms::form, xtd::forms::list_box, xtd::forms::numeric_up_down, xtd::forms::radio_button, xtd::forms::scroll_bar, xtd::forms::tab_control, xtd::forms::text_box, xtd::forms::track_bar, and xtd::forms::up_down_button.


The documentation for this class was generated from the following file: