Can someone please explain me which control is better to create custom componens? What is the difference between twincontrol and tcustomcontrol?
Thank you in advance
Can someone please explain me which control is better to create custom componens? What is the difference between twincontrol and tcustomcontrol?
Thank you in advance
That depends on what kind of component you are making and what its requires are.
Is it visual?
If no, use
TComponent
.if yes, does it need its own
HWND
(input focus, window messages, etc)?If no, use
TGraphicControl
.If yes, does it need to custom paint itself?
if yes, use
TCustomControl
.if no, use
TWinControl
.TCustomControl
is aTWinControl
descendant that adds some additional handling for theWM_PAINT
message, on top of whatTWinControl
does.TCustomControl
exposes a publicCanvas
property that you can draw on. During painting, it enables thecsCustomPaint
flag in theControlState
property, and then calls a virtualPaint()
method that your component can override. So the benefit ofTCustomControl
is that it makes custom painting a little easier to manage. Nothing more.