VOID Example_MeasureString(HDC hdc)
{
Graphics graphics(hdc);
// Set up the string.
WCHAR string[] = L"Measure Text";
Font font(L"Arial", 16);
RectF layoutRect(0, 0, 100, 50);
RectF boundRect;
// Measure the string.
graphics.MeasureString(string, 12, &font, layoutRect, &boundRect);
// Draw a rectangle that represents the size of the string.
graphics.DrawRectangle(&Pen(Color(255, 0, 0, 0)), boundRect);
}