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 all those 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 <= XControl <= XVisual <= XClass <= TObject

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 descenders 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 much. When You combine control from others, derive it from (e.g.) XCustomBevel and create its internal sub-controls as member fields (between calls of MembersCreating and MembersCreated methods). Also override method AdjustMembers to set its positions and sizes when size (or something 'layout') of control itself is changed.
    When combined control is painting, first of all PaintChildren is called. You may override it to change order of painting of child and member controls. Then, PaintTo is called. By default, it just excludes contol's region from further painting. If control has some content or even has to erase the rest of its rectangle, override it.


goto XCL page

goto home page