summaryrefslogtreecommitdiff
path: root/alf
diff options
context:
space:
mode:
authorJonas Kümmerlin <jonas@kuemmerlin.eu>2019-01-05 12:19:03 +0100
committerJonas Kümmerlin <jonas@kuemmerlin.eu>2019-01-05 12:19:03 +0100
commitcd7552ae1ce7f6c92d03b7d0a83fe4aec073aeff (patch)
tree1379164678eae7c790fee455fecd76c7b4a5b4fb /alf
parent3271b043f89966a8c33bdd2de4e93a4428c0488d (diff)
make combobox look better on NT 3.51
still broken on Win32s for whatever reason
Diffstat (limited to 'alf')
-rw-r--r--alf/alfcombobox.cpp36
1 files 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);
+
}
}