Link to home
Start Free TrialLog in
Avatar of marvinm
marvinm

asked on

button text color

I have subclassed a button, and am trying to paint the text in red, but it always appears black.  Here is part of my paint code:
case WM_PAINT:
      GetClientRect(hwnd,&aRect);
      hDC = BeginPaint(hwnd,&ps);
      hDisplayBitmap = CreateCompatibleBitmap(hDC,aRect.right-aRect.left,aRect.bottom-aRect.top);
      hDisplayDC = CreateCompatibleDC(hDC);
      hBrush = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
      FillRect(hDisplayDC,&aRect,hBrush);
      DeleteObject(hBrush);
      GetWindowText(hwnd,FinalText,100);
      SetBkColor(hDisplayDC,GetSysColor(COLOR_3DFACE));
      SetBkMode(hDisplayDC,TRANSPARENT);
      GetTextExtentPoint32(hDisplayDC,FinalText,strlen(FinalText),&tSize);
      iTextHPos = max(0,((aRect.right - aRect.left - tSize.cx)/2));
      iTextVPos = max(0,((aRect.bottom - aRect.top - tSize.cy)/2));
      SetTextColor(hDisplayDC,RGB(255,0,0));
      TextOut(hDisplayDC,iTextHPos,iTextVPos,FinalText,strlen(FinalText));
      BitBlt(hDC,0,0,aRect.right-aRect.left,aRect.bottom-aRect.top,hDisplayDC,0,0,SRCCOPY);
      DeleteDC(hDisplayDC);
      DeleteObject(hDisplayBitmap);
      DrawEdge(hDC,&aRect,EDGE_RAISED,BF_RECT);
      EndPaint(hwnd,&ps);
      return 0;
ASKER CERTIFIED SOLUTION
Avatar of pjknibbs
pjknibbs

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of marvinm
marvinm

ASKER

I just noticed that myself.
Thanks