summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-03-26 18:03:09 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-03-26 18:03:09 +0300
commit10afc1ded386e911703abd99f56843cab6a266e3 (patch)
tree6cdc970ff7af373a262af1453ae5b312a852998a
parentbb0ad44266842e40a90d94be1b6bceb43e1549f2 (diff)
common code from WndProc_Log moved to mir_app
-rw-r--r--plugins/Scriver/src/chat_window.cpp36
-rw-r--r--plugins/TabSRMM/src/chat_window.cpp30
-rw-r--r--src/core/stdmsg/src/chat_window.cpp17
-rw-r--r--src/mir_app/src/chat_tools.cpp13
-rw-r--r--src/mir_app/src/srmm_base.cpp18
5 files changed, 38 insertions, 76 deletions
diff --git a/plugins/Scriver/src/chat_window.cpp b/plugins/Scriver/src/chat_window.cpp
index 314daf7696..88f1ac6d72 100644
--- a/plugins/Scriver/src/chat_window.cpp
+++ b/plugins/Scriver/src/chat_window.cpp
@@ -830,16 +830,6 @@ LRESULT CChatRoomDlg::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam)
SetFocus(m_message.GetHwnd());
break;
- case WM_ACTIVATE:
- if (LOWORD(wParam) == WA_INACTIVE) {
- m_message.SendMsg(EM_EXGETSEL, 0, (LPARAM)&sel);
- if (sel.cpMin != sel.cpMax) {
- sel.cpMin = sel.cpMax;
- m_message.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
- }
- }
- break;
-
case WM_CONTEXTMENU:
POINT pt;
POINTL ptl;
@@ -859,10 +849,9 @@ LRESULT CChatRoomDlg::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam)
ptrW pszWord(GetRichTextWord(m_log.GetHwnd(), &ptl));
inMenu = TRUE;
- SESSION_INFO *si = m_si;
CHARRANGE all = { 0, -1 };
HMENU hMenu = GetSubMenu(g_hMenu, 1);
- UINT uID = Chat_CreateGCMenu(m_log.GetHwnd(), hMenu, pt, si, nullptr, pszWord);
+ UINT uID = Chat_CreateGCMenu(m_log.GetHwnd(), hMenu, pt, m_si, nullptr, pszWord);
inMenu = FALSE;
switch (uID) {
case 0:
@@ -878,13 +867,11 @@ LRESULT CChatRoomDlg::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam)
break;
case IDM_CLEAR:
- if (si) {
- m_log.SetText(L"");
- pci->LM_RemoveAll(&si->pLog, &si->pLogEnd);
- si->iEventCount = 0;
- si->LastTime = 0;
- PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0);
- }
+ 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:
@@ -907,11 +894,6 @@ LRESULT CChatRoomDlg::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam)
Chat_DestroyGCMenu(hMenu, 5);
}
break;
-
- case WM_CHAR:
- SetFocus(m_message.GetHwnd());
- m_message.SendMsg(WM_CHAR, wParam, lParam);
- break;
}
return CSuper::WndProc_Log(msg, wParam, lParam);
@@ -942,13 +924,13 @@ LRESULT CChatRoomDlg::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam)
}
else ScreenToClient(m_nickList.GetHwnd(), &hti.pt);
- DWORD item = (DWORD)(m_nickList.SendMsg(LB_ITEMFROMPOINT, 0, MAKELPARAM(hti.pt.x, hti.pt.y)));
+ int item = m_nickList.SendMsg(LB_ITEMFROMPOINT, 0, MAKELPARAM(hti.pt.x, hti.pt.y));
if (HIWORD(item) == 1)
- item = (DWORD)(-1);
+ item = -1;
else
item &= 0xFFFF;
- USERINFO *ui = pci->SM_GetUserFromIndex(m_si->ptszID, m_si->pszModule, (int)item);
+ USERINFO *ui = pci->SM_GetUserFromIndex(m_si->ptszID, m_si->pszModule, item);
if (ui) {
HMENU hMenu = GetSubMenu(g_hMenu, 0);
USERINFO uinew;
diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp
index d5af7d9743..b92e24d9cf 100644
--- a/plugins/TabSRMM/src/chat_window.cpp
+++ b/plugins/TabSRMM/src/chat_window.cpp
@@ -1090,25 +1090,11 @@ LRESULT CChatRoomDlg::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam)
}
break;
- case WM_ACTIVATE:
- if (LOWORD(wParam) == WA_INACTIVE) {
- CHARRANGE sel;
- SendMessage(m_log.GetHwnd(), EM_EXGETSEL, 0, (LPARAM)&sel);
- if (sel.cpMin != sel.cpMax) {
- sel.cpMin = sel.cpMax;
- SendMessage(m_log.GetHwnd(), EM_EXSETSEL, 0, (LPARAM)&sel);
- }
- }
- break;
-
case WM_CHAR:
bool isCtrl, isShift, isAlt;
KbdState(isShift, isCtrl, isAlt);
if (wParam == 0x03 && isCtrl) // Ctrl+C
return Utils::WMCopyHandler(m_log.GetHwnd(), nullptr, msg, wParam, lParam);
-
- SetFocus(m_message.GetHwnd());
- m_message.SendMsg(WM_CHAR, wParam, lParam);
break;
}
@@ -1581,10 +1567,6 @@ LRESULT CChatRoomDlg::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam)
case WM_CONTEXTMENU:
{
- SESSION_INFO *si = m_si;
- if (si == nullptr)
- break;
-
int height = 0;
TVHITTESTINFO hti;
hti.pt.x = GET_X_LPARAM(lParam);
@@ -1598,13 +1580,13 @@ LRESULT CChatRoomDlg::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam)
}
else ScreenToClient(m_nickList.GetHwnd(), &hti.pt);
- int item = (DWORD)(m_nickList.SendMsg(LB_ITEMFROMPOINT, 0, MAKELPARAM(hti.pt.x, hti.pt.y)));
+ int item = m_nickList.SendMsg(LB_ITEMFROMPOINT, 0, MAKELPARAM(hti.pt.x, hti.pt.y));
if (HIWORD(item) == 1)
- item = (DWORD)(-1);
+ item = -1;
else
item &= 0xFFFF;
- USERINFO *ui = pci->SM_GetUserFromIndex(si->ptszID, si->pszModule, item);
+ USERINFO *ui = pci->SM_GetUserFromIndex(m_si->ptszID, m_si->pszModule, item);
if (ui) {
HMENU hMenu = GetSubMenu(g_hMenu, 0);
USERINFO uinew;
@@ -1613,14 +1595,14 @@ LRESULT CChatRoomDlg::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam)
hti.pt.y += height - 4;
ClientToScreen(m_nickList.GetHwnd(), &hti.pt);
- UINT uID = Chat_CreateGCMenu(m_nickList.GetHwnd(), hMenu, hti.pt, si, uinew.pszUID, uinew.pszNick);
+ UINT uID = Chat_CreateGCMenu(m_nickList.GetHwnd(), hMenu, hti.pt, m_si, uinew.pszUID, uinew.pszNick);
switch (uID) {
case 0:
break;
case 20020: // add to highlight...
{
- THighLightEdit the = { THighLightEdit::CMD_ADD, si, ui };
+ THighLightEdit the = { THighLightEdit::CMD_ADD, m_si, ui };
HWND hwndDlg = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_ADDHIGHLIGHT), m_pContainer->m_hwnd, CMUCHighlight::dlgProcAdd, (LPARAM)&the);
TranslateDialogDefault(hwndDlg);
@@ -2175,7 +2157,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
HMENU hMenu = GetSubMenu(g_hMenu, 1);
- UINT uID = Chat_CreateGCMenu(m_hwnd, hMenu, pt, m_si, nullptr, pszWord);
+ UINT uID = Chat_CreateGCMenu(m_log.GetHwnd(), hMenu, pt, m_si, nullptr, pszWord);
switch (uID) {
case 0:
PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0);
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp
index d81fae0519..cbb246e241 100644
--- a/src/core/stdmsg/src/chat_window.cpp
+++ b/src/core/stdmsg/src/chat_window.cpp
@@ -961,21 +961,6 @@ LRESULT CChatRoomDlg::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam)
return TRUE;
}
break;
-
- case WM_ACTIVATE:
- if (LOWORD(wParam) == WA_INACTIVE) {
- m_log.SendMsg(EM_EXGETSEL, 0, (LPARAM)&sel);
- if (sel.cpMin != sel.cpMax) {
- sel.cpMin = sel.cpMax;
- m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
- }
- }
- break;
-
- case WM_CHAR:
- SetFocus(m_message.GetHwnd());
- m_message.SendMsg(WM_CHAR, wParam, lParam);
- break;
}
return CSuper::WndProc_Log(msg, wParam, lParam);
@@ -1255,7 +1240,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
CHARRANGE all = { 0, -1 };
HMENU hMenu = GetSubMenu(g_hMenu, 1);
- UINT uID = Chat_CreateGCMenu(m_hwnd, hMenu, pt, m_si, nullptr, pszWord);
+ UINT uID = Chat_CreateGCMenu(m_log.GetHwnd(), hMenu, pt, m_si, nullptr, pszWord);
switch (uID) {
case 0:
PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0);
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp
index df67d45517..ce81249be2 100644
--- a/src/mir_app/src/chat_tools.cpp
+++ b/src/mir_app/src/chat_tools.cpp
@@ -796,14 +796,9 @@ MIR_APP_DLL(UINT) Chat_CreateGCMenu(HWND hwnd, HMENU hMenu, POINT pt, SESSION_IN
gcmi.hMenu = hMenu;
if (pszUID == nullptr) {
- int iLen = GetRichTextLength(hwnd);
-
- EnableMenuItem(hMenu, IDM_CLEAR, MF_ENABLED);
- EnableMenuItem(hMenu, IDM_COPYALL, MF_ENABLED);
- if (!iLen) {
- EnableMenuItem(hMenu, IDM_COPYALL, MF_BYCOMMAND | MF_GRAYED);
- EnableMenuItem(hMenu, IDM_CLEAR, MF_BYCOMMAND | MF_GRAYED);
- }
+ 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];
@@ -822,7 +817,7 @@ MIR_APP_DLL(UINT) Chat_CreateGCMenu(HWND hwnd, HMENU hMenu, POINT pt, SESSION_IN
if (mir_wstrlen(szTemp) > 40)
mir_wstrncpy(szTemp + 40, L"...", 4);
- ModifyMenu(hMenu, IDM_SENDMESSAGE, MF_STRING | MF_BYCOMMAND, IDM_SENDMESSAGE, szTemp);
+ ModifyMenu(hMenu, 0, MF_STRING | MF_BYPOSITION, IDM_SENDMESSAGE, szTemp);
gcmi.Type = MENU_ON_NICKLIST;
}
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp
index 01ef9a8063..d9e25d6c9d 100644
--- a/src/mir_app/src/srmm_base.cpp
+++ b/src/mir_app/src/srmm_base.cpp
@@ -136,6 +136,24 @@ static LRESULT CALLBACK stubLogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
LRESULT CSrmmBaseDialog::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam)
{
+ switch (msg) {
+ case WM_ACTIVATE:
+ if (LOWORD(wParam) == WA_INACTIVE) {
+ CHARRANGE sel;
+ m_log.SendMsg(EM_EXGETSEL, 0, (LPARAM)&sel);
+ if (sel.cpMin != sel.cpMax) {
+ sel.cpMin = sel.cpMax;
+ m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
+ }
+ }
+ break;
+
+ case WM_CHAR:
+ SetFocus(m_message.GetHwnd());
+ m_message.SendMsg(WM_CHAR, wParam, lParam);
+ break;
+ }
+
return mir_callNextSubclass(m_log.GetHwnd(), stubLogProc, msg, wParam, lParam);
}