diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-07 03:39:47 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-07 03:39:47 -0400 |
| commit | 54dd1f40017dc31cc5f302cf67cd15ecb562daa1 (patch) | |
| tree | 10da4eb50f3dd26dfd4e1f01f1c9aa4bc1067c68 /new/util_windows.c | |
| parent | c4045909606cbc7733846ef7ca482d27bddd2e30 (diff) | |
Hooked up resizing. Now to make a control that uses this.
Diffstat (limited to 'new/util_windows.c')
| -rw-r--r-- | new/util_windows.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/new/util_windows.c b/new/util_windows.c index 6292967..39bffc3 100644 --- a/new/util_windows.c +++ b/new/util_windows.c @@ -70,3 +70,32 @@ BOOL sharedWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT * */ } return FALSE; } + +// TODO add function names +void resize(uiControl *control, HWND parent, RECT r) +{ + uiSizing d; + HDC dc; + HFONT prevFont; + TEXTMETRICW tm; + SIZE size; + + dc = GetDC(parent); + if (dc == NULL) + logLastError("error getting DC for preferred size calculations"); + prevFont = (HFONT) SelectObject(dc, hMessageFont); + if (prevFont == NULL) + logLastError("error loading control font into device context for preferred size calculation"); + if (GetTextMetricsW(dc, &tm) == 0) + logLastError("error getting text metrics for preferred size calculations"); + if (GetTextExtentPoint32W(dc, L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 52, &size) == 0) + logLastError("error getting text extent point for preferred size calculations"); + d.baseX = (int) ((size.cx / 26 + 1) / 2); + d.baseY = (int) tm.tmHeight; + d.internalLeading = tm.tmInternalLeading; + if (SelectObject(dc, prevFont) != hMessageFont) + logLastError("error restoring previous font into device context after preferred size calculations"); + if (ReleaseDC(parent, dc) == 0) + logLastError("error releasing DC for preferred size calculations"); + (*(control->resize))(control, r.left, r.top, r.right - r.left, r.bottom - r.top, &d); +} |
