From cd7552ae1ce7f6c92d03b7d0a83fe4aec073aeff Mon Sep 17 00:00:00 2001 From: Jonas Kümmerlin Date: Sat, 5 Jan 2019 12:19:03 +0100 Subject: make combobox look better on NT 3.51 still broken on Win32s for whatever reason --- alf/alfcombobox.cpp | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/alf/alfcombobox.cpp b/alf/alfcombobox.cpp index 8afdace..a6e846f 100644 --- a/alf/alfcombobox.cpp +++ b/alf/alfcombobox.cpp @@ -24,6 +24,13 @@ ALF__ComboItemHeight(HWND hwnd) SelectFont(hDc, oldfont); } + if (LOBYTE(LOWORD(GetVersion())) < 4) { + // baseline alignment for NT3.x/Win32s + // ideally, this would only be applied for the ODS_COMOBOXEDIT state, + // but that state is not sent pre-Win95. + height += 2; + } + ReleaseDC(hwnd, hDc); return height; } @@ -42,9 +49,7 @@ ALF__ComboWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (uMsg == WM_CREATE) { ALFComboCreateParams *params = (ALFComboCreateParams*)((CREATESTRUCT*)lParam)->lpCreateParams; - DWORD comboStyle = params->comboStyle; - if (LOBYTE(LOWORD(GetVersion())) >= 4) - comboStyle |= CBS_OWNERDRAWFIXED | CBS_HASSTRINGS; + DWORD comboStyle = params->comboStyle | CBS_OWNERDRAWFIXED | CBS_HASSTRINGS; HWND hwndCombo = CreateWindowEx(0, TEXT("COMBOBOX"), @@ -186,6 +191,13 @@ ALF__ComboWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) LONG y = lpdis->rcItem.top; LONG x = lpdis->rcItem.left; + if (LOBYTE(LOWORD(GetVersion())) < 4) { + // baseline alignment for NT3.x/Win32s + // ideally, this would only be applied for the ODS_COMOBOXEDIT state, + // but that state is not sent pre-Win95. + y += 1; + } + // add left padding like an edit control TEXTMETRIC tm; ZeroMemory(&tm, sizeof(tm)); @@ -233,13 +245,21 @@ ALF__ComboWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) SetWindowPos(hwndChild, NULL, 0, 1, pos->cx, 200, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCOPYBITS); SendMessage(hwndChild, CB_SETEDITSEL, 0, (LPARAM)sel); + DWORD heightOffset = 0; if (LOBYTE(LOWORD(GetVersion())) >= 4) { - SendMessage(hwndChild, CB_SETITEMHEIGHT, (WPARAM)-1, pos->cy - 8); - - int h = ALF__ComboItemHeight(hwnd); - if (h) - SendMessage(hwndChild, CB_SETITEMHEIGHT, (WPARAM)0, h); + heightOffset = - 2*app->compatFn->GetSystemMetricsForDpi( + SM_CYEDGE, ALF_CentipointsToPixels(GetParent(hwnd), 7200)) + - 4; + } else { + heightOffset = -2; } + + SendMessage(hwndChild, CB_SETITEMHEIGHT, (WPARAM)-1, pos->cy + heightOffset); + + int h = ALF__ComboItemHeight(hwnd); + if (h) + SendMessage(hwndChild, CB_SETITEMHEIGHT, (WPARAM)0, h); + } } -- cgit v1.2.3