diff options
-rw-r--r-- | bin10/lib/mir_core.lib | bin | 32090 -> 32014 bytes | |||
-rw-r--r-- | bin10/lib/mir_core64.lib | bin | 29332 -> 29232 bytes | |||
-rw-r--r-- | bin11/lib/mir_core.lib | bin | 32090 -> 32014 bytes | |||
-rw-r--r-- | bin11/lib/mir_core64.lib | bin | 29332 -> 29232 bytes | |||
-rw-r--r-- | include/delphi/m_core.inc | 5 | ||||
-rw-r--r-- | include/m_core.h | 1 | ||||
-rw-r--r-- | plugins/Scriver/src/chat/window.cpp | 23 | ||||
-rw-r--r-- | plugins/Scriver/src/input.cpp | 350 | ||||
-rw-r--r-- | plugins/Scriver/src/utils.cpp | 12 | ||||
-rw-r--r-- | plugins/SmileyAdd/src/richcall.cpp | 77 | ||||
-rw-r--r-- | plugins/SpellChecker/src/utils.cpp | 1 | ||||
-rw-r--r-- | src/mir_core/mir_core.def | 1 | ||||
-rw-r--r-- | src/mir_core/subclass.cpp | 108 |
13 files changed, 285 insertions, 293 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib Binary files differindex 168b57782f..dad0ff7cfc 100644 --- a/bin10/lib/mir_core.lib +++ b/bin10/lib/mir_core.lib diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib Binary files differindex e2ddd40a35..789e26cd25 100644 --- a/bin10/lib/mir_core64.lib +++ b/bin10/lib/mir_core64.lib diff --git a/bin11/lib/mir_core.lib b/bin11/lib/mir_core.lib Binary files differindex a47fbce589..5c51311e9a 100644 --- a/bin11/lib/mir_core.lib +++ b/bin11/lib/mir_core.lib diff --git a/bin11/lib/mir_core64.lib b/bin11/lib/mir_core64.lib Binary files differindex 99eb113b38..45d0d5fce5 100644 --- a/bin11/lib/mir_core64.lib +++ b/bin11/lib/mir_core64.lib diff --git a/include/delphi/m_core.inc b/include/delphi/m_core.inc index fe6c08de9d..7221ec7c59 100644 --- a/include/delphi/m_core.inc +++ b/include/delphi/m_core.inc @@ -615,9 +615,8 @@ procedure mir_subclassWindowFull(Wnd:HWND; WndProc, OldWndProc:TWNDPROC); stdcal external CoreDLL name 'mir_subclassWindowFull';
function mir_callNextSubclass(Wnd:HWND; WndProc:TWNDPROC; uMsg:uint; wParam:WPARAM; lParam:LPARAM ):LRESULT; stdcall;
external CoreDLL name 'mir_callNextSubclass';
-
-procedure KillModuleSubclassing(hInst: HMODULE);
- external CoreDLL name 'KillModuleSubclassing';
+procedure mir_unsubclassWindow(Wnd:HWND; WndProc:TWNDPROC); stdcall;
+ external CoreDLL name 'mir_unsubclassWindow';
///////////////////////////////////////////////////////////////////////////////
diff --git a/include/m_core.h b/include/m_core.h index 9a969c5326..66841e0f6a 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -590,6 +590,7 @@ __forceinline char* mir_utf8decodeA(const char* src) MIR_CORE_DLL(void) mir_subclassWindow(HWND hWnd, WNDPROC wndProc);
MIR_CORE_DLL(void) mir_subclassWindowFull(HWND hWnd, WNDPROC wndProc, WNDPROC oldWndProc);
MIR_CORE_DLL(LRESULT) mir_callNextSubclass(HWND hWnd, WNDPROC wndProc, UINT uMsg, WPARAM wParam, LPARAM lParam);
+MIR_CORE_DLL(void) mir_unsubclassWindow(HWND hWnd, WNDPROC wndProc);
MIR_CORE_DLL(void) KillModuleSubclassing(HMODULE hInst);
diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp index 13feea82db..3a9a9e0350 100644 --- a/plugins/Scriver/src/chat/window.cpp +++ b/plugins/Scriver/src/chat/window.cpp @@ -1801,23 +1801,18 @@ LABEL_SHOWWINDOW: break;
case IDOK:
- {
- char* pszRtf;
- TCHAR* ptszText, *p1;
- if (!IsWindowEnabled(GetDlgItem(hwndDlg,IDOK)))
- break;
+ if ( IsWindowEnabled( GetDlgItem(hwndDlg,IDOK))) {
+ char *pszRtf = GetRichTextRTF(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE));
- pszRtf = GetRichTextRTF(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE));
- {
- TCmdList *cmdListNew = tcmdlist_last(si->windowData.cmdList);
- while (cmdListNew != NULL && cmdListNew->temporary) {
- si->windowData.cmdList = tcmdlist_remove(si->windowData.cmdList, cmdListNew);
- cmdListNew = tcmdlist_last(si->windowData.cmdList);
- }
+ TCmdList *cmdListNew = tcmdlist_last(si->windowData.cmdList);
+ while (cmdListNew != NULL && cmdListNew->temporary) {
+ si->windowData.cmdList = tcmdlist_remove(si->windowData.cmdList, cmdListNew);
+ cmdListNew = tcmdlist_last(si->windowData.cmdList);
}
+
si->windowData.cmdList = tcmdlist_append(si->windowData.cmdList, pszRtf, 20, FALSE);
- ptszText = DoRtfToTags(pszRtf, si);
- p1 = _tcschr(ptszText, '\0');
+ TCHAR *ptszText = DoRtfToTags(pszRtf, si);
+ TCHAR *p1 = _tcschr(ptszText, '\0');
//remove trailing linebreaks
while ( p1 > ptszText && (*p1 == '\0' || *p1 == '\r' || *p1 == '\n')) {
diff --git a/plugins/Scriver/src/input.cpp b/plugins/Scriver/src/input.cpp index 836c9be876..5e6e97f2b0 100644 --- a/plugins/Scriver/src/input.cpp +++ b/plugins/Scriver/src/input.cpp @@ -118,292 +118,284 @@ void InputAreaContextMenu(HWND hwnd, WPARAM wParam, LPARAM lParam, HANDLE hConta //PostMessage(hwnd, WM_KEYUP, 0, 0 );
}
-int InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, CommonWindowData *windowData) {
-
+int InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, CommonWindowData *windowData)
+{
BOOL isShift = GetKeyState(VK_SHIFT) & 0x8000;
BOOL isAlt = GetKeyState(VK_MENU) & 0x8000;
BOOL isCtrl = (GetKeyState(VK_CONTROL) & 0x8000) && !isAlt;
- int action;
MSG amsg;
amsg.hwnd = hwnd;
amsg.message = msg;
amsg.wParam = wParam;
amsg.lParam = lParam;
- switch (action = CallService(MS_HOTKEY_CHECK, (WPARAM)&amsg, (LPARAM)"Messaging"))
- {
- case KB_PREV_TAB:
- SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATEPREV, 0, (LPARAM)GetParent(hwnd));
- return FALSE;
- case KB_NEXT_TAB:
- SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATENEXT, 0, (LPARAM)GetParent(hwnd));
- return FALSE;
- case KB_SWITCHSTATUSBAR:
- SendMessage(GetParent(GetParent(hwnd)), DM_SWITCHSTATUSBAR, 0, 0);
- return FALSE;
- case KB_SWITCHTITLEBAR:
- SendMessage(GetParent(GetParent(hwnd)), DM_SWITCHTITLEBAR, 0, 0);
- return FALSE;
- case KB_SWITCHINFOBAR:
- SendMessage(GetParent(GetParent(hwnd)), DM_SWITCHINFOBAR, 0, 0);
- return FALSE;
- case KB_SWITCHTOOLBAR:
- SendMessage(GetParent(GetParent(hwnd)), DM_SWITCHTOOLBAR, 0, 0);
- return FALSE;
- case KB_MINIMIZE:
- ShowWindow(GetParent(GetParent(hwnd)), SW_MINIMIZE);
- return FALSE;
- case KB_CLOSE:
- SendMessage(GetParent(hwnd), WM_CLOSE, 0, 0);
- return FALSE;
- case KB_CLEAR_LOG:
- SendMessage(GetParent(hwnd), DM_CLEARLOG, 0, 0);
- return FALSE;
- case KB_TAB1:
- case KB_TAB2:
- case KB_TAB3:
- case KB_TAB4:
- case KB_TAB5:
- case KB_TAB6:
- case KB_TAB7:
- case KB_TAB8:
- case KB_TAB9:
- SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATEBYINDEX, 0, action - KB_TAB1);
- return FALSE;
- case KB_SEND_ALL:
- PostMessage(GetParent(hwnd), WM_COMMAND, IDC_SENDALL, 0);
+ int action = CallService(MS_HOTKEY_CHECK, (WPARAM)&amsg, (LPARAM)"Messaging");
+
+ switch (action) {
+ case KB_PREV_TAB:
+ SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATEPREV, 0, (LPARAM)GetParent(hwnd));
+ return FALSE;
+ case KB_NEXT_TAB:
+ SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATENEXT, 0, (LPARAM)GetParent(hwnd));
+ return FALSE;
+ case KB_SWITCHSTATUSBAR:
+ SendMessage(GetParent(GetParent(hwnd)), DM_SWITCHSTATUSBAR, 0, 0);
+ return FALSE;
+ case KB_SWITCHTITLEBAR:
+ SendMessage(GetParent(GetParent(hwnd)), DM_SWITCHTITLEBAR, 0, 0);
+ return FALSE;
+ case KB_SWITCHINFOBAR:
+ SendMessage(GetParent(GetParent(hwnd)), DM_SWITCHINFOBAR, 0, 0);
+ return FALSE;
+ case KB_SWITCHTOOLBAR:
+ SendMessage(GetParent(GetParent(hwnd)), DM_SWITCHTOOLBAR, 0, 0);
+ return FALSE;
+ case KB_MINIMIZE:
+ ShowWindow(GetParent(GetParent(hwnd)), SW_MINIMIZE);
+ return FALSE;
+ case KB_CLOSE:
+ SendMessage(GetParent(hwnd), WM_CLOSE, 0, 0);
+ return FALSE;
+ case KB_CLEAR_LOG:
+ SendMessage(GetParent(hwnd), DM_CLEARLOG, 0, 0);
+ return FALSE;
+ case KB_TAB1:
+ case KB_TAB2:
+ case KB_TAB3:
+ case KB_TAB4:
+ case KB_TAB5:
+ case KB_TAB6:
+ case KB_TAB7:
+ case KB_TAB8:
+ case KB_TAB9:
+ SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATEBYINDEX, 0, action - KB_TAB1);
+ return FALSE;
+ case KB_SEND_ALL:
+ PostMessage(GetParent(hwnd), WM_COMMAND, IDC_SENDALL, 0);
+ return FALSE;
+ case KB_QUOTE:
+ PostMessage(GetParent(hwnd), WM_COMMAND, IDC_QUOTE, 0);
+ return FALSE;
+ case KB_PASTESEND:
+ if (SendMessage(hwnd, EM_CANPASTE, 0, 0)) {
+ SendMessage(hwnd, EM_PASTESPECIAL, CF_TEXT, 0);
+ PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0);
+ }
+ return FALSE;
+ }
+
+ switch (msg) {
+ case WM_KEYDOWN:
+ if (wParam >= '1' && wParam <='9' && isCtrl) {
+ SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATEBYINDEX, 0, wParam - '1');
+ return 0;
+ }
+
+ if (wParam == 'I' && isCtrl) // ctrl-i (italics)
return FALSE;
- case KB_QUOTE:
- PostMessage(GetParent(hwnd), WM_COMMAND, IDC_QUOTE, 0);
+
+ if (wParam == VK_SPACE && isCtrl) // ctrl-space (paste clean text)
return FALSE;
- case KB_PASTESEND:
- if (SendMessage(hwnd, EM_CANPASTE, 0, 0)) {
- SendMessage(hwnd, EM_PASTESPECIAL, CF_TEXT, 0);
- PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0);
- }
+
+ if (wParam == 'R' && isCtrl && isShift) { // ctrl-shift-r
+ SendMessage(GetParent(hwnd), DM_SWITCHRTL, 0, 0);
return FALSE;
- }
+ }
- switch (msg) {
- case WM_KEYDOWN:
- {
- if (wParam >= '1' && wParam <='9' && isCtrl) {
- SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATEBYINDEX, 0, wParam - '1');
- return 0;
- }
- /*
- if (wParam == 'A' && isCtrl) { //ctrl-a; select all
- SendMessage(hwnd, EM_SETSEL, 0, -1);
- return FALSE;
- }
- */
- if (wParam == 'I' && isCtrl) { // ctrl-i (italics)
- return FALSE;
- }
- if (wParam == VK_SPACE && isCtrl) // ctrl-space (paste clean text)
- return FALSE;
- if (wParam == 'R' && isCtrl && isShift) { // ctrl-shift-r
- SendMessage(GetParent(hwnd), DM_SWITCHRTL, 0, 0);
- return FALSE;
- }
- if ((wParam == VK_UP || wParam == VK_DOWN) && isCtrl && !DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_AUTOCLOSE, SRMSGDEFSET_AUTOCLOSE)) {
- if (windowData->cmdList) {
- TCmdList *cmdListNew = NULL;
- if (wParam == VK_UP) {
- if (windowData->cmdListCurrent == NULL) {
+ if ((wParam == VK_UP || wParam == VK_DOWN) && isCtrl && !DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_AUTOCLOSE, SRMSGDEFSET_AUTOCLOSE)) {
+ if (windowData->cmdList) {
+ TCmdList *cmdListNew = NULL;
+ if (wParam == VK_UP) {
+ if (windowData->cmdListCurrent == NULL) {
+ cmdListNew = tcmdlist_last(windowData->cmdList);
+ while (cmdListNew != NULL && cmdListNew->temporary) {
+ windowData->cmdList = tcmdlist_remove(windowData->cmdList, cmdListNew);
cmdListNew = tcmdlist_last(windowData->cmdList);
- while (cmdListNew != NULL && cmdListNew->temporary) {
- windowData->cmdList = tcmdlist_remove(windowData->cmdList, cmdListNew);
- cmdListNew = tcmdlist_last(windowData->cmdList);
- }
- if (cmdListNew != NULL) {
- char *textBuffer;
- if (windowData->flags & CWDF_RTF_INPUT) {
- textBuffer = GetRichTextRTF(hwnd);
- } else {
- textBuffer = GetRichTextEncoded(hwnd, windowData->codePage);
- }
- if (textBuffer != NULL) {
- windowData->cmdList = tcmdlist_append(windowData->cmdList, textBuffer, 20, TRUE);
- mir_free(textBuffer);
- }
- }
- } else if (windowData->cmdListCurrent->prev != NULL) {
- cmdListNew = windowData->cmdListCurrent->prev;
}
- } else {
- if (windowData->cmdListCurrent != NULL) {
- if (windowData->cmdListCurrent->next != NULL) {
- cmdListNew = windowData->cmdListCurrent->next;
- } else if (!windowData->cmdListCurrent->temporary) {
- SetWindowText(hwnd, _T(""));
+ if (cmdListNew != NULL) {
+ char *textBuffer;
+ if (windowData->flags & CWDF_RTF_INPUT) {
+ textBuffer = GetRichTextRTF(hwnd);
+ } else {
+ textBuffer = GetRichTextEncoded(hwnd, windowData->codePage);
+ }
+ if (textBuffer != NULL) {
+ windowData->cmdList = tcmdlist_append(windowData->cmdList, textBuffer, 20, TRUE);
+ mir_free(textBuffer);
}
}
+ } else if (windowData->cmdListCurrent->prev != NULL) {
+ cmdListNew = windowData->cmdListCurrent->prev;
}
- if (cmdListNew != NULL) {
- int iLen;
- SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
- if (windowData->flags & CWDF_RTF_INPUT) {
- iLen = SetRichTextRTF(hwnd, cmdListNew->szCmd);
- } else {
- iLen = SetRichTextEncoded(hwnd, cmdListNew->szCmd, windowData->codePage);
+ } else {
+ if (windowData->cmdListCurrent != NULL) {
+ if (windowData->cmdListCurrent->next != NULL) {
+ cmdListNew = windowData->cmdListCurrent->next;
+ } else if (!windowData->cmdListCurrent->temporary) {
+ SetWindowText(hwnd, _T(""));
}
- SendMessage(hwnd, EM_SCROLLCARET, 0,0);
- SendMessage(hwnd, WM_SETREDRAW, TRUE, 0);
- RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE);
- SendMessage(hwnd, EM_SETSEL, iLen, iLen);
- windowData->cmdListCurrent = cmdListNew;
}
}
- return FALSE;
+ if (cmdListNew != NULL) {
+ int iLen;
+ SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
+ if (windowData->flags & CWDF_RTF_INPUT)
+ iLen = SetRichTextRTF(hwnd, cmdListNew->szCmd);
+ else
+ iLen = SetRichTextEncoded(hwnd, cmdListNew->szCmd, windowData->codePage);
+
+ SendMessage(hwnd, EM_SCROLLCARET, 0,0);
+ SendMessage(hwnd, WM_SETREDRAW, TRUE, 0);
+ RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE);
+ SendMessage(hwnd, EM_SETSEL, iLen, iLen);
+ windowData->cmdListCurrent = cmdListNew;
+ }
}
+ return FALSE;
}
break;
- case WM_SYSKEYDOWN:
- {
- if ((wParam == VK_LEFT) && isAlt) {
- SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATEPREV, 0, (LPARAM)GetParent(hwnd));
- return 0;
- }
- if ((wParam == VK_RIGHT) && isAlt) {
- SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATENEXT, 0, (LPARAM)GetParent(hwnd));
- return 0;
- }
+
+ case WM_SYSKEYDOWN:
+ if ((wParam == VK_LEFT) && isAlt) {
+ SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATEPREV, 0, (LPARAM)GetParent(hwnd));
+ return 0;
+ }
+ if ((wParam == VK_RIGHT) && isAlt) {
+ SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATENEXT, 0, (LPARAM)GetParent(hwnd));
+ return 0;
}
break;
- case WM_SYSKEYUP:
+ case WM_SYSKEYUP:
{
- if ((wParam == VK_LEFT) && isAlt) {
+ if ((wParam == VK_LEFT) && isAlt)
return 0;
- }
- if ((wParam == VK_RIGHT) && isAlt) {
+
+ if ((wParam == VK_RIGHT) && isAlt)
return 0;
- }
}
break;
-
}
return -1;
-
}
void RegisterKeyBindings() {
- int i;
+
char strDesc[64], strName[64];
- HOTKEYDESC desc;
- ZeroMemory(&desc, sizeof(desc));
- desc.cbSize = sizeof(desc);
+ HOTKEYDESC desc = {sizeof(desc) };
desc.pszSection = LPGEN("Messaging");
desc.pszName = "Scriver/Nav/Previous Tab";
desc.pszDescription = LPGEN("Navigate: Previous Tab");
desc.lParam = KB_PREV_TAB;
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, VK_TAB);
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_PRIOR);
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
desc.DefHotKey = HOTKEYCODE(HOTKEYF_ALT, VK_LEFT);
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
desc.pszName = "Scriver/Nav/Next Tab";
desc.pszDescription = LPGEN("Navigate: Next Tab");
desc.lParam = KB_NEXT_TAB;
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_TAB);
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_NEXT);
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
desc.DefHotKey = HOTKEYCODE(HOTKEYF_ALT, VK_RIGHT);
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
+
desc.pszName = strName;
desc.pszDescription = strDesc;
- for (i = 0; i < 9; i++) {
+ for (int i = 0; i < 9; i++) {
mir_snprintf(strName, SIZEOF(strName), "Scriver/Nav/Tab %d", i + 1);
mir_snprintf(strDesc, SIZEOF(strDesc), LPGEN("Navigate: Tab %d"), i + 1);
desc.lParam = KB_TAB1 + i;
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, '1' + i);
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
}
desc.pszName = "Scriver/Wnd/Toggle Statusbar";
desc.pszDescription = LPGEN("Window: Toggle Statusbar");
desc.lParam = KB_SWITCHSTATUSBAR;
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'S');
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
desc.pszName = "Scriver/Wnd/Toggle Titlebar";
desc.pszDescription = LPGEN("Window: Toggle Titlebar");
desc.lParam = KB_SWITCHTITLEBAR;
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'M');
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
desc.pszName = "Scriver/Wnd/Toggle Toolbar";
desc.pszDescription = LPGEN("Window: Toggle Toolbar");
desc.lParam = KB_SWITCHTOOLBAR;
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'T');
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
desc.pszName = "Scriver/Wnd/Toggle Infobar";
desc.pszDescription = LPGEN("Window: Toggle Infobar");
desc.lParam = KB_SWITCHINFOBAR;
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'N');
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
desc.pszName = "Scriver/Wnd/Clear Log";
desc.pszDescription = LPGEN("Window: Clear Log");
desc.lParam = KB_CLEAR_LOG;
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, 'L');
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
desc.pszName = "Scriver/Wnd/Minimize";
desc.pszDescription = LPGEN("Window: Minimize");
desc.lParam = KB_MINIMIZE;
desc.DefHotKey = HOTKEYCODE(HOTKEYF_SHIFT, VK_ESCAPE);
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
desc.pszName = "Scriver/Wnd/Close Tab";
desc.pszDescription = LPGEN("Window: Close Tab");
desc.lParam = KB_CLOSE;
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_F4);
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, 'W');
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
desc.pszName = "Scriver/Action/Quote";
desc.pszDescription = LPGEN("Action: Quote");
desc.lParam = KB_QUOTE;
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, 'Q');
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
desc.pszName = "Scriver/Action/Send All";
desc.pszDescription = LPGEN("Action: Send to All");
desc.lParam = KB_SEND_ALL;
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL | HOTKEYF_SHIFT, VK_RETURN);
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
desc.pszName = "Scriver/Action/PasteSend";
desc.pszDescription = LPGEN("Action: Paste & Send");
desc.lParam = KB_PASTESEND;
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL | HOTKEYF_SHIFT, VK_INSERT);
- Hotkey_Register( &desc);
+ Hotkey_Register(&desc);
}
-BOOL HandleLinkClick(HINSTANCE hInstance, HWND hwndDlg, HWND hwndFocus, ENLINK *lParam) {
- TEXTRANGE tr;
+BOOL HandleLinkClick(HINSTANCE hInstance, HWND hwndDlg, HWND hwndFocus, ENLINK *lParam)
+{
CHARRANGE sel;
- char* pszUrl;
- BOOL bOpenLink = TRUE;
- SendMessage(lParam->nmhdr.hwndFrom, EM_EXGETSEL, 0, (LPARAM) & sel);
+ SendMessage(lParam->nmhdr.hwndFrom, EM_EXGETSEL, 0, (LPARAM)&sel);
if (sel.cpMin != sel.cpMax)
return FALSE;
+
+ TEXTRANGE tr;
tr.chrg = lParam->chrg;
tr.lpstrText = (LPWSTR)mir_alloc(sizeof(TCHAR)*(tr.chrg.cpMax - tr.chrg.cpMin + 8));
- SendMessage(lParam->nmhdr.hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM) & tr);
+ SendMessage(lParam->nmhdr.hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
if (_tcschr(tr.lpstrText, _T('@')) != NULL && _tcschr(tr.lpstrText, _T(':')) == NULL && _tcschr(tr.lpstrText, _T('/')) == NULL) {
MoveMemory(tr.lpstrText + sizeof(TCHAR) * 7, tr.lpstrText, sizeof(TCHAR)*(tr.chrg.cpMax - tr.chrg.cpMin + 1));
CopyMemory(tr.lpstrText, _T("mailto:"), sizeof(TCHAR) * 7);
}
- pszUrl = t2a( (const TCHAR *)tr.lpstrText );
- if (((ENLINK *) lParam)->msg == WM_RBUTTONDOWN) {
+
+ BOOL bOpenLink = TRUE;
+
+ if (((ENLINK*)lParam)->msg == WM_RBUTTONDOWN) {
HMENU hMenu, hSubMenu;
POINT pt;
bOpenLink = FALSE;
@@ -417,27 +409,25 @@ BOOL HandleLinkClick(HINSTANCE hInstance, HWND hwndDlg, HWND hwndFocus, ENLINK * case IDM_OPENLINK:
bOpenLink = TRUE;
break;
+
case IDM_COPYLINK:
- {
- HGLOBAL hData;
- if (!OpenClipboard(hwndDlg))
- break;
- EmptyClipboard();
- hData = GlobalAlloc(GMEM_MOVEABLE, sizeof(TCHAR)*(lstrlen(tr.lpstrText) + 1));
- lstrcpy((LPWSTR)GlobalLock(hData), tr.lpstrText);
- GlobalUnlock(hData);
- SetClipboardData(CF_UNICODETEXT, hData);
- CloseClipboard();
+ HGLOBAL hData;
+ if (!OpenClipboard(hwndDlg))
break;
- }
+ EmptyClipboard();
+ hData = GlobalAlloc(GMEM_MOVEABLE, sizeof(TCHAR)*(lstrlen(tr.lpstrText) + 1));
+ lstrcpy((LPWSTR)GlobalLock(hData), tr.lpstrText);
+ GlobalUnlock(hData);
+ SetClipboardData(CF_UNICODETEXT, hData);
+ CloseClipboard();
+ break;
}
DestroyMenu(hMenu);
}
- if (bOpenLink) {
- CallService(MS_UTILS_OPENURL, 1, (LPARAM) pszUrl);
- }
+ if (bOpenLink)
+ CallService(MS_UTILS_OPENURL, OUF_TCHAR | OUF_NEWWINDOW, (LPARAM)tr.lpstrText);
+
SetFocus(hwndFocus);
mir_free(tr.lpstrText);
- mir_free(pszUrl);
return TRUE;
}
diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp index d72947f720..46bbc41530 100644 --- a/plugins/Scriver/src/utils.cpp +++ b/plugins/Scriver/src/utils.cpp @@ -220,18 +220,14 @@ static DWORD CALLBACK RichTextStreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, char* GetRichTextRTF(HWND hwnd)
{
- EDITSTREAM stream;
- char* pszText = NULL;
- DWORD dwFlags;
-
if (hwnd == 0)
return NULL;
- ZeroMemory(&stream, sizeof(stream));
+ char* pszText = NULL;
+ EDITSTREAM stream = { 0 };
stream.pfnCallback = RichTextStreamCallback;
- stream.dwCookie = (DWORD_PTR) &pszText; // pass pointer to pointer
- dwFlags = SF_RTFNOOBJS | SFF_PLAINRTF | SF_USECODEPAGE | (CP_UTF8 << 16);
- SendMessage(hwnd, EM_STREAMOUT, dwFlags, (LPARAM) & stream);
+ stream.dwCookie = (DWORD_PTR)&pszText; // pass pointer to pointer
+ SendMessage(hwnd, EM_STREAMOUT, SF_RTFNOOBJS | SFF_PLAINRTF | SF_USECODEPAGE | (CP_UTF8 << 16), (LPARAM)&stream);
return pszText; // pszText contains the text
}
diff --git a/plugins/SmileyAdd/src/richcall.cpp b/plugins/SmileyAdd/src/richcall.cpp index 2127211b6e..afee5fca8f 100644 --- a/plugins/SmileyAdd/src/richcall.cpp +++ b/plugins/SmileyAdd/src/richcall.cpp @@ -199,19 +199,15 @@ static void SmileyToTextCutRest(RichEditData* rdt) RedrawWindow(rdt->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
}
-
static LRESULT CALLBACK RichEditSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
RichEditData* rdt = g_RichEditList.find((RichEditData*)&hwnd);
- if (rdt == NULL) return 0;
+ if (rdt == NULL)
+ return 0;
CHARRANGE sel;
switch(uMsg) {
- case WM_DESTROY:
- CloseRichCallback(hwnd);
- break;
-
case WM_COPY:
case WM_CUT:
SmileyToTextCutPrep(rdt);
@@ -336,17 +332,6 @@ static LRESULT CALLBACK RichEditSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LP return result;
}
-void CloseRichCallback(HWND hwnd)
-{
- int ind = g_RichEditList.getIndex((RichEditData*)&hwnd);
- if ( ind != -1 ) {
- RichEditData* rdt = g_RichEditList[ind];
- if (rdt->hToolTip) DestroyWindow(rdt->hToolTip);
- delete rdt;
- g_RichEditList.remove(ind);
- }
-}
-
bool SetRichCallback(HWND hwnd, HANDLE hContact, bool subany, bool subnew)
{
RichEditData* rdt = g_RichEditList.find((RichEditData*)&hwnd);
@@ -379,6 +364,22 @@ bool SetRichCallback(HWND hwnd, HANDLE hContact, bool subany, bool subnew) return true;
}
+void CloseRichCallback(HWND hwnd)
+{
+ int ind = g_RichEditList.getIndex((RichEditData*)&hwnd);
+ if (ind == -1 )
+ return;
+
+ RichEditData* rdt = g_RichEditList[ind];
+ if (rdt->hToolTip)
+ DestroyWindow(rdt->hToolTip);
+ delete rdt;
+ g_RichEditList.remove(ind);
+ mir_unsubclassWindow(hwnd, RichEditSubclass);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
static LRESULT CALLBACK RichEditOwnerSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
RichEditOwnerData* rdto = g_RichEditOwnerList.find((RichEditOwnerData*)&hwnd);
@@ -398,22 +399,12 @@ static LRESULT CALLBACK RichEditOwnerSubclass(HWND hwnd, UINT uMsg, WPARAM wPara break;
case WM_DESTROY:
- if ( !Miranda_Terminated()) {
- CHARRANGE sel = allsel;
- if (rdto->hwndInput)
- ReplaceSmileysWithText(rdto->hwndInput, sel, false);
- if (rdto->hwndLog)
- ReplaceSmileysWithText(rdto->hwndLog, sel, false);
- }
-
RichEditData* rdt = g_RichEditList.find((RichEditData*)&rdto->hwndInput);
if (rdt && (!rdt->inputarea || opt.InputSmileys)) {
CHARRANGE sel = allsel;
rdt->dontReplace = true;
ReplaceSmileysWithText(rdt->hwnd, sel, false);
}
-
- CloseRichOwnerCallback(hwnd);
break;
}
@@ -434,22 +425,6 @@ static LRESULT CALLBACK RichEditOwnerSubclass(HWND hwnd, UINT uMsg, WPARAM wPara return result;
}
-void CloseRichOwnerCallback(HWND hwnd)
-{
- int ind = g_RichEditOwnerList.getIndex((RichEditOwnerData*)&hwnd);
- if (ind == -1)
- return;
-
- RichEditOwnerData* rdto = g_RichEditOwnerList[ind];
- if (rdto) {
- CloseRichCallback(rdto->hwndInput);
- CloseRichCallback(rdto->hwndLog);
-
- delete rdto;
- g_RichEditOwnerList.remove(ind);
- }
-}
-
void SetRichOwnerCallback(HWND hwnd, HWND hwndInput, HWND hwndLog)
{
RichEditOwnerData* rdto = g_RichEditOwnerList.find((RichEditOwnerData*)&hwnd);
@@ -471,6 +446,22 @@ void SetRichOwnerCallback(HWND hwnd, HWND hwndInput, HWND hwndLog) }
}
+void CloseRichOwnerCallback(HWND hwnd)
+{
+ int ind = g_RichEditOwnerList.getIndex((RichEditOwnerData*)&hwnd);
+ if (ind == -1)
+ return;
+
+ RichEditOwnerData* rdto = g_RichEditOwnerList[ind];
+ CloseRichCallback(rdto->hwndInput);
+ CloseRichCallback(rdto->hwndLog);
+
+ delete rdto;
+ g_RichEditOwnerList.remove(ind);
+
+ mir_unsubclassWindow(hwnd, RichEditOwnerSubclass);
+}
+
void ProcessAllInputAreas(bool restoreText)
{
for (int i=g_RichEditList.getCount(); i--; ) {
diff --git a/plugins/SpellChecker/src/utils.cpp b/plugins/SpellChecker/src/utils.cpp index 77d31a381f..55abea5848 100644 --- a/plugins/SpellChecker/src/utils.cpp +++ b/plugins/SpellChecker/src/utils.cpp @@ -992,6 +992,7 @@ int RemoveContactTextBox(HWND hwnd) KillTimer(hwnd, TIMER_ID); + mir_unsubclassWindow(hwnd, EditProc); dialogs.erase(hwnd); if (dlg->hwnd_owner != NULL) dialogs.erase(dlg->hwnd_owner); diff --git a/src/mir_core/mir_core.def b/src/mir_core/mir_core.def index c124c559e5..042b5bb9d9 100644 --- a/src/mir_core/mir_core.def +++ b/src/mir_core/mir_core.def @@ -140,3 +140,4 @@ mir_subclassWindow @137 mir_callNextSubclass @138
KillModuleSubclassing @139
mir_wstrndup @140
+mir_unsubclassWindow @141
diff --git a/src/mir_core/subclass.cpp b/src/mir_core/subclass.cpp index 183556402d..a2e7530f0e 100644 --- a/src/mir_core/subclass.cpp +++ b/src/mir_core/subclass.cpp @@ -96,8 +96,37 @@ MIR_CORE_DLL(void) mir_subclassWindowFull(HWND hWnd, WNDPROC wndProc, WNDPROC ol /////////////////////////////////////////////////////////////////////////////////////////
-MIR_CORE_DLL(void) mir_unsubclassWindow(HWND hWnd)
+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++)
+ p->m_hooks[i-1] = p->m_hooks[i];
+ p->m_iHooks--;
+
+ // emulate window destruction
+ saveProc(p->m_hWnd, WM_DESTROY, 0, 0);
+ saveProc(p->m_hWnd, WM_NCDESTROY, 0, 0);
+}
+
+MIR_CORE_DLL(void) mir_unsubclassWindow(HWND hWnd, WNDPROC wndProc)
+{
+ MSubclassData *p = arSubclass.find((MSubclassData*)&hWnd);
+ if (p == NULL)
+ return;
+
+ for (int i=0; i < p->m_iHooks; i++) {
+ if (p->m_hooks[i] == wndProc) {
+ removeHook(p, i);
+ i--;
+ }
+ }
+
+ if (p->m_iHooks == 0) {
+ arSubclass.remove(p);
+ delete p;
+ }
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -105,60 +134,49 @@ MIR_CORE_DLL(void) mir_unsubclassWindow(HWND hWnd) 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=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);
- LONG res = 0;
- __try {
- res = saveProc(hWnd, uMsg, wParam, lParam);
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- }
- return res;
- }
-
- return p->m_origWndProc(hWnd, uMsg, wParam, lParam);
- }
- }
-
- // invalid / closed hook
- return 0;
+ if (p == NULL)
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
+
+ for (int i=p->m_iHooks-1; i >= 0; i--) {
+ if (p->m_hooks[i] != wndProc)
+ continue;
+
+ // next hook exists, 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)
+ return p->m_origWndProc(hWnd, uMsg, wParam, lParam);
+
+ WNDPROC saveProc = p->m_origWndProc;
+ arSubclass.remove(p);
+ delete p;
+
+ SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)saveProc);
+ return saveProc(hWnd, uMsg, wParam, lParam);
}
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
+
+ // invalid / closed hook
+ return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
MIR_CORE_DLL(void) KillModuleSubclassing(HMODULE hInst)
{
- for (int i=0; i < arSubclass.getCount(); i++) {
+ for (int i=arSubclass.getCount()-1; i >= 0; i--) {
MSubclassData *p = arSubclass[i];
- for (int j=0; j < p->m_iHooks; ) {
+ for (int j=0; j < p->m_iHooks; j++) {
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);
+ removeHook(p, j);
+ j--;
}
- else j++;
+ }
+
+ if (p->m_iHooks == 0) {
+ arSubclass.remove(p);
+ delete p;
}
}
}
|