• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 641
  • Last Modified:

Problem with TextOut, SetTextColor and CFont on XP only.

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
PMH4514
Asked:
PMH4514
  • 2
1 Solution
 
mahesh1402Commented:
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
 
AndyAinscowCommented:
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
 
PMH4514Author Commented:
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
 
PMH4514Author Commented:
ahh Andy, it appears we were posting at the same time. Yes, it was monitor settings that affected the good change.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now