TWinControl Branch

From RAD Studio
Jump to: navigation, search

Go Up to Objects, Components, and Controls


Most controls fall into the TWinControl branch. Unlike graphic controls, controls in this branch have their own associated window. Because of this, they are sometimes called windowed controls. Windowed controls all descend from TWinControl, which descends from the windows-only version of TControl.

Controls in the TWinControl branch:

  • Can receive focus while an application is running, which means they can receive keyboard input from the application user. In comparison, graphic controls can only display data and respond to the mouse.
  • Can be the parent of one or more child controls.
  • Have a handle, or unique identifier, that allows them to access the underlying window.

The TWinControl branch includes both controls that are drawn automatically (including TEdit, TListBox, TComboBox, TPageControl, and so on) and custom controls that C++Builder must draw, such as TDBNavigator, TMediaPlayer and TGauge. Direct descendants of TWinControl typically implement standard controls, like an edit field, a combo box, list box, or page control, and, therefore, already know how to paint themselves. The TCustomControl class is provided for components that require a window handle but do not encapsulate a standard control that includes the ability to repaint itself. You never have to worry about how the controls render themselves or how they respond to events; C++Builder completely encapsulates this behavior for you.

The TWinControl branch includes both controls that are drawn automatically (such as TEdit, TListBox, TComboBox, TPageControl, and so on) and custom controls that do not correspond directly to a single underlying Windows control. Controls in this latter category, which includes classes like TStringGrid and TDBNavigator, must handle the details of painting themselves. Because of this, they descend from TCustomControl, which introduces a Canvas property on which they can paint themselves.

See Also