Ah, I feel a rant coming on. How many hours must I spend fighting with CommCtrls 6 just to get my app to look right under XP.
To start lets go for ownerdraw buttons. The second you ask for ownerdraw (or bitmap buttons for that matter) XP decides that you couldn't possibly want the themed background for your button. I had to find the code to do the entire drawing process myself. Wonderful.
Continuing on the theme (pun not intended) of buttons, try creating a simple application with a number of buttons on a dialog. Enable theming for this application and keep running the app. Try moving the focus between buttons by clicking on each different one, and then separately try using the keyboard to move between them. If you can describe the rules that define the difference between these two drawing styles (below) then please do let me know:
And now to tab controls. These can look really nice when properly themed. The only problem is that it seems nigh-on impossible to get this right.
Scenario 1: Create a tab control on a dialog, and use dialogs for the pages. The tab control will appear correctly themed, but the dialogs (the tab pages) will not. Use EnableThemeDialogTexture I hear you cry. Unfortunately, while this might appear to work at first you'll notice two things:
1) The background of the tab page does not contain the correct gradiented background, but simply a plain colour all over. wrong.
2) Try adding a checkbox to the dialog. Oh dear, it would appear that the checkbox is drawing the old grey colour instead of the nice white that should be used. disaster!
I tried a number of different ways to solve this problem including overriding WM_ERASEBKGND, WM_CTLCOLORDLG, WM_CTLCOLORSTATIC and friends. None of these could get the correct gradient in the background of the tab.
Scenario 2: At this point, I noticed that property pages seemed to look OK in some programs that I'd seen, so I decided to try swapping my tab control for a property sheet and see if that works.
Low and behold, my first tab looked fantastic - all the controls were correctly themed, the checkboxes had transparent backgrounds and the tab had a gradient. Who knows what's different between a property sheet and a tab control.
Then I switched to my second tab page (which had only a list control on it). disaster! The second page had the all-original, everyone's favorite COLOR_BTNFACE background. So why did one page work, and the other not? To cut a long story short (one which involved lots of resource editing and recompiling) I discovered that page one had a button control on it, and page two didn't. Adding a single button to page two enabled the theming. Please, someone, explain this madness to me!
If anyone has a surefire way to enable theming on XP tab controls, then please let me know. I would be most grateful for your help.Posted by Simon at November 29, 2002 05:28 PM