xtd.forms - Reference Guide  0.1.0
Modern c++17 library containing classes for creating Windows-based applications that take full advantage of the rich user interface features available in the Microsoft Windows, Apple macOS and Linux like Ubuntu operating system.
xtd::forms::control Class Reference

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

#include <control.hpp>

Inheritance diagram for xtd::forms::control:
xtd::forms::component xtd::forms::iwin32_window xtd::forms::button_base xtd::forms::group_box xtd::forms::label xtd::forms::lcd_label xtd::forms::list_control xtd::forms::picture_box xtd::forms::progress_bar xtd::forms::scroll_bar xtd::forms::scrollable_control xtd::forms::tab_control xtd::forms::text_box_base xtd::forms::track_bar

Public Types

using control_collection = layout::arranged_element_collection< control_ref >
 Represents a collection of controls. More...
 

Public Member Functions

 control ()
 Initializes a new instance of the Control class with default settings. More...
 
 control (const ustring &text)
 Initializes a new instance of the control class with specific text. More...
 
 control (const control &parent, const ustring &text)
 nitializes a new instance of the control class as a child control, with specific text. More...
 
 control (const 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. More...
 
 control (const control &parent, const 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. More...
 
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. More...
 
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. More...
 
virtual drawing::point auto_scroll_point () const
 Gets where this control is scrolled to in scroll_control_into_view(control). More...
 
virtual bool auto_size () const
 Gets a value that indicates whether the control resizes based on its contents. More...
 
virtual controlauto_size (bool auto_size)
 Sets a value that indicates whether the control resizes based on its contents. More...
 
virtual drawing::color back_color () const
 Gets the background color for the control. More...
 
virtual controlback_color (const drawing::color &color)
 Sets the background color for the control. More...
 
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. More...
 
virtual drawing::rectangle bounds () const
 Gets the size and location of the control including its nonclient elements, in pixels, relative to the parent control. More...
 
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. More...
 
virtual bool can_focus () const
 Gets a value indicating whether the control can receive focus. More...
 
bool can_raise_events () const override
 Determines if events can be raised on the control. More...
 
virtual bool can_select () const
 Gets a value indicating whether the control can be selected. More...
 
virtual const drawing::rectangleclient_rectangle () const
 Gets the rectangle that represents the client area of the control. More...
 
virtual const drawing::sizeclient_size () const
 Gets the height and width of the client area of the control. More...
 
virtual controlclient_size (const drawing::size &client_size)
 Sets the height and width of the client area of the control. More...
 
virtual ustring compagny_name () const
 Gets the name of the company or creator of the application containing the control. More...
 
virtual control_collectioncontrols ()
 Gets the collection of controls contained within the control. More...
 
virtual const control_collectioncontrols () const
 Gets the collection of controls contained within the control. More...
 
void create_control ()
 
drawing::graphics create_graphics () const
 
virtual void create_handle ()
 
virtual bool created ()
 Gets a value indicating whether the control has been created. More...
 
virtual forms::cursor cursor () const
 
virtual controlcursor (const forms::cursor &cursor)
 
virtual drawing::color default_back_color () const
 Gets the default background color of the control. More...
 
virtual forms::cursor default_cursor () const
 
virtual drawing::font default_font () const
 
virtual drawing::color default_fore_color () const
 
virtual drawing::size default_size () const
 
void destroy_control ()
 
virtual void destroy_handle ()
 
virtual drawing::rectangle display_rectangle () const
 
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. More...
 
virtual controldock (dock_style dock)
 
virtual bool enabled () const
 
virtual controlenabled (bool enabled)
 
bool focus ()
 
virtual bool focused () const
 
virtual drawing::font font () const
 
virtual controlfont (const drawing::font &font)
 
virtual drawing::color fore_color () const
 
virtual controlfore_color (const drawing::color &color)
 
intptr_t handle () const override
 Gets the handle to the window represented by the implementer. More...
 
virtual int32_t height () const
 
virtual controlheight (int32_t height)
 
virtual void hide ()
 
virtual void invalidate () const
 
virtual void invalidate (bool invalidate_children) const
 
virtual void invalidate (const drawing::rectangle &rect) const
 
virtual void invalidate (const drawing::rectangle &rect, bool invalidate_children) const
 
void invoke (delegate< void(std::vector< std::any >)> value, const std::vector< std::any > &args)
 
void invoke (delegate< void()> value)
 
bool is_handle_created () const
 
virtual int32_t left () const
 
virtual controlleft (int32_t left)
 
virtual drawing::point location () const
 
virtual controllocation (const drawing::point &location)
 
virtual const ustringname () const
 
virtual controlname (const ustring &name)
 
virtual std::optional< control_refparent () const
 
virtual controlparent (const control &parent)
 
virtual controlparent (std::nullptr_t)
 
void perform_layout ()
 Forces the control to apply layout logic to all its child controls. More...
 
xtd::drawing::point point_to_client (const xtd::drawing::point &p)
 
xtd::drawing::point point_to_screen (const xtd::drawing::point &p)
 
virtual ustring product_name () const
 
bool recreating_handle () const
 
virtual void refresh () const
 
void resume_layout ()
 Resumes usual layout logic. More...
 
void resume_layout (bool perform_layout)
 Resumes usual layout logic, optionally forcing an immediate layout of pending layout requests. More...
 
virtual int32_t right () const
 
intptr_t send_message (intptr_t hwnd, int32_t msg, intptr_t wparam, intptr_t lparam) const
 
void set_auto_size_mode (auto_size_mode auto_size_mode)
 
void set_bounds (int32_t x, int32_t y, int32_t width, int32_t height)
 
void set_bounds (int32_t x, int32_t y, int32_t width, int32_t height, bounds_specified specified)
 
virtual void show ()
 
virtual drawing::size size () const
 
virtual controlsize (const drawing::size &size)
 
void suspend_layout ()
 Temporarily suspends the layout logic for the control. More...
 
virtual std::any tag () const
 Gets the object that contains data about the control. More...
 
virtual controltag (std::any tag)
 Sets the object that contains data about the control. More...
 
virtual const ustringtext () const
 
virtual controltext (const ustring &text)
 
virtual ustring to_string () const
 
virtual int32_t top () const
 
virtual controltop (int32_t top)
 
virtual std::optional< control_reftop_level_control () const
 
virtual void update () const
 
virtual bool visible () const
 
virtual controlvisible (bool visible)
 
virtual int32_t width () const
 
virtual controlwidth (int32_t width)
 

Static Public Member Functions

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)
 
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)
 
