是否可以在滚动条上绘制? [英] Is it possible to paint on scrollbars?

查看:365
本文介绍了是否可以在滚动条上绘制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在TMemo,TListbox等标准控件的滚动条上绘制?



我需要的是在滚动条上绘制一些基本的形状,我试图避免从stratch中实现整个滚动的东西。任何指针? TIA!

解决方案

确实有可能,你可能想看看 WM_NCPAINT 消息,这是非客户区对应版本的 WM_PAINT 消息。这不是一件容易的事情,但是由于你不会自己做整个滚动条,所以可能会更加直观。



此外,您可能会发现有趣的是,它也拥有了滚动条,我知道你只想要画在滚动条的顶部,但我的打赌是这也将帮助您,它也包括源代码。



Cool Scrollbar项目的屏幕截图http://www.catch22.net/img/coolscroll02.gif



可能有助于检查VCL源代码,以便检索滚动条按钮的位置信息等等。代码可以在forms.pas文件中找到,至少这是我简短搜索的样子。希望任何一个可以帮助。祝你好运。



[1] http://www.codeproject.com/KB/dialog/skinscrollbar.aspx

[2] http://www.catch22.net/tuts/coolscroll


Is it possible to paint on the scrollbars of standart controls like TMemo, TListbox, etc..?

All I need is to draw some basic shapes on the scrollbars and I'm trying to avoid implementing whole scrolling stuff from stratch. Any pointers? TIA!

解决方案

It is indeed possible, you might want to take a look at the WM_NCPAINT message, this is the non-client area corresponding version of the WM_PAINT message. This is not an easy task, however since you are not about to do the entire scrollbar drawing yourself it might be more straight forward.

Further more you might find this article [1] from The Code Project interesting, the code is in C++ and not entirely well formatted, but it should give some idea as to how one could achieve ownerdrawing of scrollbars.


Screenshot from the previous mentioned project at TCP.

Besides the first project you might find this project [2] interesting, it also ownerdraws the scrollbar, I'm aware that you only want to draw on top of the scrollbar but my bet is that this will help you as well, it includes source code as well.

Screenshot from Cool Scrollbar project http://www.catch22.net/img/coolscroll02.gif
Screenshot from the Cool Scrollbar project.

It might help to examine the VCL Source code in order to retrieve information on position of the scroll bar buttons etc. The code can be found in the forms.pas file, at least that's what it seemed like from my brief search. Hope any of this can be of any help. Good luck.

[1] http://www.codeproject.com/KB/dialog/skinscrollbar.aspx
[2] http://www.catch22.net/tuts/coolscroll

这篇关于是否可以在滚动条上绘制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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