I would use
CClientDC[
^] instead of calling
GetDC()
from edit control.
Also try to manually select the created font in your client DC like this:
CClientDC dc(&m_editSegments);
CFont* pOldFont = dc.SelectObject(&m_font);
CSize size = dc.GetTextExtent("....");
dc.SelectObject(pOldFont);
I've used something similar before and it worked for me.
NOTE: In case you need the average char width of the selected font you could use:
TEXTMETRIC txtMetric;
memset(&txtMetric, 0, sizeof(txtMetric));
dc.GetTextMetrics(&txtMetric);
I hope this helps :)