Friday, May 18, 2007

GDI+ Display Text center in the Specified Rectangle _

Display the Text center in the specified rectangle :
-------------------------------------------------------------------------
we can convert this code into VC++ GDI+ code...
Rectangle rect1 = new Rectangle(10, 10, 130, 140);

// Create a StringFormat object with the each line of text, and the block
// of text centered on the page.
StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = StringAlignment.Center;
stringFormat.LineAlignment = StringAlignment.Center;

// Draw the text and the surrounding rectangle.
e.Graphics.DrawString(text1, font1, Brushes.Blue, rect1, stringFormat);

No comments: