I've created a static text control using the resource.
I have two questions:
1) Is there a way to apply a color to the static within the resource?
2) How can I change the color after the static control was already created?
Thank you.
Printable View
I've created a static text control using the resource.
I have two questions:
1) Is there a way to apply a color to the static within the resource?
2) How can I change the color after the static control was already created?
Thank you.
1) not sure
2) you catch the WM_CTLCOLORSTATIC message
* Can I use the lParam to match the handle to the handle of the static control I wish to paint?Quote:
Syntax
ParametersCode:WM_CTLCOLORSTATIC
WPARAM wParam
LPARAM lParam;
wParam
Handle to the device context for the static control window.
lParam
Handle to the static control.
Return Value
If an application processes this message, the return value is a handle to a brush that the system uses to paint the background of the static control.
* Also, I've tried to color the text itself without the background color but it doesn't work...
Code:case WM_CTLCOLORSTATIC:
SetTextColor((HDC)wParam, RGB(0, 255, 0));
return((HBRUSH)0);
To return a NULL brush, use GetStockObject(NULL_BRUSH).Quote:
Originally Posted by Devil Panther
You should also call SetBkMode to make the background of the text (not the static control) transparent.
Code:case WM_CTLCOLORSTATIC:
{
HDC hdc = (HDC) wParam ;
HWND ctrl = (HWND) lParam ;
SetBkMode( hdc, TRANSPARENT );
SetTextColor( hdc, RGB(0, 255, 0) );
return (LRESULT)GetStockObject(NULL_BRUSH);
}
Something is not working...
The result of the code is black text on a white background :(
Hmm, it seemed to work for me when I posted that snippet yesterday.
Mind posting your code?
oops, got the lParam and wParam mixed up :D
it works fine now, thank you.