Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

button text color

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

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 article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

715 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