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.rig ht-aRect.l eft,aRect. bottom-aRe ct.top);
hDisplayDC = CreateCompatibleDC(hDC);
hBrush = CreateSolidBrush(GetSysCol or(COLOR_3 DFACE));
FillRect(hDisplayDC,&aRect ,hBrush);
DeleteObject(hBrush);
GetWindowText(hwnd,FinalTe xt,100);
SetBkColor(hDisplayDC,GetS ysColor(CO LOR_3DFACE ));
SetBkMode(hDisplayDC,TRANS PARENT);
GetTextExtentPoint32(hDisp layDC,Fina lText,strl en(FinalTe xt),&tSize );
iTextHPos = max(0,((aRect.right - aRect.left - tSize.cx)/2));
iTextVPos = max(0,((aRect.bottom - aRect.top - tSize.cy)/2));
SetTextColor(hDisplayDC,RG B(255,0,0) );
TextOut(hDisplayDC,iTextHP os,iTextVP os,FinalTe xt,strlen( FinalText) );
BitBlt(hDC,0,0,aRect.right -aRect.lef t,aRect.bo ttom-aRect .top,hDisp layDC,0,0, SRCCOPY);
DeleteDC(hDisplayDC);
DeleteObject(hDisplayBitma p);
DrawEdge(hDC,&aRect,EDGE_R AISED,BF_R ECT);
EndPaint(hwnd,&ps);
return 0;
case WM_PAINT:
GetClientRect(hwnd,&aRect)
hDC = BeginPaint(hwnd,&ps);
hDisplayBitmap = CreateCompatibleBitmap(hDC
hDisplayDC = CreateCompatibleDC(hDC);
hBrush = CreateSolidBrush(GetSysCol
FillRect(hDisplayDC,&aRect
DeleteObject(hBrush);
GetWindowText(hwnd,FinalTe
SetBkColor(hDisplayDC,GetS
SetBkMode(hDisplayDC,TRANS
GetTextExtentPoint32(hDisp
iTextHPos = max(0,((aRect.right - aRect.left - tSize.cx)/2));
iTextVPos = max(0,((aRect.bottom - aRect.top - tSize.cy)/2));
SetTextColor(hDisplayDC,RG
TextOut(hDisplayDC,iTextHP
BitBlt(hDC,0,0,aRect.right
DeleteDC(hDisplayDC);
DeleteObject(hDisplayBitma
DrawEdge(hDC,&aRect,EDGE_R
EndPaint(hwnd,&ps);
return 0;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks