Reputation: 3486
I have created a component that has a paint override on the canvas and i would like to set a limit on minimum width and height. The scrollbar should appear at the side when the Width Or Height is less then the limit just like a scrollbox and can be scroll also.
i choose TCustomControl cause i paint and less flicker when double buffered.
any idea or better solution?
Upvotes: 2
Views: 938
Reputation: 163357
TScrollBox
and TCustomControl
both descend from TWinControl
. TScrollBox
and TScrollingWinControl
add scroll bars, whereas TCustomControl
adds a canvas. To get what you want, you can either add a canvas to a TScrollingWinControl
, or you can add scroll bars to a TCustomControl
.
Compare the definitions of the two classes (in Forms.pas and Controls.pas, respectively), and it should be clear which one's features will be easier to duplicate in your descendant. TCustomControl
adds three simple methods, implemented in about 40 lines of code. Write a TScrollingWinControl
descendant and copy the methods and properties from TCustomControl
into it.
Upvotes: 3