We help IT Professionals succeed at work.
Get Started

How to ownerdraw the internal scrollbar of a ListBox in C++?

Last Modified: 2013-12-26
I am using C++ with MS Visual Studio and the Windows API, not using MFC.

My problem is this:

I have a ListBox control with the WS_VSCROLL style and the LBS_OWNERDRAWVARIABLE style set -- I want to draw the internal scrollbar, the one created from WS_VSCROLL, myself, but I cannot figure out how to stop the default scrollbar from drawing (without removing the WS_VSCROLL style, which I want there for its functionality).

I can ownerdraw my custom scrollbar over top of the internal one, and this works fine most of the time, except when I am clicking and dragging the internal scrollbar - then the default one draws again.  Ideally what I really want to do is catch the message or function that draws the internal scrollbar, and handle all the drawing myself.

I have found all sorts of kludges online involving creating frame windows or drawing other controls over top of the internal one -- that is not what I want to do.  I want to do it in typical ownerdraw fashion, where I catch the functionality that draws the scrollbar and handle it myself instead of letting it draw.  Is there a way to do this?  

If not, does anyone have a good recommendation as to how to do this in a way that is relatively elegant?

Watch Question
This problem has been solved!
Unlock 2 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE