From 66cb770a982a2502456d10d73838df2b7239fd89 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 4 Mar 2013 07:23:42 +0000 Subject: new subclassing functions applied to all plugins git-svn-id: http://svn.miranda-ng.org/main/trunk@3880 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SpellChecker/src/ardialog.cpp | 40 ++++++++++++----------------------- plugins/SpellChecker/src/commons.h | 3 --- plugins/SpellChecker/src/utils.cpp | 30 +++++++------------------- 3 files changed, 22 insertions(+), 51 deletions(-) (limited to 'plugins/SpellChecker') diff --git a/plugins/SpellChecker/src/ardialog.cpp b/plugins/SpellChecker/src/ardialog.cpp index 409ba5a6f1..a2e1cb05af 100644 --- a/plugins/SpellChecker/src/ardialog.cpp +++ b/plugins/SpellChecker/src/ardialog.cpp @@ -37,8 +37,6 @@ struct Data AutoReplaceDialogCallback callback; void *param; - - WNDPROC old_edit_proc; }; BOOL ShowAutoReplaceDialog(HWND parent, BOOL modal, @@ -81,17 +79,15 @@ static LRESULT CALLBACK OnlyCharsEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP { Data *data = (Data *) GetWindowLongPtr(hwnd, GWLP_USERDATA); - switch(msg) - { - case WM_CHAR: + switch(msg) { + case WM_CHAR: + if (wParam == VK_BACK) + break; + if (lParam & (1 << 28)) // ALT key + break; + if (GetKeyState(VK_CONTROL) & 0x8000) // CTRL key + break; { - if (wParam == VK_BACK) - break; - if (lParam & (1 << 28)) // ALT key - break; - if (GetKeyState(VK_CONTROL) & 0x8000) // CTRL key - break; - TCHAR c = (TCHAR) wParam; if (!data->dict->autoReplace->isWordChar(c)) return 1; @@ -104,12 +100,11 @@ static LRESULT CALLBACK OnlyCharsEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP } } - LRESULT ret = CallWindowProc(data->old_edit_proc, hwnd, msg, wParam, lParam); + LRESULT ret = mir_callNextSubclass(hwnd, OnlyCharsEditProc, msg, wParam, lParam); - switch(msg) - { - case EM_PASTESPECIAL: - case WM_PASTE: + switch(msg) { + case EM_PASTESPECIAL: + case WM_PASTE: { TCHAR text[256]; GetWindowText(hwnd, text, SIZEOF(text)); @@ -121,7 +116,6 @@ static LRESULT CALLBACK OnlyCharsEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP } return ret; - } @@ -159,14 +153,9 @@ static void Close(HWND hwndDlg, int ret) Data *data = (Data *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA); if (!ret) - { data->callback(TRUE, data->dict, data->find.c_str(), data->replace.c_str(), data->useVariables, data->find.c_str(), data->param); - } - - SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_OLD), GWLP_WNDPROC, (LONG_PTR) data->old_edit_proc); - data->old_edit_proc = NULL; if (data->modal) EndDialog(hwndDlg, ret); @@ -185,9 +174,8 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa Data *data = (Data *) lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) data); - SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_OLD), GWLP_USERDATA, (LONG_PTR) data); - data->old_edit_proc = (WNDPROC) SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_OLD), GWLP_WNDPROC, - (LONG_PTR) OnlyCharsEditProc); + SetWindowLongPtr( GetDlgItem(hwndDlg, IDC_OLD), GWLP_USERDATA, (LONG_PTR)data); + mir_subclassWindow( GetDlgItem(hwndDlg, IDC_OLD), OnlyCharsEditProc); HICON hIcon = Skin_GetIcon("spellchecker_enabled"); SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon); diff --git a/plugins/SpellChecker/src/commons.h b/plugins/SpellChecker/src/commons.h index 55dcfacefc..9038fe26c4 100644 --- a/plugins/SpellChecker/src/commons.h +++ b/plugins/SpellChecker/src/commons.h @@ -120,15 +120,12 @@ struct Dialog char name[64]; Dictionary *lang; TCHAR lang_name[32]; - WNDPROC old_edit_proc; - WNDPROC owner_old_edit_proc; BOOL enabled; BOOL srmm; RichEdit *re; HWND hwnd_menu_owner; - WNDPROC old_menu_proc; BOOL changed; BOOL markedSomeWord; diff --git a/plugins/SpellChecker/src/utils.cpp b/plugins/SpellChecker/src/utils.cpp index 5b46486e6f..77d31a381f 100644 --- a/plugins/SpellChecker/src/utils.cpp +++ b/plugins/SpellChecker/src/utils.cpp @@ -523,7 +523,7 @@ LRESULT CALLBACK OwnerProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) dlg->changed = TRUE; } - return CallWindowProc(dlg->owner_old_edit_proc, hwnd, msg, wParam, lParam); + return mir_callNextSubclass(hwnd, OwnerProc, msg, wParam, lParam); } void ToggleEnabled(Dialog *dlg) @@ -565,7 +565,7 @@ LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return 1; } - LRESULT ret = CallWindowProc(dlg->old_edit_proc, hwnd, msg, wParam, lParam); + LRESULT ret = mir_callNextSubclass(hwnd, EditProc, msg, wParam, lParam); switch(msg) { case WM_KEYDOWN: @@ -932,12 +932,12 @@ int AddContactTextBox(HANDLE hContact, HWND hwnd, char *name, BOOL srmm, HWND hw if (opts.auto_locale) LoadDictFromKbdl(dlg); - dlg->old_edit_proc = (WNDPROC) SetWindowLongPtr(dlg->hwnd, GWLP_WNDPROC, (LONG_PTR) EditProc); + mir_subclassWindow(dlg->hwnd, EditProc); dialogs[hwnd] = dlg; if (dlg->srmm && hwndOwner != NULL) { dlg->hwnd_owner = hwndOwner; - dlg->owner_old_edit_proc = (WNDPROC) SetWindowLongPtr(dlg->hwnd_owner, GWLP_WNDPROC, (LONG_PTR) OwnerProc); + mir_subclassWindow(dlg->hwnd_owner, OwnerProc); dialogs[dlg->hwnd_owner] = dlg; ModifyIcon(dlg); @@ -959,14 +959,6 @@ void FreePopupData(Dialog *dlg) DESTROY_MENY(dlg->hLanguageSubMenu) DESTROY_MENY(dlg->hWrongWordsSubMenu) - if (dlg->old_menu_proc != NULL) - SetWindowLongPtr(dlg->hwnd_menu_owner, GWLP_WNDPROC, (LONG_PTR) dlg->old_menu_proc); - dlg->old_menu_proc = NULL; - - if (dlg->hwnd_menu_owner != NULL) - menus.erase(dlg->hwnd_menu_owner); - dlg->hwnd_menu_owner = NULL; - if (dlg->wrong_words != NULL) { for (unsigned i = 0; i < dlg->wrong_words->size(); i++) { FREE((*dlg->wrong_words)[i].word) @@ -1000,15 +992,9 @@ int RemoveContactTextBox(HWND hwnd) KillTimer(hwnd, TIMER_ID); - if (dlg->old_edit_proc != NULL) - SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) dlg->old_edit_proc); dialogs.erase(hwnd); - - if (dlg->hwnd_owner != NULL) { - if (dlg->owner_old_edit_proc != NULL) - SetWindowLongPtr(dlg->hwnd_owner, GWLP_WNDPROC, (LONG_PTR) dlg->owner_old_edit_proc); + if (dlg->hwnd_owner != NULL) dialogs.erase(dlg->hwnd_owner); - } delete dlg->re; FreePopupData(dlg); @@ -1200,7 +1186,7 @@ void AddItemsToMenu(Dialog *dlg, HMENU hMenu, POINT pt, HWND hwndOwner) dlg->hLanguageSubMenu = CreatePopupMenu(); if (dlg->hwnd_menu_owner != NULL) - dlg->old_menu_proc = (WNDPROC) SetWindowLongPtr(dlg->hwnd_menu_owner, GWLP_WNDPROC, (LONG_PTR) MenuWndProc); + mir_subclassWindow(dlg->hwnd_menu_owner, MenuWndProc); // First add languages for (int i = 0; i < languages.getCount(); i++) @@ -1450,7 +1436,7 @@ int IconPressed(WPARAM wParam, LPARAM lParam) if (opts.use_flags) { menus[dlg->hwnd] = dlg; dlg->hwnd_menu_owner = dlg->hwnd; - dlg->old_menu_proc = (WNDPROC) SetWindowLongPtr(dlg->hwnd_menu_owner, GWLP_WNDPROC, (LONG_PTR) MenuWndProc); + mir_subclassWindow(dlg->hwnd_menu_owner, MenuWndProc); } // First add languages @@ -1607,7 +1593,7 @@ LRESULT CALLBACK MenuWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } } - return CallWindowProc(dlg->old_menu_proc, hwnd, msg, wParam, lParam); + return mir_callNextSubclass(hwnd, MenuWndProc, msg, wParam, lParam); } TCHAR *lstrtrim(TCHAR *str) -- cgit v1.2.3