How to make a TScrollbox out from TCustomControl?

Deadly 提交于 2019-12-11 03:33:51

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/9627831/how-to-make-a-tscrollbox-out-from-tcustomcontrol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!