如何从TCustomControl中制作一个TScrollbox? [英] How to make a TScrollbox out from TCustomControl?

查看:81
本文介绍了如何从TCustomControl中制作一个TScrollbox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个在画布上具有覆盖油漆的组件,我想设置最小宽度和高度的限制。当Width或Height小于极限值时,滚动条应出现在侧面,就像滚动框一样,并且也可以滚动。

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.

我选择TCustomControl导致我绘制并减少了

i choose TCustomControl cause i paint and less flicker when double buffered.

任何想法或更好的解决方案?

any idea or better solution?

推荐答案

TScrollBox TCustomControl 均来自 TWinControl TScrollBox TScrollingWinControl 添加滚动条,而 TCustomControl 添加滚动条帆布。要获得所需的内容,可以将画布添加到 TScrollingWinControl ,也可以将滚动条添加到 TCustomControl

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.

比较两个类的定义(分别在 Forms.pas Controls.pas 中) ,并且应该清楚哪些功能在后代中更容易复制。 TCustomControl 添加了三个简单的方法,用大约40行代码实现。编写 TScrollingWinControl 后代,并将方法和属性从 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.

这篇关于如何从TCustomControl中制作一个TScrollbox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