Solved

Class derived from CScrollBar does not recieve ON_WM_CTLCOLOR!

Posted on 2008-10-14
3
619 Views
Last Modified: 2013-11-20
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?

TIA
0
Comment
Question by:mrwad99
3 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 100 total points
ID: 22711543
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,

ZOPPO
0
 
LVL 19

Assisted Solution

by:alb66
alb66 earned 25 total points
ID: 22711625
Zoppo is right. Here you can find an explanation on how reflection works:
http://msdn.microsoft.com/en-us/library/eeah46xd(VS.71).aspx
0
 
LVL 19

Author Comment

by:mrwad99
ID: 22711692
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)
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question