XBasic3000
XBasic3000

Reputation: 3486

How to make a TScrollbox out from TCustomControl?

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

Answers (1)

Rob Kennedy
Rob Kennedy

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

Related Questions