Saturday, 14 September 2013

Radio button, check box and group box are not properly painted with WM_CTLCOLORSTATIC handler

Radio button, check box and group box are not properly painted with
WM_CTLCOLORSTATIC handler

INTRODUCTION AND RELEVANT INFORMATION:
I have 2 dialog boxes created via Resource editor.
Since I use Microsoft Visual Studio Express edition, I had to download
free resource editor to create them.
Resource editor is ResEdit, x32 version, and I have downloaded it from here:
http://www.resedit.net/
In my program, I have visual styles enabled like this:
#include <commctrl.h>
#pragma comment( lib, "comctl32.lib")
#pragma comment( linker, "/manifestdependency:\"type='win32' \
name='Microsoft.Windows.Common-Controls'
version='6.0.0.0' \
processorArchitecture='*'
publicKeyToken='6595b64144ccf1df' \
language='*'\"")
As far as I know, check box, radio button, and group box get
WM_CTLCOLORSTATIC message for painting their text.
This is what I have coded for the first dialog box:
case WM_CTLCOLORSTATIC:
{
SetBkMode( (HDC)wParam, TRANSPARENT );
SetTextColor( (HDC)wParam, RGB( 0, 0, 0 ) );
return (INT_PTR)( (HBRUSH)GetStockObject(NULL_BRUSH) );
}
I just want those controls to have transparent background and black color
of their text.
THE PROBLEM:
Bellow is the image of what I get in dialog boxes:
On Windows XP, here is the result for first dialog:

Group box has blue text, and brown border, while check box has everything
black.
On Windows 7, after starting yhe same program, I get this:

Here, group box and check box have proper text color, yet background of
the check box and the border of the group box are wrong.
In my dialog box, I have static controls and they are painted properly.
WHAT HAVE I TRIED SO FAR:
I have browsed through SO archive, but haven't found anything I could use
to modify my WM_CTLCOLORSTATIC handler.
I have found an example which removes visual styles from those controls,
so it can achieve the desired result, but I need to keep the visual style
and make the background of the text transparent, thus this solution can
not satisfy me.
At this moment I still keep searching online, but at the moment I ahve no
luck, I guess I'm a poor Googler.
THE QUESTION:
How can I modify my WM_CTLCOLORSTATIC handler to fix my problem ?
If the above is not possible, can I get the desired effect with
NM_CUSTOMDRAW ?

No comments:

Post a Comment