Paul N a �crit :
> Could you show me how you are getting the DC to use in GetTextMetrics,
> please?
Nothing special, just GetDC(), and I get same results than calling it on
main window =>
In Main window WM_CREATE :
LOGFONT lf = { 0 };
SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf,
FALSE);
hFont = CreateFontIndirect(&lf);
SendMessage(hEdit, WM_SETFONT, (WPARAM) hFont, FALSE);
OldEditProc = SetWindowLong(hEdit, GWL_WNDPROC,(LONG)(WNDPROC)NewEditProc);
PostMessage(hEdit, WM_USER, (WPARAM) hFont, FALSE);
in NewEditProc :
case WM_USER:
{
TEXTMETRIC tm;
HDC hdc = GetDC(hWnd);
HFONT hFontOld = (HFONT)SelectObject(hdc, hFont);
GetTextMetrics(hdc, &tm);
int halfwidth = tm.tmMaxCharWidth / 2;
SelectObject(hdc, hFontOld);
ReleaseDC(hWnd, hdc);
}
break;