From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/user32/listbox.c | 20 ++++++++++++++++---- dlls/user32/tests/class.c | 4 ++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c index 7989c2d350c..c569b296842 100644 --- a/dlls/user32/listbox.c +++ b/dlls/user32/listbox.c @@ -123,6 +123,16 @@ static TIMER_DIRECTION LISTBOX_Timer = LB_TIMER_NONE; static LRESULT LISTBOX_GetItemRect( const LB_DESCR *descr, INT index, RECT *rect ); +static LB_DESCR *get_control_state( HWND hwnd ) +{ + return (LB_DESCR *)NtUserGetPrivateData( hwnd, 0, sizeof(LB_DESCR *) ); +} + +static LB_DESCR *set_control_state( HWND hwnd, LB_DESCR *state ) +{ + return (LB_DESCR *)NtUserSetPrivateData( hwnd, 0, sizeof(LB_DESCR *), (LONG_PTR)state ); +} + /* For listboxes without LBS_NODATA, an array of LB_ITEMDATA is allocated to store the states of each item into descr->u.items. @@ -2601,7 +2611,7 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) descr->owner = lphc->self; } - SetWindowLongPtrW( descr->self, 0, (LONG_PTR)descr ); + set_control_state( descr->self, descr ); /* if (wnd->dwExStyle & WS_EX_NOPARENTNOTIFY) descr->style &= ~LBS_NOTIFY; */ @@ -2646,7 +2656,7 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) static BOOL LISTBOX_Destroy( LB_DESCR *descr ) { LISTBOX_ResetContent( descr ); - SetWindowLongPtrW( descr->self, 0, 0 ); + set_control_state( descr->self, NULL ); HeapFree( GetProcessHeap(), 0, descr ); return TRUE; } @@ -2657,10 +2667,12 @@ static BOOL LISTBOX_Destroy( LB_DESCR *descr ) */ LRESULT ListBoxWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode ) { - LB_DESCR *descr = (LB_DESCR *)GetWindowLongPtrW( hwnd, 0 ); + LB_DESCR *descr = get_control_state( hwnd ); HEADCOMBO *lphc = NULL; LRESULT ret; + if (msg == WM_CREATE || msg == WM_NCCREATE) NtUserSetWindowFNID( hwnd, MAKE_FNID(NTUSER_WNDPROC_LISTBOX) ); + if (!descr) { if (!IsWindow(hwnd)) return 0; @@ -2670,7 +2682,7 @@ LRESULT ListBoxWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam CREATESTRUCTW *lpcs = (CREATESTRUCTW *)lParam; if (lpcs->style & LBS_COMBOBOX) lphc = lpcs->lpCreateParams; if (!LISTBOX_Create( hwnd, lphc )) return -1; - TRACE("creating hwnd %p descr %p\n", hwnd, (void *)GetWindowLongPtrW( hwnd, 0 ) ); + TRACE("creating hwnd %p descr %p\n", hwnd, get_control_state( hwnd ) ); return 0; } /* Ignore all other messages before we get a WM_CREATE */ diff --git a/dlls/user32/tests/class.c b/dlls/user32/tests/class.c index 47f7b2e722a..c7a99cc80d4 100644 --- a/dlls/user32/tests/class.c +++ b/dlls/user32/tests/class.c @@ -2523,10 +2523,10 @@ static const struct real_class_test class_tests[] = { "Button", "Button", FALSE, FALSE, TRUE, TRUE, FALSE }, { "ComboBox", "ComboBox", FALSE, TRUE, TRUE, TRUE, FALSE }, { "Edit", "Edit", FALSE, FALSE, TRUE, TRUE, FALSE }, - { "ListBox", "ListBox", FALSE, TRUE, TRUE, TRUE, TRUE }, + { "ListBox", "ListBox", FALSE, TRUE, TRUE, TRUE, FALSE }, { "ScrollBar", "ScrollBar", FALSE, TRUE, FALSE, TRUE, TRUE }, { "Static", "Static", TRUE, TRUE, TRUE, TRUE, FALSE }, - { "ComboLBox", "ListBox", FALSE, TRUE, TRUE, TRUE, TRUE }, + { "ComboLBox", "ListBox", FALSE, TRUE, TRUE, TRUE, FALSE }, { "MDIClient", "MDIClient", TRUE, TRUE, TRUE, TRUE, TRUE }, { "#32768", "#32768", FALSE, FALSE, TRUE, TRUE, TRUE }, { "#32770", "#32770", TRUE, TRUE, TRUE, TRUE, TRUE }, -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11023