Solved

Problem with TextOut, SetTextColor and CFont on XP only.

Posted on 2006-06-13
4
629 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
  • 2
4 Comments
 
LVL 22

Expert Comment

by:mahesh1402
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
ahh Andy, it appears we were posting at the same time. Yes, it was monitor settings that affected the good change.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now