Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

set text color on a static text control

jtcoelhojtcoelho Member Posts: 44
I would like to change the color on a text message i play on a static text control in a dialog box. I am working with VC6 and it's code is C. Thanks ahead.

Comments

  • pingpongpingpong Member Posts: 937
    [b][red]This message was edited by pingpong at 2005-6-14 18:27:40[/red][/b][hr]
    : I would like to change the color on a text message i play on a static text control in a dialog box. I am working with VC6 and it's code is C. Thanks ahead.
    :

    Check out WM_CTLCOLORSTATIC in MSDN. I didnt compile this code, but gives you an idea how to use it:
    [code]
    // in your dialog messsage loop
    case WM_CTLCOLORSTATIC:
    if(GetDlgItem(hDlg, MyStaticId) == (HWND)lParam) // is this our static
    control?
    {
    SetTextColor((HDC)wParam, RGB(255, 0, 0));
    return (HBRUSH)(COLOR_BTNFACE+1); // since you only want to change the text color
    }
    return 0; // dont mess with other static controls
    [/code]


  • rsaranrsaran Member Posts: 1
    case WM_CTLCOLORSTATIC:
    {
    ///
    /// By responding to this message, the parent window can use the
    /// specified device context handle to set the text and background
    /// colors of the static control.
    ///
    /// 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.
    ///
    if((HWND) lParam == GetDlgItem(hPwdDlg, IDC_STATIC5))
    {
    SetBkColor((HDC) wParam, (COLORREF) GetSysColor(COLOR_BTNFACE));

    SetTextColor((HDC) wParam, RGB(255, 0, 0));
    SetBkMode((HDC) wParam, TRANSPARENT);

    if(!hBrushStatic)
    {
    hBrushStatic = CreateSolidBrush( (COLORREF) GetSysColor(COLOR_BTNFACE));
    }

    return (UINT) hBrushStatic;
    }

    // Let Windows do default handling
    return FALSE;
    }
Sign In or Register to comment.