Click to See Complete Forum and Search --> : Chenging font color


Jump_Around
June 12th, 2003, 07:06 AM
How to changa a font color on Static ctrl using win api

Please help

Lighthill
June 12th, 2003, 07:17 AM
Hi, your winproc has to process the WM_CTLCOLORSTATIC Message. You'll get a valid hDC which you can use for SetTextColor, SetBkcolor ...

Jump_Around
June 12th, 2003, 07:37 AM
This is what I got

in function

int proxyDialog(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam)

{
switch(message)
{
case WM_CTLCOLORSTATIC:
{
RECT rc;
HWND hnd = (HWND)GetDlgItem(hWnd, IDC_LINK);
::GetClientRect(hnd, &rc);
HDC hdc= (HDC) wparam;
SetTextColor(hdc, RGB(255,0,0));
return (int) hBrush;
}
...
}

It doesnt change the color of the text on my static IDC_LINK.
How to distinquish wheater WM_CTLCOLORSTATIC is called for IDC_LINK only


Please help

Lighthill
June 12th, 2003, 10:06 AM
Hmm, it works only if your hbrush is a valid handle. I tried it in a Dialog Proc, it works only if i return TRUE or a valid brush. In case of FALSE/NULL the textcolor hasn't changed its color. It could help if you would post your declaration of hbrush.