[PATCH v2 3/4] shell32/autocomplete: Prevent the listbox from going off screen when dropped
Gabriel Ivăncescu
gabrielopcode at gmail.com
Tue May 28 07:21:42 CDT 2019
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
dlls/shell32/autocomplete.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c
index 24aa895..446642a 100644
--- a/dlls/shell32/autocomplete.c
+++ b/dlls/shell32/autocomplete.c
@@ -357,7 +357,10 @@ static void hide_listbox(IAutoCompleteImpl *ac, HWND hwnd, BOOL reset)
static void show_listbox(IAutoCompleteImpl *ac)
{
RECT r;
- UINT cnt, width, height;
+ LONG top;
+ HMONITOR hmon;
+ MONITORINFO info;
+ UINT cnt, width, height, grip_sz;
GetWindowRect(ac->hwndEdit, &r);
@@ -374,8 +377,24 @@ static void show_listbox(IAutoCompleteImpl *ac)
height = SendMessageW(ac->hwndListBox, LB_GETITEMHEIGHT, 0, 0) * min(cnt + 1, 7);
width = r.right - r.left;
}
+ top = r.bottom + 1;
- SetWindowPos(ac->hwndListBoxOwner, HWND_TOP, r.left, r.bottom + 1, width, height,
+ /* Don't drop off-screen when showing the listbox */
+ info.cbSize = sizeof(info);
+ hmon = MonitorFromRect(&r, MONITOR_DEFAULTTONEAREST);
+ if (GetMonitorInfoW(hmon, &info))
+ {
+ /* Permit the width to go off-screen if the editbox also does, though */
+ LONG max_w = max(info.rcMonitor.right, r.right) - r.left;
+ LONG max_h = info.rcMonitor.bottom - top;
+ width = min(width, max_w);
+ height = min(height, max_h);
+ }
+ grip_sz = GetSystemMetrics(SM_CXVSCROLL);
+ width = max(width, grip_sz);
+ height = max(height, grip_sz);
+
+ SetWindowPos(ac->hwndListBoxOwner, HWND_TOP, r.left, top, width, height,
SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_DEFERERASE);
/* Update the grip here (as we skip it during message processing), due
--
2.21.0
More information about the wine-devel
mailing list