Keep in memory getSizing information with hMessageFont on windows

This commit is contained in:
Francesco ABBATE 2018-07-02 12:49:40 +02:00
parent cda991b7e2
commit 678609581c
3 changed files with 12 additions and 1 deletions

View File

@ -6,6 +6,7 @@ HINSTANCE hInstance;
int nCmdShow;
HFONT hMessageFont;
uiWindowsSizing messageFontSizing;
// LONGTERM needed?
HBRUSH hollowBrush;
@ -95,6 +96,11 @@ const char *uiInit(uiInitOptions *o)
if (hMessageFont == NULL)
return ieLastErr("loading default messagebox font; this is the default UI font");
// Initialize to zero to means that the values are unknown.
messageFontSizing.BaseX = 0;
messageFontSizing.BaseY = 0;
messageFontSizing.InternalLeading = 0;
if (initContainer(hDefaultIcon, hDefaultCursor) == 0)
return ieLastErr("initializing uiWindowsMakeContainer() window class");

View File

@ -34,7 +34,10 @@ void getSizing(HWND hwnd, uiWindowsSizing *sizing, HFONT font)
void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing)
{
return getSizing(hwnd, sizing, hMessageFont);
if (messageFontSizing.BaseX == 0) {
getSizing(hwnd, &messageFontSizing, hMessageFont);
}
*sizing = messageFontSizing;
}
#define dlgUnitsToX(dlg, baseX) MulDiv((dlg), (baseX), 4)

View File

@ -86,6 +86,8 @@ extern void setWindowText(HWND hwnd, WCHAR *wtext);
extern HINSTANCE hInstance;
extern int nCmdShow;
extern HFONT hMessageFont;
// keep memory of text metric values given in getSizing in sizing.cpp
extern uiWindowsSizing messageFontSizing;
extern HBRUSH hollowBrush;
extern uiInitOptions options;