summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-05-04 20:52:39 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-05-04 20:52:46 +0300
commit633d14f19afc80362a5d4872def663a5271c7225 (patch)
tree0dcd65265836da3503af39d060c45e19de149ba5 /src/mir_app
parent7c0d4f4d63669f84d0796776a47d12d75891c40e (diff)
fixes #2381 (NewStory: add right-click menu for groupchats)
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/chat.h1
-rw-r--r--src/mir_app/src/chat_tools.cpp39
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
-rw-r--r--src/mir_app/src/srmm_base.cpp13
-rw-r--r--src/mir_app/src/srmm_log_rtf.cpp19
6 files changed, 36 insertions, 38 deletions
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h
index 4685fa5685..81675c46ad 100644
--- a/src/mir_app/src/chat.h
+++ b/src/mir_app/src/chat.h
@@ -109,7 +109,6 @@ int LoadChatModule(void);
void UnloadChatModule(void);
// tools.c
-UINT CreateGCMenu(HWND hwnd, HMENU hMenu, POINT pt, SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *pszWordText);
int DoRtfToTags(CMStringW &pszText, int iNumColors, COLORREF *pColors);
wchar_t* RemoveFormatting(const wchar_t* pszText);
BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp
index 8602f59168..53b4a33700 100644
--- a/src/mir_app/src/chat_tools.cpp
+++ b/src/mir_app/src/chat_tools.cpp
@@ -753,44 +753,17 @@ MIR_APP_DLL(void) Chat_AddMenuItems(HMENU hMenu, int nItems, const gc_item *Item
/////////////////////////////////////////////////////////////////////////////////////////
-UINT CreateGCMenu(HWND hwnd, HMENU hMenu, POINT pt, SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *pszWordText)
+MIR_APP_DLL(UINT) Chat_CreateMenu(HWND hwnd, HMENU hMenu, POINT pt, SESSION_INFO *si, const wchar_t *pszUID)
{
- GCMENUITEMS gcmi = {};
if (si) {
+ GCMENUITEMS gcmi = {};
gcmi.pszID = si->ptszID;
gcmi.pszModule = si->pszModule;
- }
- gcmi.pszUID = (wchar_t*)pszUID;
- gcmi.hMenu = hMenu;
-
- if (pszUID == nullptr) {
- int flags = MF_BYPOSITION | (GetRichTextLength(hwnd) == 0 ? MF_GRAYED : MF_ENABLED);
- EnableMenuItem(hMenu, 0, flags);
- EnableMenuItem(hMenu, 2, flags);
-
- if (pszWordText && pszWordText[0]) {
- wchar_t szMenuText[4096];
- mir_snwprintf(szMenuText, TranslateT("Look up '%s':"), pszWordText);
- ModifyMenu(hMenu, 4, MF_STRING | MF_BYPOSITION, 4, szMenuText);
- }
- else ModifyMenu(hMenu, 4, MF_STRING | MF_GRAYED | MF_BYPOSITION, 4, TranslateT("No word to look up"));
- gcmi.Type = MENU_ON_LOG;
- }
- else {
- wchar_t szTemp[50];
- if (pszWordText)
- mir_snwprintf(szTemp, TranslateT("&Message %s"), pszWordText);
- else
- mir_wstrncpy(szTemp, TranslateT("&Message"), _countof(szTemp) - 1);
-
- if (mir_wstrlen(szTemp) > 40)
- mir_wstrncpy(szTemp + 40, L"...", 4);
- ModifyMenu(hMenu, 0, MF_STRING | MF_BYPOSITION, IDM_SENDMESSAGE, szTemp);
- gcmi.Type = MENU_ON_NICKLIST;
- }
-
- if (si)
+ gcmi.pszUID = (wchar_t *)pszUID;
+ gcmi.hMenu = hMenu;
+ gcmi.Type = (pszUID == nullptr) ? MENU_ON_LOG : MENU_ON_NICKLIST;
NotifyEventHooks(hevBuildMenuEvent, 0, (WPARAM)&gcmi);
+ }
return TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, nullptr);
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 200a784b75..01161746cd 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -734,3 +734,4 @@ ProtoBroadcastAsync @814 NONAME
?getChat@CSrmmBaseDialog@@QBEPAUSESSION_INFO@@XZ @821 NONAME
?EventCursor@MDatabaseCommon@@UAGPAVEventCursorBase@DB@@IAAUDBEVENTINFO@@@Z @822 NONAME
?EventCursorRev@MDatabaseCommon@@UAGPAVEventCursorBase@DB@@IAAUDBEVENTINFO@@@Z @823 NONAME
+Chat_CreateMenu @824 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 50105e6a82..9ef8a4097a 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -734,3 +734,4 @@ ProtoBroadcastAsync @814 NONAME
?getChat@CSrmmBaseDialog@@QEBAPEAUSESSION_INFO@@XZ @821 NONAME
?EventCursor@MDatabaseCommon@@UEAAPEAVEventCursorBase@DB@@IAEAUDBEVENTINFO@@@Z @822 NONAME
?EventCursorRev@MDatabaseCommon@@UEAAPEAVEventCursorBase@DB@@IAEAUDBEVENTINFO@@@Z @823 NONAME
+Chat_CreateMenu @824 NONAME
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp
index d835c3f8bf..323a336b70 100644
--- a/src/mir_app/src/srmm_base.cpp
+++ b/src/mir_app/src/srmm_base.cpp
@@ -84,7 +84,18 @@ void CSrmmBaseDialog::RunUserMenu(HWND hwndOwner, USERINFO *ui, const POINT &pt)
USERINFO uinew;
memcpy(&uinew, ui, sizeof(USERINFO));
- UINT uID = CreateGCMenu(hwndOwner, hSubMenu, pt, m_si, uinew.pszUID, uinew.pszNick);
+
+ wchar_t szTemp[50];
+ if (uinew.pszNick)
+ mir_snwprintf(szTemp, TranslateT("&Message %s"), uinew.pszNick);
+ else
+ mir_wstrncpy(szTemp, TranslateT("&Message"), _countof(szTemp) - 1);
+
+ if (mir_wstrlen(szTemp) > 40)
+ mir_wstrncpy(szTemp + 40, L"...", 4);
+ ModifyMenu(hMenu, 0, MF_STRING | MF_BYPOSITION, IDM_SENDMESSAGE, szTemp);
+
+ UINT uID = Chat_CreateMenu(hwndOwner, hSubMenu, pt, m_si, uinew.pszUID);
switch (uID) {
case 0:
break;
diff --git a/src/mir_app/src/srmm_log_rtf.cpp b/src/mir_app/src/srmm_log_rtf.cpp
index f2f1fae8d6..a5132a9af0 100644
--- a/src/mir_app/src/srmm_log_rtf.cpp
+++ b/src/mir_app/src/srmm_log_rtf.cpp
@@ -278,7 +278,7 @@ INT_PTR CRtfLogWindow::WndProc(UINT msg, WPARAM wParam, LPARAM lParam)
pt.y = GET_Y_LPARAM(lParam);
}
ptl = pt;
- ScreenToClient(m_rtf.GetHwnd(), (LPPOINT)&ptl);
+ ScreenToClient(m_rtf.GetHwnd(), &ptl);
{
wchar_t *pszWord = (wchar_t *)_alloca(8192);
pszWord[0] = '\0';
@@ -316,8 +316,22 @@ INT_PTR CRtfLogWindow::WndProc(UINT msg, WPARAM wParam, LPARAM lParam)
HMENU hSubMenu = GetSubMenu(hMenu, 0);
TranslateMenu(hSubMenu);
m_pDlg.m_bInMenu = true;
- UINT uID = CreateGCMenu(m_rtf.GetHwnd(), hSubMenu, pt, m_pDlg.m_si, nullptr, pszWord);
+
+ int flags = MF_BYPOSITION | (GetRichTextLength(m_rtf.GetHwnd()) == 0 ? MF_GRAYED : MF_ENABLED);
+ EnableMenuItem(hSubMenu, 0, flags);
+ EnableMenuItem(hSubMenu, 2, flags);
+
+ if (pszWord && pszWord[0]) {
+ wchar_t szMenuText[4096];
+ mir_snwprintf(szMenuText, TranslateT("Look up '%s':"), pszWord);
+ ModifyMenu(hSubMenu, 4, MF_STRING | MF_BYPOSITION, 4, szMenuText);
+ }
+ else ModifyMenu(hSubMenu, 4, MF_STRING | MF_GRAYED | MF_BYPOSITION, 4, TranslateT("No word to look up"));
+
+ UINT uID = Chat_CreateMenu(m_rtf.GetHwnd(), hSubMenu, pt, m_pDlg.m_si, nullptr);
m_pDlg.m_bInMenu = false;
+ DestroyMenu(hMenu);
+
switch (uID) {
case 0:
PostMessage(m_pDlg.m_hwnd, WM_MOUSEACTIVATE, 0, 0);
@@ -387,7 +401,6 @@ INT_PTR CRtfLogWindow::WndProc(UINT msg, WPARAM wParam, LPARAM lParam)
Chat_DoEventHook(m_pDlg.m_si, GC_USER_LOGMENU, nullptr, nullptr, uID);
break;
}
- DestroyMenu(hMenu);
}
return 0;
}