Solved

button text color

Posted on 2000-03-20
2
264 Views
Last Modified: 2013-12-03
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;
0
Comment
Question by:marvinm
2 Comments
 
LVL 12

Accepted Solution

by:
pjknibbs earned 200 total points
ID: 2636070
Silly question: why don't you ever select hDisplayBitmap into hDisplayDC? This means hDisplayDC will contain the default MONOCHROME bitmap, which may not be helping you any.
0
 
LVL 1

Author Comment

by:marvinm
ID: 2636093
I just noticed that myself.
Thanks
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now