This looks wrong to me. You're only adjusting the left coordinate, but in case of a rotation in the world transform, you'll need to adjust the top as well.
Also, I think you may still be able to use DT_CENTER and DT_RIGHT rather than measuring the string beforehand. Creating a rectangle something like the original is difficult, but DrawText probably only needs to know the top-center or top-right point to do these other alignments. So it should be able to align things properly if you give it a rectangle where all corners are the point where it anchors the text.
DrawText doesn't need the original rectangle because gdiplus does the clipping and wrapping (and it already doesn't get the original rectangle anyway).
Vincent Povirk
On Sat, Jun 6, 2009 at 2:19 PM, Stephan Rosekermos@somrek.net wrote:
Adds support for horizontal string alignment to GdipDrawString without using DT_CENTER or DT_RIGHT.