Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem with TextOut, SetTextColor and CFont on XP only.

Posted on 2006-06-13
4
Medium Priority
?
638 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 45

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

618 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