We help IT Professionals succeed at work.

What's the difference between "Owner Drawn" and subclassed control

I understand both techniques are used to change a control's behaviour, but I would like to know how they differ from one another in terms of Windows message processing and redirection.
Comment
Watch Question

AndyAinscowFreelance programmer / Consultant

Commented:
Subclassing means the control is of your 'custom type' where the functions in your class are available - not necessarily anything to do with drawing.

Owner drawn means just that - you draw it, all of it.  The only message/events being responded to are painting events.

Author

Commented:
Hi AndyAinscow.
So you say that a subclassed control gets all Windows messages, whereas an OwnerDrawn control only gets WM_PAINT?

Do you know of links to Win32 projects (not MFC) that show that?
AndyAinscowFreelance programmer / Consultant

Commented:
>>Do you know of links to Win32 projects (not MFC) that show that?

No.  But the principle would be the same in an MFC project.

Author

Commented:
And as for my other question/statement?
can I safely say that an ownerdrawn control gets just wm_paint and a subclass gets all messages?
In other words: a subclass is identical to ownerdrawn if I pass all but wm_paint to superclass?
Freelance programmer / Consultant
Commented:
You don't need to pass messages to the base class yourself, otherwise your understanding is pretty much correct about subclassing.  
With owner drawing you have to handle the drawing yourself, typically you would subclass the control for doing that.  It isn't about the messages, it is coding the drawing - see the DRAWITEMSTRUCT and WM_DRAWITEM message in the help files for more info.