The concept of owner drawn controls is not MFC specific. For some Windows controls it is already implemented (buttons, combo boxes, list boxes, and menus). When setting the corresponding owner draw style flag for these controls, the normal drawing is suppressed and a
WM_DRAWITEM
message is send to the window. MFC supports owner drawing for these controls (
CButton
,
CComboBox
,
CListBox
,
CMenu
) by implementing an empty virtual
DrawItem()
member function which is called upon the
WM_DRAWITEM
message. With owner drawn controls, this function must be implemented in the drived class. See
CButton::DrawItem[
^] for an example.
Implementing owner draw for other controls can be done by handling the
WM_PAINT
and
WM_ERASEBKGND
messages. With MFC, derive a class and add handlers for these messages performing your own drawing without calling the corresponding base class functions.