Your browser doesn't support JavaScript Creating Owner-Drawn Controls - Windows Programming

Creating Owner-Drawn Controls

Buttons, menus, static text controls, list boxes, and combo boxes can be created with an owner-drawn style flag. Typically, Windows handles the task of drawing a control however when a control has the owner-drawn style, the normal Windows drawing process is suppressed and the parent of the control will receive a WM_DRAWITEM and WM_MEASUREITEM message when the control is created and needs to be painted. This allows the developer to build controls with a custom-rendered appearance and adjust aspects unavailable using regular properties.

Example

The application below consists of customised listbox and a customised static box. The customised listbox displays a small bitmap next to each list item. Selecting any item will copy the Listbox item to the static box

owner drawn control combobox image


Example

The application below displays a customised menu. Clicking the file options displays an user-defined drop-down list

owner drawn control menu image