Salman Mughal
2007-02-01 19:16:02 UTC
In a Win32 app (no MFC) running on XPsp2, I have a window with a custom
background image (bitmap) and several controls on it (static text, edit
boxes, buttons, etc.). I would like all of the text drawn on the window to
have a transparent background so the image is not obscured. For the static
controls, I'm handling the WM_CTLCOLORSTATIC message and returning a
transparent brush using the following method:
LRESULT CMyWindow::OnControlColorStatic(HDC hdc, HWND hwndControl)
{
LRESULT ret = 0L;
if (hwndControl == one_of_the_static_labels_on_my_page)
{
SetBkMode(hdc, TRANSPARENT);
ret = (LRESULT)GetStockObject(HOLLOW_BRUSH);
}
else
ret = (LRESULT)GetStockObject(WHITE_BRUSH);
return ret;
}
This works fine. When I try to do the same thing with a checkbox button on
the window, however (handling the WM_CTLCOLORBTN message), I still get the
checkbox background drawn white, not transparent. Is there something
additional I need to do? Not sure it's relevant, but the button style is
BS_AUTOCHECKBOX.
background image (bitmap) and several controls on it (static text, edit
boxes, buttons, etc.). I would like all of the text drawn on the window to
have a transparent background so the image is not obscured. For the static
controls, I'm handling the WM_CTLCOLORSTATIC message and returning a
transparent brush using the following method:
LRESULT CMyWindow::OnControlColorStatic(HDC hdc, HWND hwndControl)
{
LRESULT ret = 0L;
if (hwndControl == one_of_the_static_labels_on_my_page)
{
SetBkMode(hdc, TRANSPARENT);
ret = (LRESULT)GetStockObject(HOLLOW_BRUSH);
}
else
ret = (LRESULT)GetStockObject(WHITE_BRUSH);
return ret;
}
This works fine. When I try to do the same thing with a checkbox button on
the window, however (handling the WM_CTLCOLORBTN message), I still get the
checkbox background drawn white, not transparent. Is there something
additional I need to do? Not sure it's relevant, but the button style is
BS_AUTOCHECKBOX.