diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-09 23:27:40 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-09 23:27:40 +0300 |
commit | 063a61cf745e1c51f4c9791d03832740f7dc0347 (patch) | |
tree | 960bae1ec8b3869c561cf95e9717c01dd08c735b /src | |
parent | f3ff9ad5341bb0b0a0453e61a2d419e8c02f14b0 (diff) |
- GCSessionInfoBase fields iWidth and iHeight moved to StdMSg;
- CHAT_MANAGER methods DoEventHook & DoEventHookAsync removed from CHAT_API;
- CSrmmBaseDialog::DoEventHook introduced instead
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdmsg/src/chat_window.cpp | 49 | ||||
-rw-r--r-- | src/core/stdmsg/src/stdafx.h | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat.h | 1 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 31 | ||||
-rw-r--r-- | src/mir_app/src/chat_tools.cpp | 41 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/srmm_base.cpp | 127 |
8 files changed, 115 insertions, 138 deletions
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 00f630271b..5e98c0f0f6 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -689,7 +689,7 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR return mir_callNextSubclass(hwnd, LogSubclassProc, msg, wParam, lParam); } -static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK CChatRoomDlg::NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { SESSION_INFO *si = (SESSION_INFO*)GetWindowLongPtr(hwnd, GWLP_USERDATA); @@ -781,11 +781,11 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, break; case ID_MESS: - pci->DoEventHookAsync(GetParent(hwnd), si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui, nullptr, 0); + si->pDlg->DoEventHook(GC_USER_PRIVMESS, ui, nullptr, 0); break; default: - pci->DoEventHookAsync(GetParent(hwnd), si->ptszID, si->pszModule, GC_USER_NICKLISTMENU, ui, nullptr, uID); + si->pDlg->DoEventHook(GC_USER_NICKLISTMENU, ui, nullptr, uID); break; } DestroyGCMenu(&hMenu, 1); @@ -1047,7 +1047,7 @@ void CChatRoomDlg::OnClick_NickList(CCtrlButton *pButton) void CChatRoomDlg::OnClick_Options(CCtrlButton *pButton) { if (pButton->Enabled()) - pci->DoEventHookAsync(m_hwnd, m_si->ptszID, m_si->pszModule, GC_USER_CHANMGR, nullptr, nullptr, 0); + DoEventHook(GC_USER_CHANMGR, nullptr, nullptr, 0); } void CChatRoomDlg::OnClick_Ok(CCtrlButton *pButton) @@ -1078,7 +1078,7 @@ void CChatRoomDlg::OnClick_Ok(CCtrlButton *pButton) EnableWindow(m_btnOk.GetHwnd(), FALSE); - pci->DoEventHookAsync(m_hwnd, m_si->ptszID, m_si->pszModule, GC_USER_MESSAGE, nullptr, ptszText, 0); + DoEventHook(GC_USER_MESSAGE, nullptr, ptszText, 0); SetFocus(m_message.GetHwnd()); } @@ -1101,7 +1101,7 @@ void CChatRoomDlg::OnListDblclick(CCtrlListBox*) SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)buf.c_str()); PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0); } - else pci->DoEventHookAsync(m_hwnd, m_si->ptszID, m_si->pszModule, GC_USER_PRIVMESS, ui, nullptr, 0); + else DoEventHook(GC_USER_PRIVMESS, ui, nullptr, 0); } void CChatRoomDlg::OnSplitterX(CSplitter *pSplitter) @@ -1321,10 +1321,10 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) if (!IsIconic(m_hwnd)) { SendMessage(m_hwndStatus, WM_SIZE, 0, 0); - BOOL bControl = (BOOL)db_get_b(0, CHAT_MODULE, "ShowTopButtons", 1); - BOOL bFormat = (BOOL)db_get_b(0, CHAT_MODULE, "ShowFormatButtons", 1); - BOOL bSend = (BOOL)db_get_b(0, CHAT_MODULE, "ShowSend", 0); - BOOL bNick = m_si->iType != GCW_SERVER && m_bNicklistEnabled; + bool bSend = db_get_b(0, CHAT_MODULE, "ShowSend", 0) != 0; + bool bFormat = db_get_b(0, CHAT_MODULE, "ShowFormatButtons", 1) != 0; + bool bControl = db_get_b(0, CHAT_MODULE, "ShowTopButtons", 1) != 0; + bool bNick = m_si->iType != GCW_SERVER && m_bNicklistEnabled; ShowWindow(m_btnBold.GetHwnd(), bFormat ? SW_SHOW : SW_HIDE); ShowWindow(m_btnItalic.GetHwnd(), bFormat ? SW_SHOW : SW_HIDE); @@ -1344,13 +1344,13 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) ShowWindow(m_nickList.GetHwnd(), SW_HIDE); if (m_si->iType == GCW_SERVER) { - EnableWindow(m_btnNickList.GetHwnd(), FALSE); - EnableWindow(m_btnFilter.GetHwnd(), FALSE); - EnableWindow(m_btnChannelMgr.GetHwnd(), FALSE); + EnableWindow(m_btnNickList.GetHwnd(), false); + EnableWindow(m_btnFilter.GetHwnd(), false); + EnableWindow(m_btnChannelMgr.GetHwnd(), false); } else { - EnableWindow(m_btnNickList.GetHwnd(), TRUE); - EnableWindow(m_btnFilter.GetHwnd(), TRUE); + EnableWindow(m_btnNickList.GetHwnd(), true); + EnableWindow(m_btnFilter.GetHwnd(), true); if (m_si->iType == GCW_CHATROOM) EnableWindow(m_btnChannelMgr.GetHwnd(), pci->MM_FindModule(m_si->pszModule)->bChanMgr); } @@ -1358,7 +1358,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) CSrmmBaseDialog::DlgProc(uMsg, wParam, lParam); // call built-in resizer SetButtonsPos(m_hwnd, true); - InvalidateRect(m_hwndStatus, nullptr, TRUE); + InvalidateRect(m_hwndStatus, nullptr, true); RedrawWindow(m_message.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); RedrawWindow(m_btnOk.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); SaveWindowPosition(false); @@ -1549,21 +1549,6 @@ LABEL_SHOWWINDOW: } break; - case GC_FIREHOOK: - if (lParam) { - GCHOOK *gch = (GCHOOK *)lParam; - NotifyEventHooks(pci->hSendEvent, 0, lParam); - if (gch->pDest) { - mir_free((void*)gch->pDest->ptszID); - mir_free((void*)gch->pDest->pszModule); - mir_free(gch->pDest); - } - mir_free((void*)gch->ptszText); - mir_free((void*)gch->ptszUID); - mir_free(gch); - } - break; - case GC_CLOSEWINDOW: if (g_Settings.bTabsEnable) SendMessage(GetParent(m_hwndParent), GC_REMOVETAB, 0, (LPARAM)this); @@ -1725,7 +1710,7 @@ LABEL_SHOWWINDOW: default: PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0); - pci->DoEventHookAsync(m_hwnd, m_si->ptszID, m_si->pszModule, GC_USER_LOGMENU, nullptr, nullptr, uID); + DoEventHook(GC_USER_LOGMENU, nullptr, nullptr, uID); break; } DestroyGCMenu(&hMenu, 5); diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index b18ac615ae..5821959568 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -92,6 +92,7 @@ struct MODULEINFO : public GCModuleInfoBase struct SESSION_INFO : public GCSessionInfoBase
{
int iX, iY;
+ int iWidth, iHeight;
};
struct LOGSTREAMDATA : public GCLogStreamDataBase {};
@@ -174,6 +175,7 @@ class CChatRoomDlg : public CSrmmBaseDialog friend struct CTabbedWindow;
static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
HWND m_hwndStatus;
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index fbfc8872f6..d081407ac6 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -109,7 +109,6 @@ int GetRichTextLength(HWND hwnd); bool IsHighlighted(SESSION_INFO *si, GCEVENT *pszText);
UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, wchar_t* pszUID, wchar_t* pszWordText);
void DestroyGCMenu(HMENU *hMenu, int iIndex);
-BOOL DoEventHookAsync(HWND hwnd, const wchar_t *pszID, const char *pszModule, int iType, const USERINFO *pUser, const wchar_t* pszText, INT_PTR dwItem);
BOOL DoEventHook(SESSION_INFO *si, int iType, const USERINFO *pUser, const wchar_t* pszText, INT_PTR dwItem);
BOOL IsEventSupported(int eventType);
BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index bdd3604861..59e7bb27cc 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -187,12 +187,12 @@ static HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui) BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, bool bIsHighlighted)
{
- SESSION_INFO *p = SM_FindSession(pszID, pszModule);
- if (p == nullptr)
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si == nullptr)
return TRUE;
- LOGINFO *li = chatApi.LM_AddEvent(&p->pLog, &p->pLogEnd);
- p->iEventCount += 1;
+ LOGINFO *li = chatApi.LM_AddEvent(&si->pLog, &si->pLogEnd);
+ si->iEventCount++;
li->iType = gce->pDest->iType;
li->ptszNick = mir_wstrdup(gce->ptszNick);
@@ -204,10 +204,10 @@ BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, bool li->time = gce->time;
li->bIsHighlighted = bIsHighlighted;
- if (g_Settings->iEventLimit > 0 && p->iEventCount > g_Settings->iEventLimit + 20) {
- chatApi.LM_TrimLog(&p->pLog, &p->pLogEnd, p->iEventCount - g_Settings->iEventLimit);
- p->bTrimmed = true;
- p->iEventCount = g_Settings->iEventLimit;
+ if (g_Settings->iEventLimit > 0 && si->iEventCount > g_Settings->iEventLimit + 20) {
+ chatApi.LM_TrimLog(&si->pLog, &si->pLogEnd, si->iEventCount - g_Settings->iEventLimit);
+ si->bTrimmed = true;
+ si->iEventCount = g_Settings->iEventLimit;
return FALSE;
}
return TRUE;
@@ -437,7 +437,9 @@ static void SM_AddCommand(const wchar_t *pszID, const char *pszModule, const cha if (si->wCommandsNum > WINDOWS_COMMANDS_MAX) {
COMMANDINFO *pCurComm = si->lpCommands;
- while (pCurComm->next != nullptr) { pCurComm = pCurComm->next; }
+ while (pCurComm->next != nullptr)
+ pCurComm = pCurComm->next;
+
COMMANDINFO *pLast = pCurComm->last;
mir_free(pCurComm->lpCommand);
mir_free(pCurComm);
@@ -527,7 +529,7 @@ char* SM_GetUsers(SESSION_INFO *si) if (utemp == nullptr)
return nullptr;
- char* p = nullptr;
+ char *p = nullptr;
size_t alloced = 0;
do {
size_t pLen = mir_strlen(p), nameLen = mir_wstrlen(utemp->pszUID);
@@ -1041,12 +1043,6 @@ static BOOL LM_RemoveAll(LOGINFO **ppLogListStart, LOGINFO **ppLogListEnd) return TRUE;
}
-static BOOL DoEventHook(const wchar_t *pszID, const char *pszModule, int iType, const USERINFO *pUser, const wchar_t* pszText, INT_PTR dwItem)
-{
- SESSION_INFO *si = chatApi.SM_FindSession(pszID, pszModule);
- return (si) ? DoEventHook(si, iType, pUser, pszText, dwItem) : FALSE;
-}
-
MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _hLangpack)
{
if (pInit == nullptr)
@@ -1146,9 +1142,6 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _ chatApi.LoadMsgDlgFont = LoadMsgDlgFont;
chatApi.MakeTimeStamp = MakeTimeStamp;
- chatApi.DoEventHook = DoEventHook;
- chatApi.DoEventHookAsync = DoEventHookAsync;
-
chatApi.DoSoundsFlashPopupTrayStuff = DoSoundsFlashPopupTrayStuff;
chatApi.DoTrayIcon = DoTrayIcon;
chatApi.DoPopup = DoPopup;
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index 13f573a2c4..0257297ead 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -606,31 +606,6 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) return TRUE;
}
-BOOL DoEventHookAsync(HWND hwnd, const wchar_t *pszID, const char *pszModule, int iType, const USERINFO *pUser, const wchar_t* pszText, INT_PTR dwItem)
-{
- SESSION_INFO *si = chatApi.SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return FALSE;
-
- GCDEST *gcd = (GCDEST*)mir_calloc(sizeof(GCDEST));
- gcd->pszModule = mir_strdup(pszModule);
- gcd->ptszID = mir_wstrdup(pszID);
- gcd->iType = iType;
-
- GCHOOK *gch = (GCHOOK*)mir_calloc(sizeof(GCHOOK));
- if (pUser != NULL) {
- gch->ptszUID = mir_wstrdup(pUser->pszUID);
- gch->ptszNick = mir_wstrdup(pUser->pszNick);
- }
- else gch->ptszUID = gch->ptszNick = nullptr;
-
- gch->ptszText = mir_wstrdup(pszText);
- gch->dwData = dwItem;
- gch->pDest = gcd;
- PostMessage(hwnd, GC_FIREHOOK, 0, (LPARAM)gch);
- return TRUE;
-}
-
BOOL DoEventHook(SESSION_INFO *si, int iType, const USERINFO *pUser, const wchar_t* pszText, INT_PTR dwItem)
{
if (si == nullptr)
@@ -851,22 +826,22 @@ static void CALLBACK ChatTimerProc(HWND hwnd, UINT, UINT_PTR idEvent, DWORD) USERINFO *ui1 = chatApi.SM_GetUserFromIndex(si->ptszID, si->pszModule, si->currentHovered);
if (ui1) {
- wchar_t tszBuf[1024]; tszBuf[0] = 0;
+ CMStringW wszBuf;
if (ProtoServiceExists(si->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) {
wchar_t *p = (wchar_t*)CallProtoService(si->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)si->ptszID, (LPARAM)ui1->pszUID);
if (p) {
- wcsncpy_s(tszBuf, p, _TRUNCATE);
+ wszBuf = p;
mir_free(p);
}
}
- if (tszBuf[0] == 0)
- mir_snwprintf(tszBuf, L"<b>%s:</b>\t%s\n<b>%s:</b>\t%s\n<b>%s:</b>\t%s",
- TranslateT("Nick"), ui1->pszNick,
- TranslateT("Unique ID"), ui1->pszUID,
- TranslateT("Status"), chatApi.TM_WordToString(si->pStatuses, ui1->Status));
+ if (wszBuf.IsEmpty())
+ wszBuf.Format(L"<b>%s:</b>\t%s\n<b>%s:</b>\t%s\n<b>%s:</b>\t%s",
+ TranslateT("Nick"), ui1->pszNick,
+ TranslateT("Unique ID"), ui1->pszUID,
+ TranslateT("Status"), chatApi.TM_WordToString(si->pStatuses, ui1->Status));
CLCINFOTIP ti = { sizeof(ti) };
- if (CallService("mToolTip/ShowTipW", (WPARAM)tszBuf, (LPARAM)&ti))
+ if (CallService("mToolTip/ShowTipW", (WPARAM)wszBuf.c_str(), (LPARAM)&ti))
si->bHasToolTip = true;
}
KillTimer(hwnd, idEvent);
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index d6414d4a10..c2562b7c58 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -410,3 +410,4 @@ ProtoGetAvatarMimeType @401 ?isChat@CSrmmBaseDialog@@QBE_NXZ @411 NONAME
Srmm_LogStreamCallback @412
Srmm_MessageStreamCallback @413
+?DoEventHook@CSrmmBaseDialog@@IAEXHPBUUSERINFO@@PB_WH@Z @414 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 1c66d0534a..8c86e46402 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -410,3 +410,4 @@ ProtoGetAvatarMimeType @401 ?isChat@CSrmmBaseDialog@@QEBA_NXZ @411 NONAME
Srmm_LogStreamCallback @412
Srmm_MessageStreamCallback @413
+?DoEventHook@CSrmmBaseDialog@@IEAAXHPEBUUSERINFO@@PEB_W_J@Z @414 NONAME
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index 0d007ea68f..cb7e7430de 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -27,8 +27,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern HCURSOR g_hCurHyperlinkHand; -CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si) : - CDlgBase(hInst, idDialog), +CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si) + : CDlgBase(hInst, idDialog), m_si(si), m_pLog(nullptr), m_pEntry(nullptr), @@ -57,71 +57,92 @@ CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si 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); - { + switch (msg) { + case WM_NOTIFY: + if (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: + CHARRANGE sel; + 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(); + 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; } - break; + + DestroyMenu(hMenu); + SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE); + return TRUE; } - DestroyMenu(hMenu); - SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE); - return TRUE; + Utils_OpenUrlW(wszText); + if (m_pEntry != nullptr) + SetFocus(m_pEntry->GetHwnd()); } - - Utils_OpenUrlW(wszText); - if (m_pEntry != nullptr) - SetFocus(m_pEntry->GetHwnd()); } } + break; } return CDlgBase::DlgProc(msg, wParam, lParam); } + +void CSrmmBaseDialog::DoEventHook(int iType, const USERINFO *pUser, const wchar_t *pszText, INT_PTR dwItem) +{ + GCDEST gcd = {}; + gcd.pszModule = m_si->pszModule; + gcd.ptszID = m_si->ptszID; + gcd.iType = iType; + + GCHOOK gch = {}; + if (pUser != nullptr) { + gch.ptszUID = pUser->pszUID; + gch.ptszNick = pUser->pszNick; + } + + gch.ptszText = (LPWSTR)pszText; + gch.dwData = dwItem; + gch.pDest = &gcd; + NotifyEventHooks(chatApi.hSendEvent, 0, (WPARAM)&gch); +} |