From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/user32/edit.c | 20 ++++++++++++++++---- dlls/user32/tests/class.c | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c index cad14800995..eceefbdce8c 100644 --- a/dlls/user32/edit.c +++ b/dlls/user32/edit.c @@ -147,6 +147,16 @@ static inline BOOL notify_parent(const EDITSTATE *es, INT code) return IsWindow(hwnd); } +static EDITSTATE *get_control_state( HWND hwnd ) +{ + return (EDITSTATE *)NtUserGetPrivateData( hwnd, 0, sizeof(EDITSTATE *) ); +} + +static EDITSTATE *set_control_state( HWND hwnd, EDITSTATE *state ) +{ + return (EDITSTATE *)NtUserSetPrivateData( hwnd, 0, sizeof(EDITSTATE *), (LONG_PTR)state ); +} + static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap); /********************************************************************* @@ -4390,7 +4400,7 @@ static LRESULT EDIT_WM_NCCreate(HWND hwnd, LPCREATESTRUCTW lpcs, BOOL unicode) if (!(es = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*es)))) return FALSE; - SetWindowLongPtrW( hwnd, 0, (LONG_PTR)es ); + set_control_state( hwnd, es ); /* * Note: since the EDITSTATE has not been fully initialized yet, @@ -4479,7 +4489,7 @@ static LRESULT EDIT_WM_NCCreate(HWND hwnd, LPCREATESTRUCTW lpcs, BOOL unicode) return TRUE; cleanup: - SetWindowLongPtrW(es->hwndSelf, 0, 0); + set_control_state( es->hwndSelf, NULL ); EDIT_InvalidateUniscribeData(es); HeapFree(GetProcessHeap(), 0, es->first_line_def); HeapFree(GetProcessHeap(), 0, es->undo_text); @@ -4565,7 +4575,7 @@ static LRESULT EDIT_WM_NCDestroy(EDITSTATE *es) pc = pp; } - SetWindowLongPtrW( es->hwndSelf, 0, 0 ); + set_control_state( es->hwndSelf, NULL ); HeapFree(GetProcessHeap(), 0, es->undo_text); HeapFree(GetProcessHeap(), 0, es); @@ -4590,12 +4600,14 @@ static inline LRESULT DefWindowProcT(HWND hwnd, UINT msg, WPARAM wParam, LPARAM */ LRESULT EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode ) { - EDITSTATE *es = (EDITSTATE *)GetWindowLongPtrW( hwnd, 0 ); + EDITSTATE *es = get_control_state( hwnd ); LRESULT result = 0; POINT pt; TRACE("hwnd=%p msg=%x (%s) wparam=%Ix lparam=%Ix\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), wParam, lParam); + if (msg == WM_NCCREATE) NtUserSetWindowFNID( hwnd, MAKE_FNID(NTUSER_WNDPROC_EDIT) ); + if (!es && msg != WM_NCCREATE) return DefWindowProcT(hwnd, msg, wParam, lParam, unicode); diff --git a/dlls/user32/tests/class.c b/dlls/user32/tests/class.c index 1021005802a..47f7b2e722a 100644 --- a/dlls/user32/tests/class.c +++ b/dlls/user32/tests/class.c @@ -2522,7 +2522,7 @@ 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, TRUE }, + { "Edit", "Edit", FALSE, FALSE, TRUE, TRUE, FALSE }, { "ListBox", "ListBox", FALSE, TRUE, TRUE, TRUE, TRUE }, { "ScrollBar", "ScrollBar", FALSE, TRUE, FALSE, TRUE, TRUE }, { "Static", "Static", TRUE, TRUE, TRUE, TRUE, FALSE }, -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11023