Fix subclassing to support nested messages.
This commit is contained in:
parent
adc7a91152
commit
cf4c3348bb
@ -114,6 +114,7 @@ extern void TREEVIEW_Unregister(void);
|
|||||||
extern void UPDOWN_Register(void);
|
extern void UPDOWN_Register(void);
|
||||||
extern void UPDOWN_Unregister(void);
|
extern void UPDOWN_Unregister(void);
|
||||||
|
|
||||||
|
static LRESULT WINAPI SubclassWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
LPSTR COMCTL32_aSubclass = NULL;
|
LPSTR COMCTL32_aSubclass = NULL;
|
||||||
HMODULE COMCTL32_hModule = 0;
|
HMODULE COMCTL32_hModule = 0;
|
||||||
@ -1108,10 +1109,10 @@ BOOL WINAPI SetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass,
|
|||||||
/* set window procedure to our own and save the current one */
|
/* set window procedure to our own and save the current one */
|
||||||
if (IsWindowUnicode (hWnd))
|
if (IsWindowUnicode (hWnd))
|
||||||
stack->origproc = (WNDPROC)SetWindowLongW (hWnd, GWL_WNDPROC,
|
stack->origproc = (WNDPROC)SetWindowLongW (hWnd, GWL_WNDPROC,
|
||||||
(LONG)DefSubclassProc);
|
(LONG)SubclassWndProc);
|
||||||
else
|
else
|
||||||
stack->origproc = (WNDPROC)SetWindowLongA (hWnd, GWL_WNDPROC,
|
stack->origproc = (WNDPROC)SetWindowLongA (hWnd, GWL_WNDPROC,
|
||||||
(LONG)DefSubclassProc);
|
(LONG)SubclassWndProc);
|
||||||
} else {
|
} else {
|
||||||
WNDPROC current;
|
WNDPROC current;
|
||||||
if (IsWindowUnicode (hWnd))
|
if (IsWindowUnicode (hWnd))
|
||||||
@ -1119,7 +1120,7 @@ BOOL WINAPI SetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass,
|
|||||||
else
|
else
|
||||||
current = (WNDPROC)GetWindowLongA (hWnd, GWL_WNDPROC);
|
current = (WNDPROC)GetWindowLongA (hWnd, GWL_WNDPROC);
|
||||||
|
|
||||||
if (current != DefSubclassProc) {
|
if (current != SubclassWndProc) {
|
||||||
ERR ("Application has subclassed with our procedure, then manually, then with us again. The current implementation can't handle this.\n");
|
ERR ("Application has subclassed with our procedure, then manually, then with us again. The current implementation can't handle this.\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1262,6 +1263,33 @@ BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR u
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* SubclassWndProc (internal)
|
||||||
|
*
|
||||||
|
* Window procedure for all subclassed windows.
|
||||||
|
* Saves the current subclassing stack position to support nested messages
|
||||||
|
*/
|
||||||
|
|
||||||
|
static LRESULT WINAPI SubclassWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
LPSUBCLASS_INFO stack;
|
||||||
|
int stackpos;
|
||||||
|
LRESULT ret;
|
||||||
|
|
||||||
|
/* retrieve our little stack from the Properties */
|
||||||
|
stack = (LPSUBCLASS_INFO)GetPropA (hWnd, COMCTL32_aSubclass);
|
||||||
|
if (!stack) {
|
||||||
|
ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
stackpos = stack->stackpos;
|
||||||
|
stack->stackpos = stack->stacknum;
|
||||||
|
ret = DefSubclassProc(hWnd,uMsg,wParam,lParam);
|
||||||
|
stack->stackpos = stackpos;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* DefSubclassProc [COMCTL32.413]
|
* DefSubclassProc [COMCTL32.413]
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user