diff options
author | George Hazan <george.hazan@gmail.com> | 2015-05-17 22:02:12 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-05-17 22:02:12 +0000 |
commit | ebec815cdd684a3826ff81d66481d0da206de7ba (patch) | |
tree | bd20bf73131a0a4aae8eb5004278662a0e031d47 /src | |
parent | 0fc666ba4c6939b51e25d0175928f9b0eb64a938 (diff) |
automatic unsubclassing transferred from WM_DESTROY to WM_NCDESTROY
git-svn-id: http://svn.miranda-ng.org/main/trunk@13667 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_core/src/subclass.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/mir_core/src/subclass.cpp b/src/mir_core/src/subclass.cpp index 0a29634a67..ac7c419e39 100644 --- a/src/mir_core/src/subclass.cpp +++ b/src/mir_core/src/subclass.cpp @@ -48,7 +48,8 @@ static LRESULT CALLBACK MSubclassWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
-/* This is for wine: it return wrong WNDPROC for edit control in some cases. */
+/////////////////////////////////////////////////////////////////////////////////////////
+// This is for wine: it return wrong WNDPROC for edit control in some cases.
#ifdef WIN64
#define STD_WND_PROC_ADDR_MASK 0x7FFF00000
#else
@@ -63,14 +64,12 @@ MIR_CORE_DLL(void) mir_subclassWindow(HWND hWnd, WNDPROC wndProc) p->m_hWnd = hWnd;
p->m_origWndProc = (WNDPROC)SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)MSubclassWndProc);
if (((SIZE_T)p->m_origWndProc & STD_WND_PROC_ADDR_MASK) == STD_WND_PROC_ADDR_MASK) { /* XXX: fix me. Wine fix. */
- //MessageBox(NULL, _T("mir_subclassWindow"), NULL, 0);
p->m_origWndProc = (WNDPROC)GetClassLongPtr(hWnd, GCLP_WNDPROC);
- if (((SIZE_T)p->m_origWndProc & 0x7FFF0000) == 0x7FFF0000) { /* Delay crash. */
+ if (((SIZE_T)p->m_origWndProc & 0x7FFF0000) == 0x7FFF0000) /* Delay crash. */
p->m_origWndProc = DefWindowProc;
- }
}
p->m_iHooks = 0;
- p->m_hooks = (WNDPROC*)malloc( sizeof(WNDPROC));
+ p->m_hooks = (WNDPROC*)malloc(sizeof(WNDPROC));
arSubclass.insert(p);
}
else {
@@ -92,7 +91,7 @@ MIR_CORE_DLL(void) mir_subclassWindowFull(HWND hWnd, WNDPROC wndProc, WNDPROC ol p->m_hWnd = hWnd;
p->m_origWndProc = oldWndProc;
p->m_iHooks = 0;
- p->m_hooks = (WNDPROC*)malloc( sizeof(WNDPROC));
+ p->m_hooks = (WNDPROC*)malloc(sizeof(WNDPROC));
arSubclass.insert(p);
SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)MSubclassWndProc);
@@ -115,7 +114,7 @@ static void removeHook(MSubclassData *p, int idx) WNDPROC saveProc = p->m_hooks[idx];
// untie hook from a window to prevent calling mir_callNextSubclass from saveProc
- for (int i=idx+1; i < p->m_iHooks; i++)
+ for (int i = idx + 1; i < p->m_iHooks; i++)
p->m_hooks[i-1] = p->m_hooks[i];
p->m_iHooks--;
}
@@ -126,7 +125,7 @@ MIR_CORE_DLL(void) mir_unsubclassWindow(HWND hWnd, WNDPROC wndProc) if (p == NULL)
return;
- for (int i=0; i < p->m_iHooks; i++) {
+ for (int i = 0; i < p->m_iHooks; i++) {
if (p->m_hooks[i] == wndProc) {
removeHook(p, i);
i--;
@@ -147,7 +146,7 @@ MIR_CORE_DLL(LRESULT) mir_callNextSubclass(HWND hWnd, WNDPROC wndProc, UINT uMsg if (p == NULL)
return DefWindowProc(hWnd, uMsg, wParam, lParam);
- for (int i=p->m_iHooks-1; i >= 0; i--) {
+ for (int i = p->m_iHooks - 1; i >= 0; i--) {
if (p->m_hooks[i] != wndProc)
continue;
@@ -156,7 +155,7 @@ MIR_CORE_DLL(LRESULT) mir_callNextSubclass(HWND hWnd, WNDPROC wndProc, UINT uMsg return p->m_hooks[i-1](hWnd, uMsg, wParam, lParam);
// last hook called, ping the default window procedure
- if (uMsg != WM_DESTROY)
+ if (uMsg != WM_NCDESTROY)
return p->m_origWndProc(hWnd, uMsg, wParam, lParam);
WNDPROC saveProc = p->m_origWndProc;
@@ -175,10 +174,10 @@ MIR_CORE_DLL(LRESULT) mir_callNextSubclass(HWND hWnd, WNDPROC wndProc, UINT uMsg MIR_CORE_DLL(void) KillModuleSubclassing(HMODULE hInst)
{
- for (int i=arSubclass.getCount()-1; i >= 0; i--) {
+ for (int i = arSubclass.getCount() - 1; i >= 0; i--) {
MSubclassData *p = arSubclass[i];
- for (int j=0; j < p->m_iHooks; j++) {
- if ( GetInstByAddress(p->m_hooks[j]) == hInst) {
+ for (int j = 0; j < p->m_iHooks; j++) {
+ if (GetInstByAddress(p->m_hooks[j]) == hInst) {
removeHook(p, j);
j--;
}
|