Static Control Size
Posted on 2010-09-16
I have an interesting problem which I hope somebody can help me with.
I have a static control in which I am displaying text.
I have been trying to get the rectangle in which the text occupies - which is going to be smaller than the static controls rectangle.
I tried to do this using the following:
CStatic* control = (CStatic*)GetDlgItem(IDC_MYSTATIC);
CString s = "This is a long message\n\nwith line breaks";
CRect rect = CRect(CPoint(0,0) ,CPoint(0,0));
CDC* pDC = control.GetDC();
pDC->DrawText( s, rect, DT_CALCRECT );
However, the dimensions of rect are not correct e.g. rect appears too wide.
Can anybody tell me what I'm doing wrong?