diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-12 13:10:30 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-12 13:10:30 -0400 |
| commit | 24a42d29a54a0e607daf4e15abe915b56620bfd7 (patch) | |
| tree | 289f6b556598bd3d0a98692a8919c69731f21e00 /redo/container_windows.c | |
| parent | 9ecd124500298335874d9126fc79ef999dbda69a (diff) | |
Improved dialog base units calculations on Windows.
Diffstat (limited to 'redo/container_windows.c')
| -rw-r--r-- | redo/container_windows.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/redo/container_windows.c b/redo/container_windows.c index 5f71fe2..e393861 100644 --- a/redo/container_windows.c +++ b/redo/container_windows.c @@ -88,6 +88,7 @@ void calculateBaseUnits(HWND hwnd, int *baseX, int *baseY, LONG *internalLeading HDC dc; HFONT prevFont; TEXTMETRICW tm; + SIZE size; dc = GetDC(hwnd); if (dc == NULL) @@ -97,7 +98,9 @@ void calculateBaseUnits(HWND hwnd, int *baseX, int *baseY, LONG *internalLeading xpanic("error loading control font into device context for preferred size calculation", GetLastError()); if (GetTextMetricsW(dc, &tm) == 0) xpanic("error getting text metrics for preferred size calculations", GetLastError()); - *baseX = (int) tm.tmAveCharWidth; /* TODO not optimal; third reference below has better way */ + if (GetTextExtentPoint32W(dc, L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 52, &size) == 0) + xpanic("error getting text extent point for preferred size calculations", GetLastError()); + *baseX = (int) ((size.cx / 26 + 1) / 2); *baseY = (int) tm.tmHeight; *internalLeading = tm.tmInternalLeading; if (SelectObject(dc, prevFont) != controlFont) |
