Commit 62c5d9f3 authored by Susan Farley's avatar Susan Farley Committed by Alexandre Julliard

SetBuddy no longer overwrites its superclass' WndProc property when

the buddy has already been subclassed, eliminating the infinite loop that resulted.
parent f2b77ccb
...@@ -426,6 +426,7 @@ static BOOL UPDOWN_SetBuddy (HWND hwnd, HWND hwndBud) ...@@ -426,6 +426,7 @@ static BOOL UPDOWN_SetBuddy (HWND hwnd, HWND hwndBud)
DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
RECT budRect; /* new coord for the buddy */ RECT budRect; /* new coord for the buddy */
int x,width; /* new x position and width for the up-down */ int x,width; /* new x position and width for the up-down */
WNDPROC baseWndProc, currWndProc;
/* Is it a valid bud? */ /* Is it a valid bud? */
if(!IsWindow(hwndBud)) if(!IsWindow(hwndBud))
...@@ -450,19 +451,17 @@ static BOOL UPDOWN_SetBuddy (HWND hwnd, HWND hwndBud) ...@@ -450,19 +451,17 @@ static BOOL UPDOWN_SetBuddy (HWND hwnd, HWND hwndBud)
when we reset the upDown ctrl buddy to another buddy because it is not when we reset the upDown ctrl buddy to another buddy because it is not
good to break the window proc chain. */ good to break the window proc chain. */
/* keep buddy supperclass wndproc in prop instead of in ptr struct currWndProc = (WNDPROC) GetWindowLongA(hwndBud, GWL_WNDPROC);
to prevent accessing freed memory */ if (currWndProc != UPDOWN_Buddy_SubclassProc)
SetPropA( {
hwndBud, // replace the buddy's WndProc with ours
BUDDY_SUPERCLASS_WNDPROC, baseWndProc = (WNDPROC)SetWindowLongA(hwndBud, GWL_WNDPROC,
(LONG)GetWindowLongA(hwndBud, GWL_WNDPROC) ); (LPARAM)UPDOWN_Buddy_SubclassProc);
// and save the base class' WndProc
/* Assign the buddy wndproc to local wndproc in order to override SetPropA(hwndBud, BUDDY_SUPERCLASS_WNDPROC, (HANDLE)baseWndProc);
keyboard's up and down arrow */ }
SetWindowLongA( // else
hwndBud, // its already been subclassed, don't overwrite BUDDY_SUPERCLASS_WNDPROC
GWL_WNDPROC,
(LONG)UPDOWN_Buddy_SubclassProc);
} }
/* do we need to do any adjustments? */ /* do we need to do any adjustments? */
...@@ -951,7 +950,7 @@ UPDOWN_Buddy_SubclassProc ( ...@@ -951,7 +950,7 @@ UPDOWN_Buddy_SubclassProc (
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
LONG superClassWndProc = GetPropA(hwnd, BUDDY_SUPERCLASS_WNDPROC); WNDPROC superClassWndProc = (WNDPROC)GetPropA(hwnd, BUDDY_SUPERCLASS_WNDPROC);
TRACE("hwnd=%04x, wndProc=%d, uMsg=%04x, wParam=%d, lParam=%d\n", TRACE("hwnd=%04x, wndProc=%d, uMsg=%04x, wParam=%d, lParam=%d\n",
hwnd, (INT)superClassWndProc, uMsg, wParam, (UINT)lParam); hwnd, (INT)superClassWndProc, uMsg, wParam, (UINT)lParam);
...@@ -980,12 +979,8 @@ UPDOWN_Buddy_SubclassProc ( ...@@ -980,12 +979,8 @@ UPDOWN_Buddy_SubclassProc (
} }
/* else Fall Through */ /* else Fall Through */
} }
default:
return CallWindowProcA( (WNDPROC)superClassWndProc, hwnd, uMsg, wParam, lParam);
} }
return CallWindowProcA( superClassWndProc, hwnd, uMsg, wParam, lParam);
return 0;
} }
/*********************************************************************** /***********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment