diff options
author | George Hazan <george.hazan@gmail.com> | 2013-03-04 07:23:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-03-04 07:23:42 +0000 |
commit | 66cb770a982a2502456d10d73838df2b7239fd89 (patch) | |
tree | fc419dde94a9be3ebe8f2266ff46feb90d2bcbec /src | |
parent | bc256df33a57e585367edffe33d3e58d53f82ce8 (diff) |
new subclassing functions applied to all plugins
git-svn-id: http://svn.miranda-ng.org/main/trunk@3880 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdaway/sendmsg.cpp | 10 | ||||
-rw-r--r-- | src/core/stdchat/src/richutil.cpp | 49 | ||||
-rw-r--r-- | src/core/stdchat/src/richutil.h | 1 | ||||
-rw-r--r-- | src/core/stdchat/src/window.cpp | 50 | ||||
-rw-r--r-- | src/core/stdfile/fileexistsdlg.cpp | 21 | ||||
-rw-r--r-- | src/core/stdfile/filesenddlg.cpp | 30 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 10 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.h | 1 | ||||
-rw-r--r-- | src/core/stdmsg/src/richutil.cpp | 63 | ||||
-rw-r--r-- | src/core/stdmsg/src/richutil.h | 1 | ||||
-rw-r--r-- | src/core/stdurl/urldialogs.cpp | 9 | ||||
-rw-r--r-- | src/mir_core/subclass.cpp | 79 | ||||
-rw-r--r-- | src/modules/clist/clcutils.cpp | 5 | ||||
-rw-r--r-- | src/modules/clist/genmenuopt.cpp | 7 | ||||
-rw-r--r-- | src/modules/database/profilemanager.cpp | 7 | ||||
-rw-r--r-- | src/modules/extraicons/options_ei.cpp | 6 | ||||
-rw-r--r-- | src/modules/options/options.cpp | 23 | ||||
-rw-r--r-- | src/modules/plugins/newplugins.cpp | 2 | ||||
-rw-r--r-- | src/modules/plugins/pluginopts.cpp | 6 | ||||
-rw-r--r-- | src/modules/protocols/protoopts.cpp | 15 | ||||
-rw-r--r-- | src/modules/skin/hotkey_opts.cpp | 14 | ||||
-rw-r--r-- | src/modules/skin/skin.h | 1 |
22 files changed, 194 insertions, 216 deletions
diff --git a/src/core/stdaway/sendmsg.cpp b/src/core/stdaway/sendmsg.cpp index e422707372..ac9c01d74d 100644 --- a/src/core/stdaway/sendmsg.cpp +++ b/src/core/stdaway/sendmsg.cpp @@ -140,12 +140,9 @@ static TCHAR* GetAwayMessage(int statusMode, char *szProto) return dbv.ptszVal;
}
-static WNDPROC OldMessageEditProc;
-
static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg)
- {
+ switch(msg) {
case WM_CHAR:
if (wParam == '\n' && GetKeyState(VK_CONTROL) & 0x8000)
{
@@ -181,7 +178,7 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar }
break;
}
- return CallWindowProc(OldMessageEditProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, MessageEditSubclassProc, msg, wParam, lParam);
}
void ChangeAllProtoMessages(char *szProto, int statusMode, TCHAR *msg)
@@ -235,7 +232,7 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa dat->szProto = newdat->szProto;
mir_free(newdat);
SendDlgItemMessage(hwndDlg, IDC_MSG, EM_LIMITTEXT, 1024, 0);
- OldMessageEditProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MSG), GWLP_WNDPROC, (LONG_PTR)MessageEditSubclassProc);
+ mir_subclassWindow( GetDlgItem(hwndDlg, IDC_MSG), MessageEditSubclassProc);
{
TCHAR str[256], format[128];
GetWindowText(hwndDlg, format, SIZEOF(format));
@@ -310,7 +307,6 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa KillTimer(hwndDlg, 1);
UnhookEvent(dat->hPreshutdown);
Window_FreeIcon_IcoLib(hwndDlg);
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MSG), GWLP_WNDPROC, (LONG_PTR)OldMessageEditProc);
mir_free(dat);
hwndStatusMsg = NULL;
break;
diff --git a/src/core/stdchat/src/richutil.cpp b/src/core/stdchat/src/richutil.cpp index a6b3d5971a..46c9e5c28e 100644 --- a/src/core/stdchat/src/richutil.cpp +++ b/src/core/stdchat/src/richutil.cpp @@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <windows.h>
#include <stdio.h>
#include <richedit.h>
+
+#include <m_core.h>
#include "richutil.h"
/*
@@ -176,29 +178,29 @@ int RichUtil_SubClass(HWND hwndEdit) { slist = rlist_append(slist, ru);
LeaveCriticalSection(&csRich);
SetWindowLongPtr(ru->hwnd, GWLP_USERDATA, (LONG_PTR)ru); // Ugly hack
- ru->origProc = (WNDPROC)SetWindowLongPtr(ru->hwnd, GWLP_WNDPROC, (LONG_PTR)&RichUtil_Proc);
+ mir_subclassWindow(ru->hwnd, RichUtil_Proc);
RichUtil_ClearUglyBorder(ru);
return 1;
}
return 0;
}
-static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
+static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
TRichUtil *ru;
-
+
EnterCriticalSection(&csRich);
ru = rlist_find(slist, hwnd);
LeaveCriticalSection(&csRich);
switch(msg) {
- case WM_THEMECHANGED:
- case WM_STYLECHANGED:
- {
- RichUtil_ClearUglyBorder(ru);
- break;
- }
- case WM_NCPAINT:
+ case WM_THEMECHANGED:
+ case WM_STYLECHANGED:
+ RichUtil_ClearUglyBorder(ru);
+ break;
+
+ case WM_NCPAINT:
{
- LRESULT ret = CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
+ LRESULT ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
if (ru->hasUglyBorder&&MyIsThemeActive()) {
HANDLE hTheme = MyOpenThemeData(ru->hwnd, L"EDIT");
@@ -232,11 +234,11 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM }
return ret;
}
- case WM_NCCALCSIZE:
+ case WM_NCCALCSIZE:
{
- LRESULT ret = CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
+ LRESULT ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS*)lParam;
-
+
if (ru->hasUglyBorder&&MyIsThemeActive()) {
HANDLE hTheme = MyOpenThemeData(hwnd, L"EDIT");
@@ -261,17 +263,14 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM }
return ret;
}
- case WM_ENABLE:
- RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE|RDW_NOCHILDREN|RDW_UPDATENOW|RDW_FRAME);
- break;
- case WM_DESTROY:
- {
- LRESULT ret = CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
- if(IsWindow(hwnd)) {
- if ((WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC) == &RichUtil_Proc)
- SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)ru->origProc);
- }
+ case WM_ENABLE:
+ RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE|RDW_NOCHILDREN|RDW_UPDATENOW|RDW_FRAME);
+ break;
+
+ case WM_DESTROY:
+ {
+ LRESULT ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
EnterCriticalSection(&csRich);
slist = rlist_remove(slist, ru);
LeaveCriticalSection(&csRich);
@@ -279,7 +278,7 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return ret;
}
}
- return CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
}
static VOID RichUtil_ClearUglyBorder(TRichUtil *ru) {
diff --git a/src/core/stdchat/src/richutil.h b/src/core/stdchat/src/richutil.h index 9a69f8f809..97d85aeddf 100644 --- a/src/core/stdchat/src/richutil.h +++ b/src/core/stdchat/src/richutil.h @@ -45,7 +45,6 @@ typedef struct { HWND hwnd;
RECT rect;
int hasUglyBorder;
- WNDPROC origProc;
} TRichUtil;
void RichUtil_Load();
diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp index 59fc8e830d..0627dfbea1 100644 --- a/src/core/stdchat/src/window.cpp +++ b/src/core/stdchat/src/window.cpp @@ -34,12 +34,6 @@ extern BOOL SmileyAddInstalled; extern TABLIST * g_TabList;
extern HIMAGELIST hIconsList;
-static WNDPROC OldSplitterProc;
-static WNDPROC OldMessageProc;
-static WNDPROC OldNicklistProc;
-static WNDPROC OldTabProc;
-static WNDPROC OldFilterButtonProc;
-static WNDPROC OldLogProc;
static HKL hkl = NULL;
typedef struct
@@ -48,7 +42,6 @@ typedef struct TCHAR szTabSave[20];
} MESSAGESUBDATA;
-
static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg) {
@@ -78,7 +71,7 @@ static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LP PostMessage(GetParent(hwnd),WM_SIZE, 0, 0);
return 0;
}
- return CallWindowProc(OldSplitterProc,hwnd,msg,wParam,lParam);
+ return mir_callNextSubclass(hwnd, SplitterSubclassProc, msg, wParam, lParam);
}
static void InitButtons(HWND hwndDlg, SESSION_INFO* si)
@@ -737,7 +730,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return 0;
}
- return CallWindowProc(OldMessageProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, MessageSubclassProc, msg, wParam, lParam);
}
static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
@@ -830,7 +823,7 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, L break;
}
- return CallWindowProc(OldFilterButtonProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, ButtonSubclassProc, msg, wParam, lParam);
}
static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -873,7 +866,7 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR break;
}
- return CallWindowProc(OldLogProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, LogSubclassProc, msg, wParam, lParam);
}
static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -987,7 +980,7 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR break;
}
- return CallWindowProc(OldTabProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, TabSubclassProc, msg, wParam, lParam);
}
static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -1103,13 +1096,11 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, POINT p;
GetCursorPos(&p);
SendMessage( parentdat->hwndTooltip,TTM_TRACKPOSITION,0,(LPARAM)MAKELPARAM(p.x + 15,p.y + 15));
-// SendMessage( parentdat->hwndTooltip, TTM_ACTIVATE, TRUE, 0 );
} }
break;
-
}
- return CallWindowProc(OldNicklistProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, NicklistSubclassProc, msg, wParam, lParam);
}
static int RestoreWindowPosition(HWND hwnd, HANDLE hContact, char * szModule, char * szNamePrefix, UINT showCmd)
@@ -1182,15 +1173,15 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, IID_IAccPropServices, (LPVOID *)si->pAccPropServicesForNickList);
TranslateDialogDefault(hwndDlg);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)si);
- OldSplitterProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_SPLITTERX),GWLP_WNDPROC,(LONG_PTR)SplitterSubclassProc);
- SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_SPLITTERY),GWLP_WNDPROC,(LONG_PTR)SplitterSubclassProc);
- OldNicklistProc=(WNDPROC)SetWindowLongPtr(hNickList,GWLP_WNDPROC,(LONG_PTR)NicklistSubclassProc);
- OldTabProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_TAB),GWLP_WNDPROC,(LONG_PTR)TabSubclassProc);
- OldLogProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_LOG),GWLP_WNDPROC,(LONG_PTR)LogSubclassProc);
- OldFilterButtonProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_FILTER),GWLP_WNDPROC,(LONG_PTR)ButtonSubclassProc);
- SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_COLOR),GWLP_WNDPROC,(LONG_PTR)ButtonSubclassProc);
- SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_BKGCOLOR),GWLP_WNDPROC,(LONG_PTR)ButtonSubclassProc);
- OldMessageProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWLP_WNDPROC,(LONG_PTR)MessageSubclassProc);
+ mir_subclassWindow( GetDlgItem(hwndDlg,IDC_SPLITTERX), SplitterSubclassProc);
+ mir_subclassWindow( GetDlgItem(hwndDlg,IDC_SPLITTERY), SplitterSubclassProc);
+ mir_subclassWindow( hNickList, NicklistSubclassProc);
+ mir_subclassWindow( GetDlgItem(hwndDlg,IDC_TAB), TabSubclassProc);
+ mir_subclassWindow( GetDlgItem(hwndDlg,IDC_LOG), LogSubclassProc);
+ mir_subclassWindow( GetDlgItem(hwndDlg,IDC_FILTER), ButtonSubclassProc);
+ mir_subclassWindow( GetDlgItem(hwndDlg,IDC_COLOR), ButtonSubclassProc);
+ mir_subclassWindow( GetDlgItem(hwndDlg,IDC_BKGCOLOR), ButtonSubclassProc);
+ mir_subclassWindow( GetDlgItem(hwndDlg, IDC_MESSAGE), MessageSubclassProc);
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SUBCLASSED, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_AUTOURLDETECT, 1, 0);
mask = (int)SendDlgItemMessage(hwndDlg, IDC_LOG, EM_GETEVENTMASK, 0, 0);
@@ -2709,17 +2700,8 @@ LABEL_SHOWWINDOW: si->hwndTooltip = NULL;
if (si->pAccPropServicesForNickList) si->pAccPropServicesForNickList->Release();
SetWindowLongPtr(hwndDlg,GWLP_USERDATA,0);
- SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_SPLITTERX),GWLP_WNDPROC,(LONG_PTR)OldSplitterProc);
- SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_SPLITTERY),GWLP_WNDPROC,(LONG_PTR)OldSplitterProc);
- SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_LIST),GWLP_WNDPROC,(LONG_PTR)OldNicklistProc);
- SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_TAB),GWLP_WNDPROC,(LONG_PTR)OldTabProc);
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_UNSUBCLASSED, 0, 0);
- SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_MESSAGE),GWLP_WNDPROC,(LONG_PTR)OldMessageProc);
- SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_LOG),GWLP_WNDPROC,(LONG_PTR)OldLogProc);
- SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_FILTER),GWLP_WNDPROC,(LONG_PTR)OldFilterButtonProc);
- SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_COLOR),GWLP_WNDPROC,(LONG_PTR)OldFilterButtonProc);
- SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_BKGCOLOR),GWLP_WNDPROC,(LONG_PTR)OldFilterButtonProc);
break;
}
- return(FALSE);
+ return FALSE;
}
diff --git a/src/core/stdfile/fileexistsdlg.cpp b/src/core/stdfile/fileexistsdlg.cpp index 4efb73ebfb..8729229462 100644 --- a/src/core/stdfile/fileexistsdlg.cpp +++ b/src/core/stdfile/fileexistsdlg.cpp @@ -112,24 +112,23 @@ static void DoAnnoyingShellCommand(HWND hwnd, const TCHAR *szFilename, int cmd, }
}
-static WNDPROC pfnIconWindowProc;
static LRESULT CALLBACK IconCtrlSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PROTOFILETRANSFERSTATUS* pft = (PROTOFILETRANSFERSTATUS*)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA);
switch(msg) {
- case WM_LBUTTONDBLCLK:
- ShellExecute(hwnd, NULL, pft->tszCurrentFile, NULL, NULL, SW_SHOW);
- break;
- case WM_RBUTTONUP:
+ case WM_LBUTTONDBLCLK:
+ ShellExecute(hwnd, NULL, pft->tszCurrentFile, NULL, NULL, SW_SHOW);
+ break;
+ case WM_RBUTTONUP:
{ POINT pt;
- pt.x = (short)LOWORD(lParam); pt.y = (short)HIWORD(lParam);
- ClientToScreen(hwnd, &pt);
- DoAnnoyingShellCommand(hwnd, pft->tszCurrentFile, C_CONTEXTMENU, &pt);
- return 0;
+ pt.x = (short)LOWORD(lParam); pt.y = (short)HIWORD(lParam);
+ ClientToScreen(hwnd, &pt);
+ DoAnnoyingShellCommand(hwnd, pft->tszCurrentFile, C_CONTEXTMENU, &pt);
+ return 0;
}
}
- return CallWindowProc(pfnIconWindowProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, IconCtrlSubclassProc, msg, wParam, lParam);
}
struct loadiconsstartinfo {
@@ -215,7 +214,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM GetSensiblyFormattedSize(fts->currentFileSize, szSize, SIZEOF(szSize), 0, 1, NULL);
SetDlgItemText(hwndDlg, IDC_NEWSIZE, szSize);
- pfnIconWindowProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_EXISTINGICON), GWLP_WNDPROC, (LONG_PTR)IconCtrlSubclassProc);
+ mir_subclassWindow( GetDlgItem(hwndDlg, IDC_EXISTINGICON), IconCtrlSubclassProc);
hwndFocus = GetDlgItem(hwndDlg, IDC_RESUME);
if (_tstati64(fts->tszCurrentFile, &statbuf) == 0) {
diff --git a/src/core/stdfile/filesenddlg.cpp b/src/core/stdfile/filesenddlg.cpp index 4523c63b36..e41670889b 100644 --- a/src/core/stdfile/filesenddlg.cpp +++ b/src/core/stdfile/filesenddlg.cpp @@ -170,24 +170,23 @@ static BOOL CALLBACK ClipSiblingsChildEnumProc(HWND hwnd, LPARAM) return TRUE;
}
-static WNDPROC OldSendEditProc;
static LRESULT CALLBACK SendEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg) {
- case WM_CHAR:
- if (wParam == '\n' && GetKeyState(VK_CONTROL)&0x8000) {
- PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0);
- return 0;
- }
- break;
- case WM_SYSCHAR:
- if ((wParam == 's' || wParam == 'S') && GetKeyState(VK_MENU)&0x8000) {
- PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0);
- return 0;
- }
- break;
+ case WM_CHAR:
+ if (wParam == '\n' && GetKeyState(VK_CONTROL)&0x8000) {
+ PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0);
+ return 0;
+ }
+ break;
+ case WM_SYSCHAR:
+ if ((wParam == 's' || wParam == 'S') && GetKeyState(VK_MENU)&0x8000) {
+ PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0);
+ return 0;
+ }
+ break;
}
- return CallWindowProc(OldSendEditProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, SendEditSubclassProc, msg, wParam, lParam);
}
INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -210,7 +209,7 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l TranslateDialogDefault(hwndDlg);
EnumChildWindows(hwndDlg, ClipSiblingsChildEnumProc, 0);
- OldSendEditProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MSG), GWLP_WNDPROC, (LONG_PTR)SendEditSubclassProc);
+ mir_subclassWindow( GetDlgItem(hwndDlg, IDC_MSG), SendEditSubclassProc);
Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_FILE);
Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View User's Details"));
@@ -349,7 +348,6 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l if (dat)
FreeFileDlgData(dat);
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MSG), GWLP_WNDPROC, (LONG_PTR)OldSendEditProc);
return TRUE;
}
return FALSE;
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index dcb83e9f35..f0d40a305b 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -504,7 +504,7 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar mir_free(dat);
return 0;
}
- return CallWindowProc(pdat->OldMessageEditProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, MessageEditSubclassProc, msg, wParam, lParam);
}
static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -539,7 +539,7 @@ static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, ReleaseCapture();
return 0;
}
- return CallWindowProc(pdat->OldSplitterProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, SplitterSubclassProc, msg, wParam, lParam);
}
static int MessageDialogResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL * urc)
@@ -779,9 +779,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SendDlgItemMessage(hwndDlg, IDC_LOG, EM_LIMITTEXT, (WPARAM) sizeof(TCHAR) * 0x7FFFFFFF, 0);
}
- dat->OldMessageEditProc = (WNDPROC) SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWLP_WNDPROC, (LONG_PTR) MessageEditSubclassProc);
+ mir_subclassWindow(GetDlgItem(hwndDlg, IDC_MESSAGE), MessageEditSubclassProc);
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SUBCLASSED, 0, 0);
- dat->OldSplitterProc = (WNDPROC) SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_SPLITTER), GWLP_WNDPROC, (LONG_PTR) SplitterSubclassProc);
+ mir_subclassWindow(GetDlgItem(hwndDlg, IDC_SPLITTER), SplitterSubclassProc);
if (dat->hContact) {
int historyMode = db_get_b(NULL, SRMMMOD, SRMSGSET_LOADHISTORY, SRMSGDEFSET_LOADHISTORY);
@@ -1850,9 +1850,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP tcmdlist_free(dat->cmdList);
WindowList_Remove(g_dat->hMessageWindowList, hwndDlg);
DBWriteContactSettingDword(db_get_b(NULL, SRMMMOD, SRMSGSET_SAVEPERCONTACT, SRMSGDEFSET_SAVEPERCONTACT)?dat->hContact:NULL, SRMMMOD, "splitterPos", dat->splitterPos);
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_SPLITTER), GWLP_WNDPROC, (LONG_PTR) dat->OldSplitterProc);
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_UNSUBCLASSED, 0, 0);
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWLP_WNDPROC, (LONG_PTR) dat->OldMessageEditProc);
{
HFONT hFont = (HFONT) SendDlgItemMessage(hwndDlg, IDC_MESSAGE, WM_GETFONT, 0, 0);
if (hFont != NULL && hFont != (HFONT) SendDlgItemMessage(hwndDlg, IDOK, WM_GETFONT, 0, 0))
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index 1403172b2a..3414ee5e98 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -38,7 +38,6 @@ struct SrmmWindowData HANDLE hContact;
HANDLE hDbEventFirst, hDbEventLast;
HBRUSH hBkgBrush;
- WNDPROC OldMessageEditProc, OldSplitterProc;
int splitterPos, originalSplitterPos;
SIZE minEditBoxSize;
RECT minEditInit;
diff --git a/src/core/stdmsg/src/richutil.cpp b/src/core/stdmsg/src/richutil.cpp index c863395cd0..42e3f890f3 100644 --- a/src/core/stdmsg/src/richutil.cpp +++ b/src/core/stdmsg/src/richutil.cpp @@ -118,7 +118,7 @@ int RichUtil_SubClass(HWND hwndEdit) List_Insert(&sListInt, ru, idx);
LeaveCriticalSection(&csRich);
- ru->origProc = (WNDPROC)SetWindowLongPtr(ru->hwnd, GWLP_WNDPROC, (LONG_PTR)&RichUtil_Proc);
+ mir_subclassWindow(ru->hwnd, RichUtil_Proc);
RichUtil_ClearUglyBorder(ru);
return 1;
}
@@ -135,9 +135,8 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM if (ru == NULL) return 0;
- switch(msg)
- {
- case WM_CHAR:
+ switch(msg) {
+ case WM_CHAR:
{
HWND hwndMsg = GetDlgItem(GetParent(hwnd), IDC_MESSAGE);
if (hwndMsg != hwnd)
@@ -148,16 +147,16 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM break;
}
- case WM_THEMECHANGED:
- case WM_STYLECHANGED:
+ case WM_THEMECHANGED:
+ case WM_STYLECHANGED:
{
RichUtil_ClearUglyBorder(ru);
break;
}
- case WM_NCPAINT:
+ case WM_NCPAINT:
{
- LRESULT ret = CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
+ LRESULT ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
if (ru->hasUglyBorder && MyIsThemeActive())
{
HANDLE hTheme = MyOpenThemeData(ru->hwnd, L"EDIT");
@@ -197,22 +196,18 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM }
return ret;
}
- case WM_NCCALCSIZE:
+ case WM_NCCALCSIZE:
{
- LRESULT ret = CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
+ LRESULT ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS*)lParam;
- if (ru->hasUglyBorder && MyIsThemeActive())
- {
+ if (ru->hasUglyBorder && MyIsThemeActive()) {
HANDLE hTheme = MyOpenThemeData(hwnd, L"EDIT");
-
- if (hTheme)
- {
+ if (hTheme) {
RECT rcClient ={0};
HDC hdc = GetDC(GetParent(hwnd));
- if (MyGetThemeBackgroundContentRect(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &ncsParam->rgrc[0], &rcClient) == S_OK)
- {
+ if (MyGetThemeBackgroundContentRect(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &ncsParam->rgrc[0], &rcClient) == S_OK) {
ru->rect.left = rcClient.left-ncsParam->rgrc[0].left;
ru->rect.top = rcClient.top-ncsParam->rgrc[0].top;
ru->rect.right = ncsParam->rgrc[0].right-rcClient.right;
@@ -230,32 +225,24 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return ret;
}
- case WM_ENABLE:
- RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME);
- break;
+ case WM_ENABLE:
+ RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME);
+ break;
- case WM_GETDLGCODE:
- return CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam) & ~DLGC_HASSETSEL;
+ case WM_GETDLGCODE:
+ return mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam) & ~DLGC_HASSETSEL;
- case WM_NCDESTROY:
- {
- LRESULT ret = CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
+ case WM_NCDESTROY:
+ LRESULT ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
- if (IsWindow(hwnd))
- {
- if ((WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC) == &RichUtil_Proc)
- SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)ru->origProc);
- }
-
- EnterCriticalSection(&csRich);
- List_RemovePtr(&sListInt, ru);
- LeaveCriticalSection(&csRich);
+ EnterCriticalSection(&csRich);
+ List_RemovePtr(&sListInt, ru);
+ LeaveCriticalSection(&csRich);
- mir_free(ru);
- return ret;
- }
+ mir_free(ru);
+ return ret;
}
- return CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
}
static void RichUtil_ClearUglyBorder(TRichUtil *ru)
diff --git a/src/core/stdmsg/src/richutil.h b/src/core/stdmsg/src/richutil.h index ff90e14691..1408c85ead 100644 --- a/src/core/stdmsg/src/richutil.h +++ b/src/core/stdmsg/src/richutil.h @@ -26,7 +26,6 @@ typedef struct { HWND hwnd;
RECT rect;
int hasUglyBorder;
- WNDPROC origProc;
} TRichUtil;
void RichUtil_Load();
diff --git a/src/core/stdurl/urldialogs.cpp b/src/core/stdurl/urldialogs.cpp index 863d58be63..dc0ef67bf4 100644 --- a/src/core/stdurl/urldialogs.cpp +++ b/src/core/stdurl/urldialogs.cpp @@ -438,7 +438,6 @@ static void GetOpenBrowserUrls(HWND hwndDlg, HWND hwndCombo) GetOpenBrowserUrlsForBrowser("iexplore", hwndDlg, hwndCombo);
}
-static WNDPROC OldSendEditProc;
static LRESULT CALLBACK SendEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg) {
@@ -455,7 +454,7 @@ static LRESULT CALLBACK SendEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, }
break;
}
- return CallWindowProc(OldSendEditProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, SendEditSubclassProc, msg, wParam, lParam);
}
INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -489,8 +488,8 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0))SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_URLS, CBN_SELCHANGE), 0);
EnableWindow(GetDlgItem(hwndDlg, IDOK), (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0) == CB_ERR)?FALSE:TRUE);
Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "SRUrl", "send");
- OldSendEditProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWLP_WNDPROC, (LONG_PTR)SendEditSubclassProc);
- OldSendEditProc = (WNDPROC)SetWindowLongPtr(GetWindow(GetDlgItem(hwndDlg, IDC_URLS), GW_CHILD), GWLP_WNDPROC, (LONG_PTR)SendEditSubclassProc);
+ mir_subclassWindow( GetDlgItem(hwndDlg, IDC_MESSAGE), SendEditSubclassProc);
+ mir_subclassWindow( GetWindow(GetDlgItem(hwndDlg, IDC_URLS), GW_CHILD), SendEditSubclassProc);
// From message dlg
if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0))
@@ -647,8 +646,6 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU);
WindowList_Remove(hUrlWindowList, hwndDlg);
- SetWindowLongPtr(GetWindow(GetDlgItem(hwndDlg, IDC_URLS), GW_CHILD), GWLP_WNDPROC, (LONG_PTR)OldSendEditProc);
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWLP_WNDPROC, (LONG_PTR)OldSendEditProc);
if (dat->hAckEvent) UnhookEvent(dat->hAckEvent);
if (dat->sendBuffer != NULL) mir_free(dat->sendBuffer);
mir_free(dat);
diff --git a/src/mir_core/subclass.cpp b/src/mir_core/subclass.cpp index a526aeb9bf..6bb1eeb962 100644 --- a/src/mir_core/subclass.cpp +++ b/src/mir_core/subclass.cpp @@ -37,17 +37,10 @@ static LRESULT CALLBACK MSubclassWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP {
MSubclassData *p = arSubclass.find((MSubclassData*)&hwnd);
if (p != NULL) {
- for (int i=0; i < p->m_iHooks; i++) {
- LRESULT res = p->m_hooks[i](hwnd, uMsg, wParam, lParam);
- if (res != 0)
- return res;
- }
+ if (p->m_iHooks)
+ return p->m_hooks[0](hwnd, uMsg, wParam, lParam);
- if (uMsg == WM_DESTROY) {
- SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)p->m_origWndProc);
- arSubclass.remove(p);
- delete p;
- }
+ return p->m_origWndProc(hwnd, uMsg, wParam, lParam);
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
@@ -64,7 +57,37 @@ MIR_CORE_DLL(void) mir_subclassWindow(HWND hWnd, WNDPROC wndProc) p->m_hooks = (WNDPROC*)malloc( sizeof(WNDPROC));
arSubclass.insert(p);
}
- else p->m_hooks = (WNDPROC*)realloc(p->m_hooks, (p->m_iHooks+1)*sizeof(WNDPROC));
+ else {
+ for (int i=0; i < p->m_iHooks; i++)
+ if (p->m_hooks[i] == wndProc)
+ return;
+
+ p->m_hooks = (WNDPROC*)realloc(p->m_hooks, (p->m_iHooks+1)*sizeof(WNDPROC));
+ }
+
+ p->m_hooks[p->m_iHooks++] = wndProc;
+}
+
+MIR_CORE_DLL(void) mir_subclassWindowFull(HWND hWnd, WNDPROC wndProc, WNDPROC oldWndProc)
+{
+ MSubclassData *p = arSubclass.find((MSubclassData*)&hWnd);
+ if (p == NULL) {
+ p = new MSubclassData;
+ p->m_hWnd = hWnd;
+ p->m_origWndProc = oldWndProc;
+ p->m_iHooks = 0;
+ p->m_hooks = (WNDPROC*)malloc( sizeof(WNDPROC));
+ arSubclass.insert(p);
+
+ SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)MSubclassWndProc);
+ }
+ else {
+ for (int i=0; i < p->m_iHooks; i++)
+ if (p->m_hooks[i] == wndProc)
+ return;
+
+ p->m_hooks = (WNDPROC*)realloc(p->m_hooks, (p->m_iHooks+1)*sizeof(WNDPROC));
+ }
p->m_hooks[p->m_iHooks++] = wndProc;
}
@@ -72,11 +95,32 @@ MIR_CORE_DLL(void) mir_subclassWindow(HWND hWnd, WNDPROC wndProc) MIR_CORE_DLL(LRESULT) mir_callNextSubclass(HWND hWnd, WNDPROC wndProc, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
MSubclassData *p = arSubclass.find((MSubclassData*)&hWnd);
- if (p)
- for (int i=0; i < p->m_iHooks-1; i++)
+ if (p) {
+ int i;
+ for (i=0; i < p->m_iHooks; i++)
if (p->m_hooks[i] == wndProc)
- return p->m_hooks[i+1](hWnd, uMsg, wParam, lParam);
+ break;
+
+ // 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 DefWindowProc(hWnd, uMsg, wParam, lParam);
}
@@ -86,9 +130,16 @@ MIR_CORE_DLL(void) KillModuleSubclassing(HMODULE hInst) MSubclassData *p = arSubclass[i];
for (int j=0; j < p->m_iHooks; ) {
if ( GetInstByAddress(p->m_hooks[j]) == hInst) {
+ WNDPROC saveProc = p->m_hooks[j];
+
+ // untie hook from a window to prevent calling mir_callNextSubclass from saveProc
for (int k=j+1; k < p->m_iHooks; k++)
p->m_hooks[k-1] = p->m_hooks[k];
p->m_iHooks--;
+
+ // emulate window destruction
+ saveProc(p->m_hWnd, WM_DESTROY, 0, 0);
+ saveProc(p->m_hWnd, WM_NCDESTROY, 0, 0);
}
else j++;
}
diff --git a/src/modules/clist/clcutils.cpp b/src/modules/clist/clcutils.cpp index fb5053bd00..b4873b9d03 100644 --- a/src/modules/clist/clcutils.cpp +++ b/src/modules/clist/clcutils.cpp @@ -457,7 +457,6 @@ void fnDeleteFromContactList(HWND hwnd, struct ClcData *dat) }
}
-static WNDPROC OldRenameEditWndProc;
static LRESULT CALLBACK RenameEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
@@ -484,7 +483,7 @@ static LRESULT CALLBACK RenameEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPara cli.pfnEndRename(GetParent(hwnd), (struct ClcData *) GetWindowLongPtr(GetParent(hwnd), 0), 1);
return 0;
}
- return CallWindowProc(OldRenameEditWndProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, RenameEditSubclassProc, msg, wParam, lParam);
}
void fnBeginRenameSelection(HWND hwnd, struct ClcData *dat)
@@ -507,7 +506,7 @@ void fnBeginRenameSelection(HWND hwnd, struct ClcData *dat) cli.pfnCalcEipPosition(dat, contact, group, &pt);
int h = cli.pfnGetRowHeight(dat, dat->selection);
dat->hwndRenameEdit = CreateWindow(_T("EDIT"), contact->szText, WS_CHILD | WS_BORDER | ES_AUTOHSCROLL, pt.x, pt.y, clRect.right - pt.x, h, hwnd, NULL, cli.hInst, NULL);
- OldRenameEditWndProc = (WNDPROC) SetWindowLongPtr(dat->hwndRenameEdit, GWLP_WNDPROC, (LONG_PTR) RenameEditSubclassProc);
+ mir_subclassWindow(dat->hwndRenameEdit, RenameEditSubclassProc);
SendMessage(dat->hwndRenameEdit, WM_SETFONT, (WPARAM) (contact->type == CLCIT_GROUP ? dat->fontInfo[FONTID_GROUPS].hFont : dat->fontInfo[FONTID_CONTACTS].hFont), 0);
SendMessage(dat->hwndRenameEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN | EC_USEFONTINFO, 0);
SendMessage(dat->hwndRenameEdit, EM_SETSEL, 0, (LPARAM) (-1));
diff --git a/src/modules/clist/genmenuopt.cpp b/src/modules/clist/genmenuopt.cpp index 6dd96a921b..3922e42533 100644 --- a/src/modules/clist/genmenuopt.cpp +++ b/src/modules/clist/genmenuopt.cpp @@ -382,8 +382,6 @@ static HTREEITEM MoveItemAbove(HWND hTreeWnd, HTREEITEM hItem, HTREEITEM hInsert return NULL;
}
-WNDPROC MyOldWindowProc = NULL;
-
LRESULT CALLBACK LBTNDOWNProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_LBUTTONDOWN && !(GetKeyState(VK_CONTROL)&0x8000)) {
@@ -424,7 +422,7 @@ LRESULT CALLBACK LBTNDOWNProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam }
}
- return CallWindowProc(MyOldWindowProc, hwnd, uMsg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, LBTNDOWNProc, uMsg, wParam, lParam);
}
static INT_PTR CALLBACK GenMenuOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -439,8 +437,7 @@ static INT_PTR CALLBACK GenMenuOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SetWindowLongPtr( GetDlgItem(hwndDlg, IDC_MENUITEMS), GWLP_USERDATA, (LONG_PTR)dat);
dat->dragging = 0;
dat->iInitMenuValue = db_get_b(NULL, "CList", "MoveProtoMenus", TRUE);
- MyOldWindowProc = (WNDPROC)GetWindowLongPtr( GetDlgItem(hwndDlg, IDC_MENUITEMS), GWLP_WNDPROC);
- SetWindowLongPtr( GetDlgItem(hwndDlg, IDC_MENUITEMS), GWLP_WNDPROC, (LONG_PTR)&LBTNDOWNProc);
+ mir_subclassWindow( GetDlgItem(hwndDlg, IDC_MENUITEMS), LBTNDOWNProc);
{
HIMAGELIST himlCheckBoxes;
himlCheckBoxes = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
diff --git a/src/modules/database/profilemanager.cpp b/src/modules/database/profilemanager.cpp index d597d50a3f..67589a9d25 100644 --- a/src/modules/database/profilemanager.cpp +++ b/src/modules/database/profilemanager.cpp @@ -155,7 +155,7 @@ static LRESULT CALLBACK ProfileNameValidate(HWND edit, UINT msg, WPARAM wParam, return 0;
PostMessage(GetParent(edit), WM_INPUTCHANGED, 0, 0);
}
- return CallWindowProc((WNDPROC)GetWindowLongPtr(edit, GWLP_USERDATA), edit, msg, wParam, lParam);
+ return mir_callNextSubclass(edit, ProfileNameValidate, msg, wParam, lParam);
}
static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -187,10 +187,7 @@ static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPA SendMessage(hwndCombo, CB_SETCURSEL, 0, 0);
// subclass the profile name box
- HWND hwndProfile = GetDlgItem(hwndDlg, IDC_PROFILENAME);
- WNDPROC proc = (WNDPROC)GetWindowLongPtr(hwndProfile, GWLP_WNDPROC);
- SetWindowLongPtr(hwndProfile, GWLP_USERDATA, (LONG_PTR)proc);
- SetWindowLongPtr(hwndProfile, GWLP_WNDPROC, (LONG_PTR)ProfileNameValidate);
+ mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PROFILENAME), ProfileNameValidate);
}
// decide if there is a default profile name given in the INI and if it should be used
diff --git a/src/modules/extraicons/options_ei.cpp b/src/modules/extraicons/options_ei.cpp index fc76ce5835..65866ae24b 100644 --- a/src/modules/extraicons/options_ei.cpp +++ b/src/modules/extraicons/options_ei.cpp @@ -67,8 +67,6 @@ static void RemoveExtraIcons(int slot) #define TVIS_FOCUSED 1
#endif
-WNDPROC origTreeProc;
-
static bool IsSelected(HWND tree, HTREEITEM hItem)
{
return (TVIS_SELECTED & TreeView_GetItemState(tree, hItem, TVIS_SELECTED)) == TVIS_SELECTED;
@@ -234,7 +232,7 @@ LRESULT CALLBACK TreeProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) }
}
- return CallWindowProc(origTreeProc, hwndDlg, msg, wParam, lParam);
+ return mir_callNextSubclass(hwndDlg, TreeProc, msg, wParam, lParam);
}
static vector<int> * Tree_GetIDs(HWND tree, HTREEITEM hItem)
@@ -468,7 +466,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP sort.lpfnCompare = CompareFunc;
TreeView_SortChildrenCB(tree, &sort, 0);
- origTreeProc = (WNDPROC) SetWindowLongPtr(tree, GWLP_WNDPROC, (INT_PTR)TreeProc);
+ mir_subclassWindow(tree, TreeProc);
}
return TRUE;
diff --git a/src/modules/options/options.cpp b/src/modules/options/options.cpp index 952e30361a..e7fd848af1 100644 --- a/src/modules/options/options.cpp +++ b/src/modules/options/options.cpp @@ -252,15 +252,13 @@ static int MatchesFilter(const OptionsPageData *page, TCHAR *szFilterString) return ContainsFilterString(key, szFilterString);
}
-static WNDPROC OptionsFilterDefaultProc = NULL;
-
static LRESULT CALLBACK OptionsFilterSubclassProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message != WM_PAINT && message != WM_PRINT)
- return CallWindowProc(OptionsFilterDefaultProc, hWnd, message, wParam, lParam);
+ return mir_callNextSubclass(hWnd, OptionsFilterSubclassProc, message, wParam, lParam);
if (GetFocus() == hWnd || GetWindowTextLength(hWnd))
- return CallWindowProc(OptionsFilterDefaultProc, hWnd, message, wParam, lParam);
+ return mir_callNextSubclass(hWnd, OptionsFilterSubclassProc, message, wParam, lParam);
RECT rc;
GetClientRect(hWnd, &rc);
@@ -386,7 +384,7 @@ static void AeroPaintControl(HWND hwnd, HDC hdc, WNDPROC OldWndProc, UINT msg = //paint
SetPropA(hwnd, "Miranda.AeroRender.Active", (HANDLE)TRUE);
- CallWindowProc(OldWndProc, hwnd, msg, (WPARAM)tempDC, lpFlags);
+ mir_callNextSubclass(hwnd, OldWndProc, msg, (WPARAM)tempDC, lpFlags);
SetPropA(hwnd, "Miranda.AeroRender.Active", (HANDLE)FALSE);
// Fix alpha channel
@@ -403,7 +401,6 @@ static void AeroPaintControl(HWND hwnd, HDC hdc, WNDPROC OldWndProc, UINT msg = static LRESULT CALLBACK AeroPaintSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- WNDPROC OldWndProc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_USERDATA);
switch (msg) {
case WM_CTLCOLOREDIT:
if ( !GetPropA((HWND)lParam, "Miranda.AeroRender.Active"))
@@ -415,14 +412,14 @@ static LRESULT CALLBACK AeroPaintSubclassProc(HWND hwnd, UINT msg, WPARAM wParam case WM_PRINT:
case WM_PRINTCLIENT:
- AeroPaintControl(hwnd, (HDC)wParam, OldWndProc, msg, lParam);
+ AeroPaintControl(hwnd, (HDC)wParam, AeroPaintSubclassProc, msg, lParam);
return TRUE;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
- AeroPaintControl(hwnd, hdc, OldWndProc);
+ AeroPaintControl(hwnd, hdc, AeroPaintSubclassProc);
EndPaint(hwnd, &ps);
}
return TRUE;
@@ -431,7 +428,7 @@ static LRESULT CALLBACK AeroPaintSubclassProc(HWND hwnd, UINT msg, WPARAM wParam RemovePropA(hwnd, "Miranda.AeroRender.Active");
break;
}
- return CallWindowProc(OldWndProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, AeroPaintSubclassProc, msg, wParam, lParam);
}
static void CALLBACK FilterSearchTimerFunc(HWND hwnd, UINT, UINT_PTR, DWORD)
@@ -662,13 +659,11 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L COMBOBOXINFO cbi;
cbi.cbSize = sizeof(COMBOBOXINFO);
getComboBoxInfo( GetDlgItem(hdlg, IDC_KEYWORD_FILTER), &cbi);
- OptionsFilterDefaultProc = (WNDPROC)SetWindowLongPtr(cbi.hwndItem, GWLP_WNDPROC, (LONG_PTR) OptionsFilterSubclassProc);
+ mir_subclassWindow(cbi.hwndItem, OptionsFilterSubclassProc);
if (IsAeroMode()) {
- SetWindowLongPtr(cbi.hwndCombo, GWLP_USERDATA, GetWindowLongPtr(cbi.hwndCombo, GWLP_WNDPROC));
- SetWindowLongPtr(cbi.hwndCombo, GWLP_WNDPROC, (LONG_PTR)AeroPaintSubclassProc);
- SetWindowLongPtr(cbi.hwndItem, GWLP_USERDATA, GetWindowLongPtr(cbi.hwndItem, GWLP_WNDPROC));
- SetWindowLongPtr(cbi.hwndItem, GWLP_WNDPROC, (LONG_PTR)AeroPaintSubclassProc);
+ mir_subclassWindow(cbi.hwndCombo, AeroPaintSubclassProc);
+ mir_subclassWindow(cbi.hwndItem, AeroPaintSubclassProc);
}
}
diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index b3c46d4482..90ea348e59 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -347,6 +347,8 @@ int Plugin_UnloadDyn(pluginEntry *p) if ( CallPluginEventHook(p->bpi.hInst, hOkToExitEvent, 0, 0) != 0)
return FALSE;
+ KillModuleSubclassing(p->bpi.hInst);
+
CallPluginEventHook(p->bpi.hInst, hPreShutdownEvent, 0, 0);
CallPluginEventHook(p->bpi.hInst, hShutdownEvent, 0, 0);
diff --git a/src/modules/plugins/pluginopts.cpp b/src/modules/plugins/pluginopts.cpp index 8448b255bb..12aa248e31 100644 --- a/src/modules/plugins/pluginopts.cpp +++ b/src/modules/plugins/pluginopts.cpp @@ -229,8 +229,7 @@ static LRESULT CALLBACK PluginListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LP ListView_SetItem(hwnd, &lvi);
} } } } }
- WNDPROC wnProc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- return CallWindowProc(wnProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, PluginListWndProc, msg, wParam, lParam);
}
static int CALLBACK SortPlugins(WPARAM i1, LPARAM i2, LPARAM lParamSort)
@@ -254,8 +253,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar TranslateDialogDefault(hwndDlg);
{
HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST);
- SetWindowLongPtr(hwndList, GWLP_USERDATA, (LONG_PTR)GetWindowLongPtr(hwndList, GWLP_WNDPROC));
- SetWindowLongPtr(hwndList, GWLP_WNDPROC, (LONG_PTR)PluginListWndProc);
+ mir_subclassWindow(hwndList, PluginListWndProc);
HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus()? ILC_COLOR32 : ILC_COLOR16), 4, 0);
ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNICODE);
diff --git a/src/modules/protocols/protoopts.cpp b/src/modules/protocols/protoopts.cpp index 7b128dcea7..4eec5c28b1 100644 --- a/src/modules/protocols/protoopts.cpp +++ b/src/modules/protocols/protoopts.cpp @@ -227,12 +227,9 @@ struct TAccMgrData struct TAccListData
{
- WNDPROC oldWndProc;
- int iItem;
+ int iItem;
RECT rcCheck;
-
HWND hwndEdit;
- WNDPROC oldEditProc;
};
static void sttClickButton(HWND hwndDlg, int idcButton)
@@ -272,7 +269,7 @@ static LRESULT CALLBACK sttEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, DestroyWindow(hwnd);
return 0;
}
- return CallWindowProc((WNDPROC)GetWindowLongPtr(hwnd, GWLP_USERDATA), hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, sttEditSubclassProc, msg, wParam, lParam);
}
static LRESULT CALLBACK AccListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -338,7 +335,7 @@ static LRESULT CALLBACK AccListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA ++rc.top; --rc.right;
dat->hwndEdit = CreateWindow(_T("EDIT"), pa->tszAccountName, WS_CHILD|WS_BORDER|ES_AUTOHSCROLL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hwnd, NULL, hInst, NULL);
- SetWindowLongPtr(dat->hwndEdit, GWLP_USERDATA, SetWindowLongPtr(dat->hwndEdit, GWLP_WNDPROC, (LONG_PTR)sttEditSubclassProc));
+ mir_subclassWindow(dat->hwndEdit, sttEditSubclassProc);
SendMessage(dat->hwndEdit, WM_SETFONT, (WPARAM)parentDat->hfntTitle, 0);
SendMessage(dat->hwndEdit, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN|EC_USEFONTINFO, 0);
SendMessage(dat->hwndEdit, EM_SETSEL, 0, (LPARAM) (-1));
@@ -371,7 +368,7 @@ static LRESULT CALLBACK AccListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA break;
}
- return CallWindowProc(dat->oldWndProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, AccListWndProc, msg, wParam, lParam);
}
static void sttSubclassAccList(HWND hwnd, BOOL subclass)
@@ -379,13 +376,11 @@ static void sttSubclassAccList(HWND hwnd, BOOL subclass) if (subclass) {
struct TAccListData *dat = (struct TAccListData *)mir_alloc(sizeof(struct TAccListData));
dat->iItem = -1;
- dat->oldWndProc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC);
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat);
- SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)AccListWndProc);
+ mir_subclassWindow(hwnd, AccListWndProc);
}
else {
struct TAccListData *dat = (struct TAccListData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)dat->oldWndProc);
SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
mir_free(dat);
}
diff --git a/src/modules/skin/hotkey_opts.cpp b/src/modules/skin/hotkey_opts.cpp index b2159e5032..ed6a4bd40b 100644 --- a/src/modules/skin/hotkey_opts.cpp +++ b/src/modules/skin/hotkey_opts.cpp @@ -142,29 +142,23 @@ static LRESULT CALLBACK sttHotkeyEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP return TRUE;
case WM_DESTROY:
- {
- WNDPROC saveOldWndProc = data->oldWndProc;
- SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)data->oldWndProc);
- SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
- mir_free(data);
- return CallWindowProc(saveOldWndProc, hwnd, msg, wParam, lParam);
- }
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
+ mir_free(data);
}
- return CallWindowProc(data->oldWndProc, hwnd, msg, wParam, lParam);
+ return mir_callNextSubclass(hwnd, sttHotkeyEditProc, msg, wParam, lParam);
}
void HotkeyEditCreate(HWND hwnd)
{
THotkeyBoxData *data = (THotkeyBoxData *)mir_alloc(sizeof(THotkeyBoxData));
SetWindowLongPtr(hwnd, GWLP_USERDATA, (ULONG_PTR)data);
- data->oldWndProc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (ULONG_PTR)sttHotkeyEditProc);
+ mir_subclassWindow(hwnd, sttHotkeyEditProc);
}
void HotkeyEditDestroy(HWND hwnd)
{
THotkeyBoxData *data = (THotkeyBoxData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- SetWindowLongPtr(hwnd, GWLP_WNDPROC, (ULONG_PTR)data->oldWndProc);
SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
mir_free(data);
}
diff --git a/src/modules/skin/skin.h b/src/modules/skin/skin.h index 3dbbb3a7c5..b36472a0dd 100644 --- a/src/modules/skin/skin.h +++ b/src/modules/skin/skin.h @@ -29,7 +29,6 @@ typedef enum { HKT_GLOBAL, HKT_LOCAL, HKT_MANUAL, HKT_COUNT } THotkeyType; struct THotkeyBoxData
{
- WNDPROC oldWndProc;
BYTE shift;
BYTE key;
};
|