From 592c0d89f865c44e6909e0ca1e9d0c550be890b4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 26 Mar 2017 20:45:13 +0300 Subject: context menu moved to mir_app, part II :) --- plugins/Scriver/src/chat_main.cpp | 9 --- plugins/Scriver/src/chat_window.cpp | 128 +----------------------------------- plugins/Scriver/src/msgdialog.cpp | 12 ++-- plugins/Scriver/src/msgs.cpp | 2 - plugins/Scriver/src/resource.h | 1 - plugins/Scriver/src/stdafx.h | 2 - plugins/Scriver/src/utils.cpp | 2 +- plugins/Scriver/src/utils.h | 2 +- 8 files changed, 10 insertions(+), 148 deletions(-) (limited to 'plugins/Scriver/src') diff --git a/plugins/Scriver/src/chat_main.cpp b/plugins/Scriver/src/chat_main.cpp index 5d0cb3b0e3..5c7e1183f7 100644 --- a/plugins/Scriver/src/chat_main.cpp +++ b/plugins/Scriver/src/chat_main.cpp @@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // globals CHAT_MANAGER *pci; -HMENU g_hMenu = nullptr; pfnDoTrayIcon oldDoTrayIcon; pfnDoPopup oldDoPopup; @@ -151,13 +150,5 @@ int Chat_Load() oldDoTrayIcon = pci->DoTrayIcon; pci->DoTrayIcon = DoTrayIcon; pci->ReloadSettings(); - g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU)); - TranslateMenu(g_hMenu); - return 0; -} - -int Chat_Unload(void) -{ - DestroyMenu(g_hMenu); return 0; } diff --git a/plugins/Scriver/src/chat_window.cpp b/plugins/Scriver/src/chat_window.cpp index 88f1ac6d72..2ab211a1bd 100644 --- a/plugins/Scriver/src/chat_window.cpp +++ b/plugins/Scriver/src/chat_window.cpp @@ -233,7 +233,7 @@ CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si) void CChatRoomDlg::OnInitDialog() { - CScriverWindow::OnInitDialog(); + CSuper::OnInitDialog(); m_si->pDlg = this; NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_OPENING); @@ -797,8 +797,6 @@ LRESULT CChatRoomDlg::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) LRESULT CChatRoomDlg::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) { - static BOOL inMenu = FALSE; - int result = InputAreaShortcuts(m_log.GetHwnd(), msg, wParam, lParam); if (result != -1) return result; @@ -813,13 +811,6 @@ LRESULT CChatRoomDlg::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) case WM_DRAWITEM: return DrawMenuItem(wParam, lParam); - case WM_SETCURSOR: - if (inMenu) { - SetCursor(LoadCursor(nullptr, IDC_ARROW)); - return TRUE; - } - break; - case WM_LBUTTONUP: SendMessage(m_log.GetHwnd(), EM_EXGETSEL, 0, (LPARAM)&sel); if (sel.cpMin != sel.cpMax) { @@ -829,71 +820,6 @@ LRESULT CChatRoomDlg::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) } SetFocus(m_message.GetHwnd()); break; - - case WM_CONTEXTMENU: - POINT pt; - POINTL ptl; - m_message.SendMsg(EM_EXGETSEL, 0, (LPARAM)&sel); - if (lParam == 0xFFFFFFFF) { - m_message.SendMsg(EM_POSFROMCHAR, (WPARAM)&pt, (LPARAM)sel.cpMax); - ClientToScreen(m_log.GetHwnd(), &pt); - } - else { - pt.x = GET_X_LPARAM(lParam); - pt.y = GET_Y_LPARAM(lParam); - } - ptl.x = (LONG)pt.x; - ptl.y = (LONG)pt.y; - ScreenToClient(m_log.GetHwnd(), (LPPOINT)&ptl); - { - ptrW pszWord(GetRichTextWord(m_log.GetHwnd(), &ptl)); - inMenu = TRUE; - - CHARRANGE all = { 0, -1 }; - HMENU hMenu = GetSubMenu(g_hMenu, 1); - UINT uID = Chat_CreateGCMenu(m_log.GetHwnd(), hMenu, pt, m_si, nullptr, pszWord); - inMenu = FALSE; - switch (uID) { - case 0: - PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0); - break; - - case ID_COPYALL: - m_message.SendMsg(EM_EXGETSEL, 0, (LPARAM)&sel); - m_message.SendMsg(EM_EXSETSEL, 0, (LPARAM)&all); - m_message.SendMsg(WM_COPY, 0, 0); - m_message.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); - PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0); - break; - - case IDM_CLEAR: - m_log.SetText(L""); - pci->LM_RemoveAll(&m_si->pLog, &m_si->pLogEnd); - m_si->iEventCount = 0; - m_si->LastTime = 0; - PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0); - break; - - case IDM_SEARCH_GOOGLE: - case IDM_SEARCH_BING: - case IDM_SEARCH_YANDEX: - case IDM_SEARCH_YAHOO: - case IDM_SEARCH_WIKIPEDIA: - case IDM_SEARCH_FOODNETWORK: - case IDM_SEARCH_GOOGLE_MAPS: - case IDM_SEARCH_GOOGLE_TRANSLATE: - SearchWord(pszWord, uID - IDM_SEARCH_GOOGLE + SEARCHENGINE_GOOGLE); - PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0); - break; - - default: - PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0); - DoEventHook(GC_USER_LOGMENU, nullptr, nullptr, uID); - break; - } - Chat_DestroyGCMenu(hMenu, 5); - } - break; } return CSuper::WndProc_Log(msg, wParam, lParam); @@ -908,56 +834,6 @@ LRESULT CChatRoomDlg::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam) return result; switch (msg) { - case WM_CONTEXTMENU: - { - int height = 0; - - TVHITTESTINFO hti; - hti.pt.x = GET_X_LPARAM(lParam); - hti.pt.y = GET_Y_LPARAM(lParam); - if (hti.pt.x == -1 && hti.pt.y == -1) { - int index = m_nickList.SendMsg(LB_GETCURSEL, 0, 0); - int top = m_nickList.SendMsg(LB_GETTOPINDEX, 0, 0); - height = m_nickList.SendMsg(LB_GETITEMHEIGHT, 0, 0); - hti.pt.x = 4; - hti.pt.y = (index - top)*height + 1; - } - else ScreenToClient(m_nickList.GetHwnd(), &hti.pt); - - int item = m_nickList.SendMsg(LB_ITEMFROMPOINT, 0, MAKELPARAM(hti.pt.x, hti.pt.y)); - if (HIWORD(item) == 1) - item = -1; - else - item &= 0xFFFF; - - USERINFO *ui = pci->SM_GetUserFromIndex(m_si->ptszID, m_si->pszModule, item); - if (ui) { - HMENU hMenu = GetSubMenu(g_hMenu, 0); - USERINFO uinew; - memcpy(&uinew, ui, sizeof(USERINFO)); - if (hti.pt.x == -1 && hti.pt.y == -1) - hti.pt.y += height - 4; - ClientToScreen(m_nickList.GetHwnd(), &hti.pt); - UINT uID = Chat_CreateGCMenu(m_nickList.GetHwnd(), hMenu, hti.pt, m_si, uinew.pszUID, uinew.pszNick); - - switch (uID) { - case 0: - break; - - case ID_MESS: - DoEventHook(GC_USER_PRIVMESS, ui, nullptr, 0); - break; - - default: - DoEventHook(GC_USER_NICKLISTMENU, ui, nullptr, uID); - break; - } - Chat_DestroyGCMenu(hMenu, 1); - return TRUE; - } - } - break; - case WM_GETDLGCODE: { BOOL isAlt = GetKeyState(VK_MENU) & 0x8000; @@ -1251,7 +1127,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) } break; } - return CScriverWindow::DlgProc(uMsg, wParam, lParam); + return CSuper::DlgProc(uMsg, wParam, lParam); } void ShowRoom(SESSION_INFO *si) diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index c51e8da8f2..7968f3da0c 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -215,7 +215,7 @@ CSrmmWindow::CSrmmWindow(MCONTACT hContact, bool bIncoming, const char *szInitia void CSrmmWindow::OnInitDialog() { - CScriverWindow::OnInitDialog(); + CSuper::OnInitDialog(); SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this); WindowList_Add(pci->hWindowList, m_hwnd, m_hContact); @@ -997,9 +997,9 @@ LRESULT CSrmmWindow::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) pt.y = GET_Y_LPARAM(lParam); } - POINTL ptl = { (LONG)pt.x, (LONG)pt.y }; - ScreenToClient(m_message.GetHwnd(), (LPPOINT)&ptl); - ptrW pszWord(GetRichTextWord(m_message.GetHwnd(), &ptl)); + POINT ptl = pt; + ScreenToClient(m_log.GetHwnd(), &ptl); + ptrW pszWord(GetRichTextWord(m_log.GetHwnd(), &ptl)); if (pszWord && pszWord[0]) { wchar_t szMenuText[4096]; mir_snwprintf(szMenuText, TranslateT("Look up '%s':"), pszWord); @@ -1009,7 +1009,7 @@ LRESULT CSrmmWindow::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) else ModifyMenu(hSubMenu, 5, MF_STRING | MF_GRAYED | MF_BYPOSITION, 5, TranslateT("No word to look up")); inMenu = TRUE; - int uID = TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_message.GetHwnd(), nullptr); + int uID = TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_log.GetHwnd(), nullptr); inMenu = FALSE; switch (uID) { @@ -1743,5 +1743,5 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) break; } - return CScriverWindow::DlgProc(msg, wParam, lParam); + return CSuper::DlgProc(msg, wParam, lParam); } diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index b8426c8924..6e1f443b8a 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -590,8 +590,6 @@ int OnSystemPreshutdown(WPARAM, LPARAM) int OnUnloadModule(void) { - Chat_Unload(); - DestroyCursor(hDragCursor); DestroyHookableEvent(hHookWinEvt); diff --git a/plugins/Scriver/src/resource.h b/plugins/Scriver/src/resource.h index 140bbdb351..7966a71277 100644 --- a/plugins/Scriver/src/resource.h +++ b/plugins/Scriver/src/resource.h @@ -60,7 +60,6 @@ #define IDI_ADDSTATUS 441 #define IDI_REMSTATUS 442 #define IDI_ACTION 443 -#define IDR_MENU 451 #define IDI_STATUS3 453 #define IDI_STATUS2 454 #define IDI_STATUS4 455 diff --git a/plugins/Scriver/src/stdafx.h b/plugins/Scriver/src/stdafx.h index c276c7e0fa..cd4c800ef1 100644 --- a/plugins/Scriver/src/stdafx.h +++ b/plugins/Scriver/src/stdafx.h @@ -91,7 +91,6 @@ extern HWND SM_FindWindowByContact(MCONTACT hContact); extern HINSTANCE g_hInst; extern HCURSOR hDragCursor; extern ITaskbarList3 *pTaskbarInterface; -extern HMENU g_hMenu; extern HANDLE hHookWinPopup, hHookWinWrite, hHookWinEvt; void ChangeStatusIcons(); @@ -106,7 +105,6 @@ void LoadInfobarFonts(); #define INFO_BAR_COLOR COLOR_INACTIVEBORDER int Chat_Load(); -int Chat_Unload(); int OptInitialise(WPARAM wParam, LPARAM lParam); int FontServiceFontsChanged(WPARAM wParam, LPARAM lParam); int StatusIconPressed(WPARAM wParam, LPARAM lParam); diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp index aabc26d15f..ddc542ad38 100644 --- a/plugins/Scriver/src/utils.cpp +++ b/plugins/Scriver/src/utils.cpp @@ -136,7 +136,7 @@ wchar_t* limitText(wchar_t *text, int limit) return text; } -wchar_t* GetRichTextWord(HWND hwnd, POINTL *ptl) +wchar_t* GetRichTextWord(HWND hwnd, POINT *ptl) { long iCharIndex, start, end, iRes; wchar_t *pszWord = GetRichEditSelection(hwnd); diff --git a/plugins/Scriver/src/utils.h b/plugins/Scriver/src/utils.h index bf01163431..ba88ea469d 100644 --- a/plugins/Scriver/src/utils.h +++ b/plugins/Scriver/src/utils.h @@ -40,7 +40,7 @@ int GetRichTextLength(HWND hwnd, int codepage, BOOL inBytes); wchar_t *GetRichEditSelection(HWND hwnd); char* GetRichTextRTF(HWND hwnd); char* GetRichTextUtf(HWND hwnd); -wchar_t *GetRichTextWord(HWND hwnd, POINTL *pt); +wchar_t *GetRichTextWord(HWND hwnd, POINT *pt); int SetRichText(HWND hwnd, const wchar_t *text); int SetRichTextRTF(HWND hwnd, const char *text); void SearchWord(wchar_t * word, int engine); -- cgit v1.2.3