Class derived from CScrollBar does not recieve ON_WM_CTLCOLOR!

Ah hello.

I have derived a class from CScrollBar, CMyScroll.  I add a V scrollbar and H scrollbar to my dialog, then link them up via DDX so they are instances of CMyScroll. In the CMyScroll class I handle the OnCtlColor message, in the hope of painting the scrollbar a different colour internally, as opposed to having to have OnCtlColor in the parent dialog

However, this message never gets sent, so my OnCtlColor function never gets called.

I can stick a breakpoint on CMyScroll::PreTranslateMessage, and this gets hit, but not OnCtlColor.

Why is this?

LVL 19
Who is Participating?
ZoppoConnect With a Mentor Commented:
Hi mrwad99,

this message is sent to the parent window of the control, not to the control itself. It should work with message reflection using the macro ON_WM_CTLCOLOR_REFLECT.

Hope that helps,

alb66Connect With a Mentor Commented:
Zoppo is right. Here you can find an explanation on how reflection works:
mrwad99Author Commented:
Thank you ZOPPO, that now works.

Thanks alb66; I keep meaning to read that link...perhaps if I would have read it earlier I would not have asked this question :o)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.