Solved

Problem with TextOut, SetTextColor and CFont on XP only.

Posted on 2006-06-13
4
634 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 125 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.

731 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