Question

I am writing a GUI wrapper for windows api right now ( i can't use qt or mfc ). The library itself is extremely basic. After subclassing windows common controls ( and wrapping them into the classes ) i have faced a problem. As far as i know (and i hope i am wrong), only parent control can handle a message like WM_CTLCOLOREDIT and the same. But i want to be able to write something like this:

myedit->SetBkColor ( RGB ( 0, 0, 0 ) );

Is it possible to implement at all ( like in windows forms, for example ), or i should write a new controll from scratch, and write the painting by myself?

Thank you, #535.

Was it helpful?

Solution

You can do it, but it is a fair amount of work. The basic idea is that you create another window to act as the parent to the control you're subclassing. In that, you keep track of whether a notification message (e.g. WM_CTLCOLOREDIT) is being handled by the parent or the sub-classed control itself. If it's being handled by the parent, it just passes the message through, but if it's supposed to be handled by the subclassed control itself, it reflects it back to the control.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top