How to make TScrollbox from TCustomControl?

I created a component that has overriding paint on canvas, and I would like to set a limit on the minimum width and height. A scroll bar should appear on the side when the width or height is less than the limit, just like scrolling, and you can also scroll.

I choose TCustomControl because I draw and flicker less with double buffering.

any idea or better solution?

+2
source share
1 answer

TScrollBox and TCustomControl both descend from TWinControl . TScrollBox and TScrollingWinControl add scrollbars, while TCustomControl adds canvas. To get what you want, you can either add the canvas to TScrollingWinControl or add scrollbars to TCustomControl .

Compare the definitions of the two classes (respectively in Forms.pas and Controls.pas), and it should be clear which functions will be easier to duplicate in your descendant. TCustomControl adds three simple methods, implemented in approximately 40 lines of code. Write a descendant of TScrollingWinControl and copy the methods and properties from TCustomControl .

+3
source

Source: https://habr.com/ru/post/1497145/


All Articles