Programming Windows - Creating Owner-Drawn Controls


Home | API | MFC | C++ | C | Previous | Next

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


Home | API | MFC | C++ | C | Previous | Next

Creating a Simple Window | Common Elements | Data Types and Character Sets | The Device Context | Graphics Device Interface | Displaying Text | Displaying Graphics | Mapping Modes | Keyboard Input | Working with the Mouse | Menus | Child Windows | The Dialog Box | Windows Message Box | Common Dialog Box | Bitmaps | Common Controls | Creating a Toolbar | Multiple Document Interface | Timers | DLL’s | Creating Custom Controls | Owner Drawn Controls | API Hooking and DLL Injection | File Management Functions | String Manipulation | System Information Functions

Last Updated: 15 September 2022