summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-03-04 11:38:16 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-03-04 11:38:16 +0000
commiteabc40e7c9cc64ae9a24f05fa5ed553e0d181a63 (patch)
tree97d53de89119e7cd2ce749bc697c894ea158d05d
parente305b0a6143716dba6c11fd1a4c6d60e6ed27fd6 (diff)
fix for drawing subclassed windows
git-svn-id: http://svn.miranda-ng.org/main/trunk@3882 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--src/mir_core/subclass.cpp44
1 files changed, 21 insertions, 23 deletions
diff --git a/src/mir_core/subclass.cpp b/src/mir_core/subclass.cpp
index 6bb1eeb962..40fa3c6b95 100644
--- a/src/mir_core/subclass.cpp
+++ b/src/mir_core/subclass.cpp
@@ -38,7 +38,7 @@ static LRESULT CALLBACK MSubclassWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP
MSubclassData *p = arSubclass.find((MSubclassData*)&hwnd);
if (p != NULL) {
if (p->m_iHooks)
- return p->m_hooks[0](hwnd, uMsg, wParam, lParam);
+ return p->m_hooks[p->m_iHooks-1](hwnd, uMsg, wParam, lParam);
return p->m_origWndProc(hwnd, uMsg, wParam, lParam);
}
@@ -96,30 +96,28 @@ MIR_CORE_DLL(LRESULT) mir_callNextSubclass(HWND hWnd, WNDPROC wndProc, UINT uMsg
{
MSubclassData *p = arSubclass.find((MSubclassData*)&hWnd);
if (p) {
- int i;
- for (i=0; i < p->m_iHooks; i++)
- if (p->m_hooks[i] == wndProc)
- break;
+ for (int i=p->m_iHooks-1; i >= 0; i--) {
+ if (p->m_hooks[i] == wndProc) {
+ // next hook exitst, call it
+ if (i != 0)
+ return p->m_hooks[i-1](hWnd, uMsg, wParam, lParam);
+
+ // last hook called, ping the default window procedure
+ if (uMsg == WM_DESTROY) {
+ WNDPROC saveProc = p->m_origWndProc;
+ arSubclass.remove(p);
+ delete p;
+
+ SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)saveProc);
+ return CallWindowProc(saveProc, hWnd, uMsg, wParam, lParam);
+ }
+
+ return CallWindowProc(p->m_origWndProc, hWnd, uMsg, wParam, lParam);
+ }
+ }
// invalid / closed hook
- if (i == p->m_iHooks)
- return 0;
-
- // next hook exitst, call it
- if (i != p->m_iHooks-1)
- return p->m_hooks[i+1](hWnd, uMsg, wParam, lParam);
-
- // last hook called, ping the default window procedure
- if (uMsg == WM_DESTROY) {
- WNDPROC saveProc = p->m_origWndProc;
- arSubclass.remove(p);
- delete p;
-
- SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)saveProc);
- return CallWindowProc(saveProc, hWnd, uMsg, wParam, lParam);
- }
-
- return CallWindowProc(p->m_origWndProc, hWnd, uMsg, wParam, lParam);
+ return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}