Thread: SetTextColor question

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    57

    SetTextColor question

    When i use that function, the color of the text never change, except if i use inside WM_CTLCOLOREDIT...
    How to make it work outside? thanks =]

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    If you are using it with a control, that's really the only effectively simple place to use it. Another option is to subclass the control in question but you may end up having to handle the entire drawing for the control as attempts to CallWindowProc for default system rendering may sometimes result in changes you've made being overridden. A third option, if you're confronted with having to draw the control yourself, is to owner-draw it; refer to the individual control documentation on msdn for how to do this.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    34
    Try this.

    case WM_CTLCOLOREDIT:
    hdc = (HDC)wParam;
    SetTextColor(hdc, RGB(255,0,0)); // red
    SetBkColor(hdc, RGB(255,255,0)); // yellow
    return GetSysColorBrush(COLOR_3DHILIGHT); // hilight colour
    go here for more info.
    http://www.catch22.net/tuts/tips.asp#EditColour
    Its Really All up to you.

  4. #4
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    unkownname, Tropicalia said that he already can get it to work in WM_CTLCOLOREDIT.

    Try
    Code:
    case WM_XXX: // Never use this code in WM_PAINT.
    HDC hdc = GetDC(hwnd);
    SetTextColor(hdc, RGB(255,0,0)); // red
    SetBkColor(hdc, RGB(255,255,0)); // yellow
    break;

Popular pages Recent additions subscribe to a feed