template<typename control_t >
static std::unique_ptr< control_t > create (const 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)
 
template<typename control_t >
static std::unique_ptr< control_t > create (const control &parent, const 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)
 
static std::optional< control_reffrom_child_handle (intptr_t handle)
 
static std::optional< control_reffrom_handle (intptr_t handle)
 
static forms::mouse_buttons mouse_buttons ()
 

Public Attributes

event< control, event_handler< control & > > auto_size_changed
 
event< control, event_handler< control & > > back_color_changed
 
event< control, event_handler< control & > > click
 
event< control, event_handler< control & > > client_size_changed
 
event< control, control_event_handler< control & > > control_added
 
event< control, control_event_handler< control & > > control_removed
 
event< control, event_handler< control & > > cursor_changed
 
event< control, event_handler< control & > > dock_changed
 
event< control, event_handler< control & > > double_click
 
event< control, event_handler< control & > > enabled_changed
 
event< control, event_handler< control & > > font_changed
 
event< control, event_handler< control & > > fore_color_changed
 
event< control, event_handler< control & > > got_focus
 
event< control, event_handler< control & > > handle_created
 
event< control, event_handler< control & > > handle_destroyed
 
event< control, key_event_handler< control & > > key_down
 
event< control, key_press_event_handler< control & > > key_press
 
event< control, key_event_handler< control & > > key_up
 
event< control, event_handler< control & > > layout
 Occurs when a control should reposition its child controls. More...
 
event< control, event_handler< control & > > location_changed
 
event< control, event_handler< control & > > lost_focus
 
event< control, mouse_event_handler< control & > > mouse_click
 
event< control, mouse_event_handler< control & > > mouse_double_click
 
event< control, mouse_event_handler< control & > > mouse_down
 
event< control, event_handler< control & > > mouse_enter
 
event< control, mouse_event_handler< control & > > mouse_horizontal_wheel
 
event< control, event_handler< control & > > mouse_leave
 
event< control, mouse_event_handler< control & > > mouse_move
 
event< control, mouse_event_handler< control & > > mouse_up
 
event< control, mouse_event_handler< control & > > mouse_wheel
 
event< control, paint_event_handler< control & > > paint
 
event< control, event_handler< control & > > parent_changed
 
event< control, event_handler< control & > > resize
 
event< control, event_handler< control & > > size_changed
 
event< control, event_handler< control & > > text_changed
 
event< control, event_handler< control & > > visible_changed
 

Protected Member Functions

virtual forms::create_params create_params () const
 Gets the required creation parameters when the control handle is created. More...
 
virtual void def_wnd_proc (message &message)
 
bool get_style (control_styles flag) const
 Retrieves the value of the specified control style bit for the control. More...
 
virtual drawing::size measure_control () const
 Measure this control. More...
 
drawing::size measure_text () const
 
virtual void on_auto_size_changed (const event_args &e)
 
virtual void on_back_color_changed (const event_args &e)
 
virtual void on_click (const event_args &e)
 
virtual void on_client_size_changed (const event_args &e)
 
virtual void on_control_added (const control_event_args &e)
 
virtual void on_control_removed (const control_event_args &e)
 
virtual void on_create_control ()
 
virtual void on_cursor_changed (const event_args &e)
 
virtual void on_dock_changed (const event_args &e)
 
virtual void on_double_click (const event_args &e)
 
virtual void on_enabled_changed (const event_args &e)
 
virtual void on_font_changed (const event_args &e)
 
virtual void on_fore_color_changed (const event_args &e)
 
virtual void on_got_focus (const event_args &e)
 
