Solved

button text color

Posted on 2000-03-20
2
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

617 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