diff --git a/windows/colordialog.cpp b/windows/colordialog.cpp index 159593e0..a8beca30 100644 --- a/windows/colordialog.cpp +++ b/windows/colordialog.cpp @@ -932,8 +932,7 @@ static void fixupControlPositions(struct colorDialog *c) labelA, c->editADouble, c->editAInt, NULL); - // TODO this uses the message font, not the dialog font - uiWindowsGetSizing(c->hwnd, &sizing); + getSizing(c->hwnd, &sizing, (HFONT) SendMessageW(labelH, WM_GETFONT, 0, 0)); offset = sizing.InternalLeading; moveWindowsUp(c, offset, labelH, labelS, labelV, diff --git a/windows/sizing.cpp b/windows/sizing.cpp index a0abdb46..a6d25d6e 100644 --- a/windows/sizing.cpp +++ b/windows/sizing.cpp @@ -2,7 +2,7 @@ #include "uipriv_windows.hpp" // TODO rework the error handling -void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing) +void getSizing(HWND hwnd, uiWindowsSizing *sizing, HFONT font) { HDC dc; HFONT prevfont; @@ -12,7 +12,7 @@ void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing) dc = GetDC(hwnd); if (dc == NULL) logLastError(L"error getting DC"); - prevfont = (HFONT) SelectObject(dc, hMessageFont); + prevfont = (HFONT) SelectObject(dc, font); if (prevfont == NULL) logLastError(L"error loading control font into device context"); @@ -26,12 +26,17 @@ void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing) sizing->BaseY = (int) tm.tmHeight; sizing->InternalLeading = tm.tmInternalLeading; - if (SelectObject(dc, prevfont) != hMessageFont) + if (SelectObject(dc, prevfont) != font) logLastError(L"error restoring previous font into device context"); if (ReleaseDC(hwnd, dc) == 0) logLastError(L"error releasing DC"); } +void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing) +{ + return getSizing(hwnd, sizing, hMessageFont); +} + #define dlgUnitsToX(dlg, baseX) MulDiv((dlg), (baseX), 4) #define dlgUnitsToY(dlg, baseY) MulDiv((dlg), (baseY), 8) diff --git a/windows/uipriv_windows.hpp b/windows/uipriv_windows.hpp index d1380af3..dcd31617 100644 --- a/windows/uipriv_windows.hpp +++ b/windows/uipriv_windows.hpp @@ -137,6 +137,9 @@ struct colorDialogRGBA { }; extern BOOL showColorDialog(HWND parent, struct colorDialogRGBA *c); +// sizing.cpp +extern void getSizing(HWND hwnd, uiWindowsSizing *sizing, HFONT font); + diff --git a/windows/window.cpp b/windows/window.cpp index f9806c72..42475b6d 100644 --- a/windows/window.cpp +++ b/windows/window.cpp @@ -185,7 +185,6 @@ static void uiWindowShow(uiControl *c) w->visible = 1; // just in case the window's minimum size wasn't recalculated already - // TODO is it needed? ensureMinimumWindowSize(w); if (w->shownOnce) { ShowWindow(w->hwnd, SW_SHOW);