Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

button text color

Posted on 2000-03-20
2
Medium Priority
?
277 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 800 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

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

824 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