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.
(source: catch22.net)
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.
Updated links, the cool scrollbar page seems to be down, so I have linked to the archived version
[1] https://www.codeproject.com/Articles/14724/Replace-a-Window-s-Internal-Scrollbar-with-a-custo [2] https://web.archive.org/web/20170924110426/http://www.catch22.net/tuts/custom-scrollbars
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With