diff options
author | George Hazan <ghazan@miranda.im> | 2017-02-21 21:22:45 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-02-21 21:30:33 +0300 |
commit | 6694c3eebbc11d776a51039c74b75e5f2539c0d8 (patch) | |
tree | 4486cc2b0e46d74691a83f46a74eaa227e7b34a3 /src/mir_app | |
parent | 2cf889e14cb73a24f0ab1a5cb5e2a5d09a98c895 (diff) |
CSrmmBaseDialog - basic class for SRMM windows & chats
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/res/resource.rc | 3 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 6 | ||||
-rw-r--r-- | src/mir_app/src/resource.h | 5 | ||||
-rw-r--r-- | src/mir_app/src/srmm_base.cpp | 104 | ||||
-rw-r--r-- | src/mir_app/src/srmm_statusicon.cpp | 8 |
5 files changed, 120 insertions, 6 deletions
diff --git a/src/mir_app/res/resource.rc b/src/mir_app/res/resource.rc index 59797591f5..28b3100092 100644 --- a/src/mir_app/res/resource.rc +++ b/src/mir_app/res/resource.rc @@ -1278,8 +1278,7 @@ BEGIN END
POPUP "LogLink"
BEGIN
- MENUITEM "Open in &new window", IDM_OPENNEW
- MENUITEM "&Open in existing window", IDM_OPENEXISTING
+ MENUITEM "&Open link", IDM_OPENLINK
MENUITEM "&Copy link", IDM_COPYLINK
END
END
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index b60684fb88..fee7aec60a 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -399,3 +399,9 @@ Chat_UnescapeTags @399 NONAME ProtoGetAvatarFormatByMimeType @400
ProtoGetAvatarMimeType @401
?set_uin@DB_AUTH_BLOB@@QEAAXK@Z @402 NONAME
+??0CSrmmBaseDialog@@IEAA@PEAUHINSTANCE__@@H@Z @403 NONAME
+??0CSrmmBaseDialog@@QEAA@AEBV0@@Z @404 NONAME
+??1CSrmmBaseDialog@@UEAA@XZ @405 NONAME
+??4CSrmmBaseDialog@@QEAAAEAV0@AEBV0@@Z @406 NONAME
+??_7CSrmmBaseDialog@@6B@ @407 NONAME
+?DlgProc@CSrmmBaseDialog@@MEAA_JI_K_J@Z @408 NONAME
diff --git a/src/mir_app/src/resource.h b/src/mir_app/src/resource.h index 95d7111a7b..30d9aed425 100644 --- a/src/mir_app/src/resource.h +++ b/src/mir_app/src/resource.h @@ -589,9 +589,8 @@ #define IDM_COPYALL 40011
#define IDM_SELECTALL 40012
#define IDM_CLEAR 40013
-#define IDM_OPENNEW 40014
-#define IDM_OPENEXISTING 40015
-#define IDM_COPYLINK 40016
+#define IDM_OPENLINK 40014
+#define IDM_COPYLINK 40015
#define POPUP_HIDEMIRANDA 40017
#define ID_CANCELCHANGE 40018
#define POPUP_GROUPSHOWOFFLINE 40019
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp new file mode 100644 index 0000000000..b28549b6c0 --- /dev/null +++ b/src/mir_app/src/srmm_base.cpp @@ -0,0 +1,104 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (ñ) 2012-17 Miranda NG project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "stdafx.h" + +extern HCURSOR g_hCurHyperlinkHand; + +CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog) : + CDlgBase(hInst, idDialog), + m_pLog(NULL), + m_pEntry(NULL) +{ +} + +INT_PTR CSrmmBaseDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) +{ + CHARRANGE sel; + + if (msg == WM_NOTIFY && m_pLog != nullptr) { + LPNMHDR hdr = (LPNMHDR)lParam; + if (hdr->hwndFrom == m_pLog->GetHwnd() && hdr->code == EN_LINK) { + ENLINK *pLink = (ENLINK*)lParam; + switch (pLink->msg) { + case WM_SETCURSOR: + SetCursor(g_hCurHyperlinkHand); + SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE); + return TRUE; + + case WM_RBUTTONDOWN: + case WM_LBUTTONUP: + case WM_LBUTTONDBLCLK: + m_pLog->SendMsg(EM_EXGETSEL, 0, (LPARAM)&sel); + if (sel.cpMin != sel.cpMax) + break; + + CMStringW wszText(' ', pLink->chrg.cpMax - pLink->chrg.cpMin + 1); + { + TEXTRANGE tr; + tr.chrg = pLink->chrg; + tr.lpstrText = wszText.GetBuffer(); + m_pLog->SendMsg(EM_GETTEXTRANGE, 0, (LPARAM)&tr); + if (wcschr(tr.lpstrText, '@') != NULL && wcschr(tr.lpstrText, ':') == NULL && wcschr(tr.lpstrText, '/') == NULL) + wszText.Insert(0, L"mailto:"); + } + + if (pLink->msg == WM_RBUTTONDOWN) { + HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT)); + HMENU hSubMenu = GetSubMenu(hMenu, 6); + TranslateMenu(hSubMenu); + + POINT pt = { GET_X_LPARAM(pLink->lParam), GET_Y_LPARAM(pLink->lParam) }; + ClientToScreen(((NMHDR *)lParam)->hwndFrom, &pt); + + switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_hwnd, NULL)) { + case IDM_OPENLINK: + Utils_OpenUrlW(wszText); + break; + + case IDM_COPYLINK: + if (OpenClipboard(m_hwnd)) { + EmptyClipboard(); + HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, (wszText.GetLength()+1) * sizeof(wchar_t)); + mir_wstrcpy((wchar_t*)GlobalLock(hData), wszText); + GlobalUnlock(hData); + SetClipboardData(CF_UNICODETEXT, hData); + CloseClipboard(); + } + break; + } + + DestroyMenu(hMenu); + SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE); + return TRUE; + } + + Utils_OpenUrlW(wszText); + if (m_pEntry != nullptr) + SetFocus(m_pEntry->GetHwnd()); + } + } + } + + return CDlgBase::DlgProc(msg, wParam, lParam); +} diff --git a/src/mir_app/src/srmm_statusicon.cpp b/src/mir_app/src/srmm_statusicon.cpp index 050bc25e43..bbd7202582 100644 --- a/src/mir_app/src/srmm_statusicon.cpp +++ b/src/mir_app/src/srmm_statusicon.cpp @@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
+HCURSOR g_hCurHyperlinkHand;
+
void LoadSrmmToolbarModule();
void UnloadSrmmToolbarModule();
@@ -205,6 +207,8 @@ void KillModuleSrmmIcons(int _hLang) int LoadSrmmModule()
{
+ g_hCurHyperlinkHand = LoadCursor(NULL, IDC_HAND);
+
LoadSrmmToolbarModule();
hHookIconsChanged = CreateHookableEvent(ME_MSG_ICONSCHANGED);
@@ -216,6 +220,8 @@ void UnloadSrmmModule() arIcons.destroy();
NotifyEventHooks(hHookIconsChanged, NULL, NULL);
DestroyHookableEvent(hHookIconsChanged);
-
+
+ DestroyCursor(g_hCurHyperlinkHand);
+
UnloadSrmmToolbarModule();
}
|