XCanvas classcontrols of XControls unitXCustomControl class (in XControls.pas unit)

    XCustomControl class is derived from XControl and is intended to be a base class for all self-painting controls, which are not windowed. Such controls are similar to TGraphicControl in VCL and do not need in window handle, using parent window (form) for showing. But those all require XCanvas to perform painting and must be painted itself. Also, its are not using standard Microsoft Foundation Classes to do what its have to do. So, code of applet, which contains such controls, can be larger, then in case of using only MFC-based controls. And creating of new self-painted control can be more complicated task, then creating of mfc-based ones.
    Therefore, self-painted controls have some additional advantages. First, its are created by us and not by Windows creators. So, we can make its more clever, using more advanced algorithms to perform some works (e.g., handling of huge data arrays). Or, we can perform painting without flickering, using rotated text (MFC-based controls can not draw rotated text correctly), custom backgrounds and so on.
    It is also possible to combine self-painted and mfc-based controls together on one form (but this will increase applet size).

XCustomControl = class(XControl);

Properties, inherited from XControl:

Properties, inherited from XVisual:

Properties inherited from XClass:

 


XCustomControl methods:

Methods, inherited from XControl:

Methods, inherited from XVisual:

 

Methods inherited from XClass:


Event of XCustomControl:


Tasks.

    Use XCustomControl to create self-painted non-windowed controls. Look at other its descendent to understand how to do it.
    Pay attention to implementation of controls, combined from other ones (XCustomButton, XGroup, etc.) Combining the control from already existing is simplifying its developing very well. When You combine control from other, derive it from XCustomBevel and create its internal sub-controls as private fields. In constructor create it with no parent, assigning OwnerForm to its OwnerForm properties. Also do not forget override method SetOwnerForm, calling inherited one and reassigning the value to OwnerForm properties of internal controls.
    You may place and size internal controls where You wish. (Changing of its bounds does not lead to realigning or resizing form and its controls, because its Parent is nil).
    Painting of combined controls usually consist of overriding PaintTo method, where You have to recall PaintTo methods of internal control, and (may be) paint something else (e.g., call OnDrawFocusRect event of GlobalFormsManager as it is made for XButton). At the end of painting self-painted control must erase rest of its rectangle with background color and exclude it from clipping region (using ExcludeUpdRect or ExcludeUpdRegion methods). When You erase background after painting of internal controls (with no parent), You have to perform excluding its rectangle by yourself - in combined control.


goto XCL page

goto home page