Sunday, July 21, 2013

Custom Controls in Win32 API: Visual Styles

Introduction
The last time we discussed basic of custom control's painting. Today, we will continue in the same direction and we will explore the visual styles (a.k.a. XP theming).

For creation of high quality custom controls, using this API properly is essential, yet quite complex task, so this article is longer then its predecessors and I kindly ask my readers for some patience when reading it. It will take some time before we start really using the API because first of all, we must take a look on the Windows theming from somewhat broader perspective.

UXTHEME.DLL and COMCTL32.DLL
The theming API is provided by the library UXTHEME.DLL which appeared in Windows XP. The two following screenshots demonstrate the difference between the themed and unthemed user experience:

Inline image 1 Inline image 2

The introduction of this library also affected the common controls library, COMCTL32.DLL. For compatibility reasons, Windows XP (and all newer Windows versions) are equipped with two different versions of COMCTL32.DLL.

At the standard path C:\Windows\System32\, the old COMCTL32.DLL version 5 can be found. This library version contains implementation of the standard controls like list view, combo-box etc. which are unaware of UXTHEME.DLL existence, hence application linked with this library generally are not themed.

Newer version 6 of the COMCTL32.DLL resides under C:\Windows\WinSxS\, available as a side-by-side assembly. Only applications explicitly manifesting their compatibility with the library version 6 use it. The other applications simply continue to using the version 5.

Read more: Codeproject
QR: Inline image 3