Search code examples
c++graphicsmfccdc

Drawing Text with MFC CDC


I cannot set text alignment correctly. For instance, if I do this, then bottom alignment gets lost

memDC.SetTextAlign(TA_BOTTOM); 
memDC.SetTextAlign(TA_RIGHT);
memDC.TextOutW(textRect.left, textRect.top, _T("HELLo"));

And if I do this, then right alignment gets lost.

memDC.SetTextAlign(TA_RIGHT);
memDC.SetTextAlign(TA_BOTTOM); 
memDC.TextOutW(textRect.left, textRect.top, _T("HELLo"));

There does not seem to exist a way to keep both alignments. Any suggestions to fix this?


Solution

  • They're bitflags:

    memDC.SetTextAlign(TA_RIGHT | TA_BOTTOM);