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!
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 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
Sounds like you could create a custom control (deriving from TMemo or whatever). You could override
the Paint
procedure of that control as described here.
I don't know if that will allow you draw on the scrollbars but hopefully it helps you in creating a custom control.
EDIT
A combonation of Tommy's answer and mine: Here is an example (albeit a bit more complex) that uses the WindowProc
method to handle messages in a custom control. If you create a control you maybe able to handle the WM_NCPAINT
message. Also here is some more info about Windows Message handling in Delphi.