I'm curios as to why this
Code:
void initialize_font(HFONT hf, HWND hwnd) {
HDC hdc;
TEXTMETRIC tm;
hdc = GetDC(hwnd);
hf = CreateFont(20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Times New Roman");
SelectObject(hdc, hf);
GetTextMetrics(hdc, &tm);
printf("Char Height is %d Average Char Width is %d\n", tm.tmHeight, tm.tmAveCharWidth);
}
results in a different average character width to this
Code:
void initialize_font(HFONT hf, HWND hwnd) {
HDC hdc, hdc2;
TEXTMETRIC tm;
hdc = GetDC(hwnd);
hdc2 = GetDC(hwnd);
hf = CreateFont(20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Times New Roman");
SelectObject(hdc, hf);
GetTextMetrics(hdc2, &tm);
printf("Char Height is %d Average Char Width is %d\n", tm.tmHeight, tm.tmAveCharWidth);
}
I understand that each call to GetDC() will result in a different handle to the device context getting returned but shouldn't the handles both be pointing to the same client area and so have the same text metrics?