HOWTO calcualte real text length in a CStatic

Hi,
how can I calcualate/retrieve the length a CStatic really needs to show a given text.
- or -
How ca I realize a function to change a CStatic to the "optimal" length?
Thank for your help!
K.
[220 byte] By [kseybold] at [2007-11-18 2:14:14]
# 1 Re: HOWTO calcualte real text length in a CStatic
Hi,

Suppose If your static text is IDC_STATIC
Do like this.

CString st;
GetDlgItemText(IDC_STATIC,st);

then,
st.GetLength(); will return the length of string.

All the Best,
vikram.
vikram_patwardh at 2007-11-10 8:56:25 >
# 2 Re: HOWTO calcualte real text length in a CStatic
Use CDC::GetTextExtent for the first point and SetWindowPos for the second one.

Regards,
Snakekaa
Snakekaa at 2007-11-10 8:57:34 >