?
Solved

Problem with TextOut, SetTextColor and CFont on XP only.

Posted on 2006-06-13
4
Medium Priority
?
636 Views
Last Modified: 2013-11-20
I'm using the following code to draw a text label into a device context:

      CFont font;
      font.CreateFont(
         m_iTextHeight,                        // nHeight
         0,                         // nWidth
         angle,                     // nEscapement
         angle,                     // nOrientation
         FW_NORMAL,                   // nWeight
         FALSE,                     // bItalic
         FALSE,                     // bUnderline
         0,                         // cStrikeOut
         ANSI_CHARSET,              // nCharSet
         OUT_DEFAULT_PRECIS,        // nOutPrecision
         CLIP_DEFAULT_PRECIS,       // nClipPrecision
         DEFAULT_QUALITY,           // nQuality
         DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
         "Verdana");                // lpszFacename

        m_LabelColor = RGB(0,0, 255);

      memDC->SelectObject(&font);
      memDC->SetBkMode(TRANSPARENT);
      memDC->SetTextColor(m_LabelColor);
      memDC->SetTextAlign(TA_CENTER|TA_BOTTOM);
      memDC->TextOut( (m_pEndPoint->x + m_pStartPoint->x)/2, ((m_pEndPoint->y + m_pStartPoint->y)/2)-5, m_sLabel, m_sLabel.GetLength());

------------------------
On Windows 2000, this works perfectly. I recently ran my app on XP though, and, while the text is drawn in the right location, rather than seeing the solid color text I see under Win2k, the font is a deeper color, and seems to have a border (like a 1px stroke around the character) in a different purplish color, which is making the text very difficult to read and quite ugly.. Again, only on XP.

Any ideas what the fix might be?

Thanks!
0
Comment
Question by:PMH4514
[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
4 Comments
 
LVL 22

Expert Comment

by:mahesh1402
ID: 16900117
Try with OUT_TT_ONLY_PRECIS instead of OUT_DEFAULT_PRECIS..

Another thing to test is using DEFAULT_CHARSET as the charset parameter - this parameter allows the name and size of a font to fully describe the logical font.
CreatePointFont is another call which restricts the font to a name and a height.

-MAHESH
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 16902253
Font colour - is this a monitor thing?  (I run two monitors (different models) with the same settings and do see a difference with the colour between the two).

Can you try physically attaching a different monitor (eg that from your Win 2000 system) and seeing if the colour is still lousy.


Also check the display settings between the 2000 and XP systems.
0
 

Author Comment

by:PMH4514
ID: 16902374
Thanks MAHESH, that had no impact though.

I did find however, that by changing some of the large/small font settings on the XP desktop, that the "problem" resolved itself.
0
 

Author Comment

by:PMH4514
ID: 16902406
ahh Andy, it appears we were posting at the same time. Yes, it was monitor settings that affected the good change.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

777 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