virtual void on_handle_created (const event_args &e)
 
virtual void on_handle_destroyed (const event_args &e)
 
virtual void on_key_down (key_event_args &e)
 
virtual void on_key_press (key_press_event_args &e)
 
virtual void on_key_up (key_event_args &e)
 
virtual void on_layout (const event_args &e)
 
virtual void on_location_changed (const event_args &e)
 
virtual void on_lost_focus (const event_args &e)
 
virtual void on_mouse_click (const mouse_event_args &e)
 
virtual void on_mouse_double_click (const mouse_event_args &e)
 
virtual void on_mouse_down (const mouse_event_args &e)
 
virtual void on_mouse_enter (const event_args &e)
 
virtual void on_mouse_horizontal_wheel (const mouse_event_args &e)
 
virtual void on_mouse_leave (const event_args &e)
 
virtual void on_mouse_move (const mouse_event_args &e)
 
virtual void on_mouse_up (const mouse_event_args &e)
 
virtual void on_mouse_wheel (const mouse_event_args &e)
 
virtual void on_paint (paint_event_args &e)
 
virtual void on_parent_back_color_changed (const event_args &e)
 
virtual void on_parent_changed (const event_args &e)
 
virtual void on_parent_cursor_changed (const event_args &e)
 
virtual void on_parent_font_changed (const event_args &e)
 
virtual void on_parent_fore_color_changed (const event_args &e)
 
virtual void on_resize (const event_args &e)
 
virtual void on_size_changed (const event_args &e)
 
virtual void on_text_changed (const event_args &e)
 
virtual void on_visible_changed (const event_args &e)
 
virtual void recreate_handle ()
 
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. More...
 
virtual void set_client_size_core (int32_t width, int32_t height)
 Sets the size of the client area of the control. More...
 
void set_style (control_styles flag, bool value)
 Sets a specified control_styles flag to either true or false. More...
 
virtual void wnd_proc (message &m)
 Processes Windows messages. More...
 
- Protected Member Functions inherited from xtd::forms::component
bool design_mode () const
 Gets a value that indicates whether the component is currently in design mode. More...
 

Friends

class application
 
controloperator<< (control &parent, control &child)
 
class screen
 

Detailed Description

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

Remarks
To create your own control class, inherit from the user_control, control classes, or from the other Windows Forms provided controls. For more information about authoring custom controls, see Developing Custom Windows Forms Controls with xtd.
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.
Example
The following code example demonstrate the use of control control.
#include <xtd/xtd.forms>
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(color::spring_green);
control1.location({50, 50});
control1.size({100, 50});
control1.click += [this](control& sender, const event_args& e) {
control1.back_color(control1.back_color() == color::spring_green ? color::orange_red : color::spring_green);
};
}
private:
control control1;
};
}
int main() {
application::run(examples::form1());
}

Member Typedef Documentation

§ control_collection

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 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 ustring text 
)
inlineexplicit

nitializes 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 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 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 Ineritors
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.
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 Ineritors
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
This 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
inlinevirtual

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.

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

§ 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
Arectangle in pixels relative to the parent control that represents the size and location of the control including its nonclient elements.
Returns
This control.
Remarks
The bounds of the control include the nonclient elements such as scroll bars, borders, title bars, and menus. The Set_bounds_core method is called to set the bounds property. The bounds property is not always changed through its set method so you should override the set_bounds_core method to ensure that your code is executed when the bounds property is set.

§ can_focus()

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

Gets a value indicating whether the control can receive focus.

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

§ 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
Asize 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. 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_sizeCore method to ensure that your code is executed when the client_size property is set.

§ compagny_name()

virtual ustring xtd::forms::control::compagny_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_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::progress_bar, xtd::forms::track_bar, xtd::forms::form, xtd::forms::checked_list_box, xtd::forms::check_box, xtd::forms::radio_button, xtd::forms::button_base, xtd::forms::domain_up_down, xtd::forms::button, xtd::forms::combo_box, xtd::forms::list_box, xtd::forms::up_down_button, xtd::forms::numeric_up_down, xtd::forms::scrollable_control, xtd::forms::picture_box, xtd::forms::label, xtd::forms::text_box, xtd::forms::tab_control, xtd::forms::panel, xtd::forms::user_control, xtd::forms::group_box, xtd::forms::tab_page, and xtd::forms::up_down_base.

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

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

§ dock()

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.

§ 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 handle to the window represented by the implementer.

Returns
A handle to the window represented by the implementer.
Remarks
Depending on the implementer, the value of the Handle property could change during the life of the window.

Implements xtd::forms::iwin32_window.

§ measure_control()

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

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

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

§ 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 pecified 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::track_bar, and xtd::forms::combo_box.

§ 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::track_bar, and xtd::forms::combo_box.

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

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

§ 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::track_bar, xtd::forms::form, xtd::forms::checked_list_box, xtd::forms::button, xtd::forms::up_down_button, xtd::forms::combo_box, and xtd::forms::list_box.

Member Data Documentation

§ layout

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

Occurs when a control should reposition its child controls.

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

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