IssacJones
asked on
Static Control Size
Hiya
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_M YSTATIC);
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?
John
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_M
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?
John
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome
ASKER