CDC::DrawText ignores '&'

  • Thread starter Thread starter Safiullah
  • Start date Start date
S

Safiullah

Guest
I have the Following code running:

strBlockText = "AND";
CString string(strBlockText.c_str());
arg_pDC->SetTextColor(RGB(0, 0, 0));
arg_pDC->SetTextAlign(TA_LEFT | TA_TOP);
arg_pDC->MoveTo(arg_ptOrigin + CPoint(3, 3));
arg_pDC->DrawText(string, &objBlockRect, 0);


This prints correctly in the desired location.

However, when I change the string to something like this:

strBlockText = "A&D";
CString string(strBlockText.c_str());
arg_pDC->SetTextColor(RGB(0, 0, 0));
arg_pDC->SetTextAlign(TA_LEFT | TA_TOP);
arg_pDC->MoveTo(arg_ptOrigin + CPoint(3, 3));
arg_pDC->DrawText(string, &objBlockRect, 0);


The '&' gets ignored and I only get AD.

Do I need to use an escape character for &?

1355285.png

Continue reading...
 
Back
Top