From 35ec83f41f78aff503d1bfa16714aadee360d2f7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 24 Mar 2017 12:41:14 +0300 Subject: m_message & m_log moved inside mir_app --- src/core/stdmsg/res/resource.rc | 12 +-- src/core/stdmsg/src/chat_util.cpp | 4 +- src/core/stdmsg/src/chat_window.cpp | 21 ++---- src/core/stdmsg/src/msgdialog.cpp | 20 ++--- src/core/stdmsg/src/msglog.cpp | 32 ++++---- src/core/stdmsg/src/msgs.cpp | 6 +- src/core/stdmsg/src/msgs.h | 1 - src/core/stdmsg/src/resource.h | 2 - src/core/stdmsg/src/richutil.cpp | 2 +- src/core/stdmsg/src/stdafx.h | 1 - src/mir_app/src/colorchooser.cpp | 2 +- src/mir_app/src/srmm_base.cpp | 145 ++++++++++++++++++------------------ 12 files changed, 114 insertions(+), 134 deletions(-) (limited to 'src') diff --git a/src/core/stdmsg/res/resource.rc b/src/core/stdmsg/res/resource.rc index cab5c99329..7893ed2b21 100644 --- a/src/core/stdmsg/res/resource.rc +++ b/src/core/stdmsg/res/resource.rc @@ -85,10 +85,10 @@ EXSTYLE WS_EX_NOPARENTNOTIFY | WS_EX_ACCEPTFILES | WS_EX_CONTROLPARENT CAPTION "Message session" FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - CONTROL "",IDC_MESSAGE,"RichEdit50W",WS_VSCROLL | WS_TABSTOP | 0x1144,1,49,141,13,WS_EX_ACCEPTFILES | WS_EX_STATICEDGE + CONTROL "",IDC_SRMM_MESSAGE,"RichEdit50W",WS_VSCROLL | WS_TABSTOP | 0x1144,1,49,141,13,WS_EX_ACCEPTFILES | WS_EX_STATICEDGE DEFPUSHBUTTON "&Send",IDOK,143,48,39,15 PUSHBUTTON "Close",IDCANCEL,129,0,54,15,NOT WS_VISIBLE - CONTROL "",IDC_LOG,"RichEdit50W",WS_VSCROLL | WS_TABSTOP | 0x844,1,18,183,26,WS_EX_STATICEDGE + CONTROL "",IDC_SRMM_LOG,"RichEdit50W",WS_VSCROLL | WS_TABSTOP | 0x844,1,18,183,26,WS_EX_STATICEDGE CONTROL "",IDC_SPLITTERY,"Static",SS_ENHMETAFILE,0,45,183,2 CONTROL "",IDC_AVATAR,"Button",BS_OWNERDRAW | NOT WS_VISIBLE,1,50,1,13 END @@ -198,9 +198,9 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - CONTROL "",IDC_MESSAGE,"RichEdit50W",WS_VSCROLL | WS_TABSTOP | 0x3144,0,128,127,12,WS_EX_STATICEDGE + CONTROL "",IDC_SRMM_MESSAGE,"RichEdit50W",WS_VSCROLL | WS_TABSTOP | 0x3144,0,128,127,12,WS_EX_STATICEDGE PUSHBUTTON "&Send",IDOK,136,126,115,14,WS_DISABLED - CONTROL "",IDC_LOG,"RichEdit50W",WS_VSCROLL | WS_TABSTOP | 0x2844,8,2,164,94,WS_EX_STATICEDGE + CONTROL "",IDC_SRMM_LOG,"RichEdit50W",WS_VSCROLL | WS_TABSTOP | 0x2844,8,2,164,94,WS_EX_STATICEDGE CONTROL "",IDC_SPLITTERX,"Static",SS_ENHMETAFILE,172,23,10,73 CONTROL "",IDC_SPLITTERY,"Static",SS_ENHMETAFILE,0,102,251,6 LISTBOX IDC_SRMM_NICKLIST,182,2,69,94,LBS_OWNERDRAWFIXED | LBS_NOINTEGRALHEIGHT | LBS_NODATA | NOT WS_BORDER | WS_VSCROLL | WS_TABSTOP,WS_EX_STATICEDGE @@ -210,9 +210,9 @@ IDD_CHANNEL DIALOGEX 0, 0, 252, 140 STYLE DS_SETFONT | DS_FIXEDSYS | DS_3DLOOK | DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - CONTROL "",IDC_MESSAGE,"RichEdit50W",WS_VSCROLL | WS_TABSTOP | 0x3144,0,128,127,12,WS_EX_STATICEDGE + CONTROL "",IDC_SRMM_MESSAGE,"RichEdit50W",WS_VSCROLL | WS_TABSTOP | 0x3144,0,128,127,12,WS_EX_STATICEDGE PUSHBUTTON "&Send",IDOK,136,126,115,14,WS_DISABLED - CONTROL "",IDC_LOG,"RichEdit50W",WS_VSCROLL | WS_TABSTOP | 0x2844,8,23,164,73,WS_EX_STATICEDGE + CONTROL "",IDC_SRMM_LOG,"RichEdit50W",WS_VSCROLL | WS_TABSTOP | 0x2844,8,23,164,73,WS_EX_STATICEDGE CONTROL "",IDC_SPLITTERX,"Static",SS_ENHMETAFILE,172,23,10,73 CONTROL "",IDC_SPLITTERY,"Static",SS_ENHMETAFILE,0,102,251,6 LISTBOX IDC_SRMM_NICKLIST,182,23,69,73,LBS_OWNERDRAWFIXED | LBS_NOINTEGRALHEIGHT | LBS_NODATA | NOT WS_BORDER | WS_VSCROLL | WS_TABSTOP,WS_EX_STATICEDGE diff --git a/src/core/stdmsg/src/chat_util.cpp b/src/core/stdmsg/src/chat_util.cpp index cdd53ef2cf..602c2c14c5 100644 --- a/src/core/stdmsg/src/chat_util.cpp +++ b/src/core/stdmsg/src/chat_util.cpp @@ -136,7 +136,7 @@ char* Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si) stream.dwCookie = (DWORD_PTR)&pszText; // pass pointer to pointer DWORD dwFlags = SF_RTFNOOBJS | SFF_PLAINRTF | SF_USECODEPAGE | (CP_UTF8 << 16); - SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_STREAMOUT, dwFlags, (LPARAM)&stream); + SendDlgItemMessage(hwndDlg, IDC_SRMM_MESSAGE, EM_STREAMOUT, dwFlags, (LPARAM)&stream); return pszText; // pszText contains the text } @@ -199,7 +199,7 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO gcmi.pszUID = pszUID; if (iIndex == 1) { - int i = GetRichTextLength(GetDlgItem(hwndDlg, IDC_LOG)); + int i = GetRichTextLength(GetDlgItem(hwndDlg, IDC_SRMM_LOG)); EnableMenuItem(*hMenu, ID_CLEARLOG, MF_ENABLED); EnableMenuItem(*hMenu, ID_COPYALL, MF_ENABLED); diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 3247b0ef98..bb1065bf7f 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -52,17 +52,11 @@ static void __cdecl phase2(void *lParam) CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si) : CSrmmBaseDialog(g_hInst, g_Settings.bTabsEnable ? IDD_CHANNEL_TAB : IDD_CHANNEL, si), - m_message(this, IDC_MESSAGE), - m_log(this, IDC_LOG), - m_btnOk(this, IDOK), m_splitterX(this, IDC_SPLITTERX), m_splitterY(this, IDC_SPLITTERY) { - m_pLog = &m_log; - m_pEntry = &m_message; - m_autoClose = 0; m_forceResizable = true; @@ -201,7 +195,7 @@ void CChatRoomDlg::onClick_Ok(CCtrlButton *pButton) EnableWindow(m_message.GetHwnd(), FALSE); m_message.SendMsg(EM_SETREADONLY, TRUE, 0); } - else SetDlgItemText(m_hwnd, IDC_MESSAGE, L""); + else m_message.SetText(L""); EnableWindow(m_btnOk.GetHwnd(), FALSE); @@ -508,7 +502,7 @@ int CChatRoomDlg::Resizer(UTILRESIZECONTROL *urc) urc->rcItem.bottom = urc->dlgNewSize.cy - (rc.bottom - rc.top) - 1; return RD_ANCHORX_RIGHT | RD_ANCHORY_CUSTOM; - case IDC_LOG: + case IDC_SRMM_LOG: urc->rcItem.top = 2; urc->rcItem.left = 0; urc->rcItem.right = bNick ? urc->dlgNewSize.cx - m_iSplitterX : urc->dlgNewSize.cx; @@ -537,7 +531,7 @@ int CChatRoomDlg::Resizer(UTILRESIZECONTROL *urc) urc->rcItem.bottom = urc->rcItem.top + 2; return RD_ANCHORX_WIDTH | RD_ANCHORY_CUSTOM; - case IDC_MESSAGE: + case IDC_SRMM_MESSAGE: GetWindowRect(m_hwndStatus, &rc); urc->rcItem.right = bSend ? urc->dlgNewSize.cx - 64 : urc->dlgNewSize.cx; urc->rcItem.top = urc->dlgNewSize.cy - m_iSplitterY + 22; @@ -627,7 +621,7 @@ LRESULT CChatRoomDlg::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) switch (msg) { case WM_MOUSEWHEEL: - SendDlgItemMessage(m_hwnd, IDC_LOG, WM_MOUSEWHEEL, wParam, lParam); + m_log.SendMsg(WM_MOUSEWHEEL, wParam, lParam); m_iLastEnterTime = 0; return TRUE; @@ -815,8 +809,7 @@ LRESULT CChatRoomDlg::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) } if (wParam == VK_NEXT || wParam == VK_PRIOR) { - HWND htemp = m_hwnd; - SendDlgItemMessage(htemp, IDC_LOG, msg, wParam, lParam); + m_log.SendMsg(msg, wParam, lParam); m_iLastEnterTime = 0; return TRUE; } @@ -1284,7 +1277,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case EN_MSGFILTER: - if (((LPNMHDR)lParam)->idFrom == IDC_LOG && ((MSGFILTER *)lParam)->msg == WM_RBUTTONUP) { + if (((LPNMHDR)lParam)->idFrom == IDC_SRMM_LOG && ((MSGFILTER *)lParam)->msg == WM_RBUTTONUP) { ENLINK *pLink = (ENLINK*)lParam; POINT pt = { GET_X_LPARAM(pLink->lParam), GET_Y_LPARAM(pLink->lParam) }; ClientToScreen(((LPNMHDR)lParam)->hwndFrom, &pt); @@ -1390,7 +1383,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_COMMAND: switch (LOWORD(wParam)) { - case IDC_MESSAGE: + case IDC_SRMM_MESSAGE: EnableWindow(m_btnOk.GetHwnd(), GetRichTextLength(m_message.GetHwnd()) != 0); break; } diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index fa99f057f7..e4631281f8 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define ENTERCLICKTIME 1000 //max time in ms during which a double-tap on enter will cause a send -static const UINT sendControls[] = { IDC_MESSAGE }; +static const UINT sendControls[] = { IDC_SRMM_MESSAGE }; void NotifyLocalWinEvent(MCONTACT hContact, HWND hwnd, unsigned int type) { @@ -45,8 +45,8 @@ void NotifyLocalWinEvent(MCONTACT hContact, HWND hwnd, unsigned int type) mwe.szModule = SRMMMOD; mwe.uType = type; mwe.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH; - mwe.hwndInput = GetDlgItem(hwnd, IDC_MESSAGE); - mwe.hwndLog = GetDlgItem(hwnd, IDC_LOG); + mwe.hwndInput = GetDlgItem(hwnd, IDC_SRMM_MESSAGE); + mwe.hwndLog = GetDlgItem(hwnd, IDC_SRMM_LOG); NotifyEventHooks(hHookWinEvt, 0, (LPARAM)&mwe); } } @@ -117,15 +117,11 @@ static void SetEditorText(HWND hwnd, const wchar_t* txt) CSrmmWindow::CSrmmWindow(MCONTACT hContact, bool noActivate, const char *szInitialText, bool bIsUnicode) : CSrmmBaseDialog(g_hInst, IDD_MSG), - m_log(this, IDC_LOG), - m_message(this, IDC_MESSAGE), m_splitter(this, IDC_SPLITTERY), m_btnOk(this, IDOK), m_cmdList(20), m_bNoActivate(noActivate) { - m_pLog = &m_log; - m_pEntry = &m_message; m_hContact = hContact; m_btnOk.OnClick = Callback(this, &CSrmmWindow::onClick_Ok); @@ -611,7 +607,7 @@ void CSrmmWindow::UpdateReadChars() int CSrmmWindow::Resizer(UTILRESIZECONTROL *urc) { switch (urc->wId) { - case IDC_LOG: + case IDC_SRMM_LOG: if (!g_dat.bShowButtons) urc->rcItem.top -= m_lineHeight; urc->rcItem.bottom -= m_splitterPos - m_originalSplitterPos; @@ -622,7 +618,7 @@ int CSrmmWindow::Resizer(UTILRESIZECONTROL *urc) urc->rcItem.bottom -= m_splitterPos - m_originalSplitterPos; return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM; - case IDC_MESSAGE: + case IDC_SRMM_MESSAGE: if (!g_dat.bSendButton) urc->rcItem.right = urc->dlgNewSize.cx - urc->rcItem.left; if (g_dat.bShowAvatar && m_avatarPic) @@ -1321,7 +1317,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), FALSE); break; - case IDC_MESSAGE: + case IDC_SRMM_MESSAGE: if (HIWORD(wParam) == EN_CHANGE) { int len = GetWindowTextLength(m_message.GetHwnd()); UpdateReadChars(); @@ -1353,7 +1349,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) HCURSOR hCur; switch (((LPNMHDR)lParam)->idFrom) { - case IDC_LOG: + case IDC_SRMM_LOG: switch (((LPNMHDR)lParam)->code) { case EN_MSGFILTER: switch (((MSGFILTER *)lParam)->msg) { @@ -1409,7 +1405,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) break; case EN_VSCROLL: - if (LOWORD(wParam) == IDC_LOG && GetWindowLongPtr((HWND)lParam, GWL_STYLE) & WS_VSCROLL) { + if (LOWORD(wParam) == IDC_SRMM_LOG && GetWindowLongPtr((HWND)lParam, GWL_STYLE) & WS_VSCROLL) { SCROLLINFO si = {}; si.cbSize = sizeof(si); si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index b4eb69150f..8db9ac92a7 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -398,59 +398,57 @@ void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, bool bAppend) BOOL bottomScroll = TRUE; POINT scrollPos; - HWND hwndLog = GetDlgItem(m_hwnd, IDC_LOG); - - SendMessage(hwndLog, WM_SETREDRAW, FALSE, 0); - SendMessage(hwndLog, EM_EXGETSEL, 0, (LPARAM)&oldSel); + m_log.SendMsg(WM_SETREDRAW, FALSE, 0); + m_log.SendMsg(EM_EXGETSEL, 0, (LPARAM)&oldSel); LogStreamData streamData = {}; streamData.hContact = m_hContact; streamData.hDbEvent = hDbEventFirst; streamData.dlgDat = this; streamData.eventsToInsert = count; - streamData.isEmpty = !bAppend || GetWindowTextLength(hwndLog) == 0; + streamData.isEmpty = !bAppend || GetWindowTextLength(m_log.GetHwnd()) == 0; EDITSTREAM stream = {}; stream.pfnCallback = LogStreamInEvents; stream.dwCookie = (DWORD_PTR)&streamData; if (!streamData.isEmpty) { - bottomScroll = (GetFocus() != hwndLog); - if (bottomScroll && (GetWindowLongPtr(hwndLog, GWL_STYLE) & WS_VSCROLL)) { + bottomScroll = (GetFocus() != m_log.GetHwnd()); + if (bottomScroll && (GetWindowLongPtr(m_log.GetHwnd(), GWL_STYLE) & WS_VSCROLL)) { SCROLLINFO si = {}; si.cbSize = sizeof(si); si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; - GetScrollInfo(hwndLog, SB_VERT, &si); + GetScrollInfo(m_log.GetHwnd(), SB_VERT, &si); bottomScroll = (si.nPos + (int)si.nPage) >= si.nMax; } if (!bottomScroll) - SendMessage(hwndLog, EM_GETSCROLLPOS, 0, (LPARAM)&scrollPos); + m_log.SendMsg(EM_GETSCROLLPOS, 0, (LPARAM)&scrollPos); } if (bAppend) { sel.cpMin = sel.cpMax = -1; - SendMessage(hwndLog, EM_EXSETSEL, 0, (LPARAM)&sel); + m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); } mir_strcpy(szSep2, bAppend ? "\\par\\sl0" : "\\sl1000"); mir_strcpy(szSep2_RTL, bAppend ? "\\rtlpar\\rtlmark\\par\\sl1000" : "\\sl1000"); - SendMessage(hwndLog, EM_STREAMIN, bAppend ? SFF_SELECTION | SF_RTF : SF_RTF, (LPARAM)&stream); + m_log.SendMsg(EM_STREAMIN, bAppend ? SFF_SELECTION | SF_RTF : SF_RTF, (LPARAM)&stream); if (bottomScroll) { sel.cpMin = sel.cpMax = -1; - SendMessage(hwndLog, EM_EXSETSEL, 0, (LPARAM)&sel); - if (GetWindowLongPtr(hwndLog, GWL_STYLE) & WS_VSCROLL) { + m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); + if (GetWindowLongPtr(m_log.GetHwnd(), GWL_STYLE) & WS_VSCROLL) { SendMessage(m_hwnd, DM_SCROLLLOGTOBOTTOM, 0, 0); PostMessage(m_hwnd, DM_SCROLLLOGTOBOTTOM, 0, 0); } } else { - SendMessage(hwndLog, EM_EXSETSEL, 0, (LPARAM)&oldSel); - SendMessage(hwndLog, EM_SETSCROLLPOS, 0, (LPARAM)&scrollPos); + m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&oldSel); + m_log.SendMsg(EM_SETSCROLLPOS, 0, (LPARAM)&scrollPos); } - SendMessage(hwndLog, WM_SETREDRAW, TRUE, 0); + m_log.SendMsg(WM_SETREDRAW, TRUE, 0); if (bottomScroll) - RedrawWindow(hwndLog, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); + RedrawWindow(m_log.GetHwnd(), NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); m_hDbEventLast = streamData.hDbEventLast; } diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 5e0c8e767d..e9f25b410a 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -113,11 +113,11 @@ INT_PTR SendMessageCmd(MCONTACT hContact, char *msg, int isWchar) HWND hwnd = WindowList_Find(pci->hWindowList, hContact); if (hwnd) { if (msg) { - SendDlgItemMessage(hwnd, IDC_MESSAGE, EM_SETSEL, -1, SendDlgItemMessage(hwnd, IDC_MESSAGE, WM_GETTEXTLENGTH, 0, 0)); + SendDlgItemMessage(hwnd, IDC_SRMM_MESSAGE, EM_SETSEL, -1, SendDlgItemMessage(hwnd, IDC_SRMM_MESSAGE, WM_GETTEXTLENGTH, 0, 0)); if (isWchar) - SendDlgItemMessageW(hwnd, IDC_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)msg); + SendDlgItemMessageW(hwnd, IDC_SRMM_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)msg); else - SendDlgItemMessageA(hwnd, IDC_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)msg); + SendDlgItemMessageA(hwnd, IDC_SRMM_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)msg); } ShowWindow(hwnd, SW_RESTORE); SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index 83bdc4f3d2..aa365e17d1 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -57,7 +57,6 @@ class CSrmmWindow : public CSrmmBaseDialog virtual LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) override; CCtrlButton m_btnOk; - CCtrlEdit m_log, m_message; CSplitter m_splitter; void NotifyTyping(int mode); diff --git a/src/core/stdmsg/src/resource.h b/src/core/stdmsg/src/resource.h index af3f02dbc0..9deadabd3e 100644 --- a/src/core/stdmsg/src/resource.h +++ b/src/core/stdmsg/src/resource.h @@ -63,8 +63,6 @@ #define IDD_MODERNOPT_MSGDLG 288 #define IDD_MODERNOPT_MSGLOG 289 -#define IDC_LOG 1001 -#define IDC_MESSAGE 1002 #define IDC_SPLITTERX 1003 #define IDC_AUTOCLOSE 1004 #define IDC_AUTOMIN 1005 diff --git a/src/core/stdmsg/src/richutil.cpp b/src/core/stdmsg/src/richutil.cpp index 551daf33de..b461d91e26 100644 --- a/src/core/stdmsg/src/richutil.cpp +++ b/src/core/stdmsg/src/richutil.cpp @@ -97,7 +97,7 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM switch (msg) { case WM_CHAR: { - HWND hwndMsg = GetDlgItem(GetParent(hwnd), IDC_MESSAGE); + HWND hwndMsg = GetDlgItem(GetParent(hwnd), IDC_SRMM_MESSAGE); if (hwndMsg != hwnd) { SetFocus(hwndMsg); if (wParam != '\t') SendMessage(hwndMsg, WM_CHAR, wParam, lParam); diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index c09f311e83..08f35ac924 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -218,7 +218,6 @@ class CChatRoomDlg : public CSrmmBaseDialog HWND m_hwndStatus; wchar_t szTabSave[20]; - CCtrlEdit m_message, m_log; CCtrlButton m_btnOk; CSplitter m_splitterX, m_splitterY; diff --git a/src/mir_app/src/colorchooser.cpp b/src/mir_app/src/colorchooser.cpp index 6422e4020a..311f61ea69 100644 --- a/src/mir_app/src/colorchooser.cpp +++ b/src/mir_app/src/colorchooser.cpp @@ -267,6 +267,6 @@ public: void CSrmmBaseDialog::ShowColorChooser(int iCtrlId) { - CColorChooserDlg *pDialog = new CColorChooserDlg(m_si, iCtrlId == IDC_SRMM_COLOR, m_hwnd, m_pEntry->GetHwnd(), GetDlgItem(m_hwnd, iCtrlId)); + CColorChooserDlg *pDialog = new CColorChooserDlg(m_si, iCtrlId == IDC_SRMM_COLOR, m_hwnd, m_message.GetHwnd(), GetDlgItem(m_hwnd, iCtrlId)); pDialog->Show(); } diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index 689776bedd..8bbc5c4d92 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -30,6 +30,8 @@ extern HCURSOR g_hCurHyperlinkHand; CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si) : CDlgBase(hInst, idDialog), + m_log(this, IDC_SRMM_LOG), + m_message(this, IDC_SRMM_MESSAGE), m_nickList(this, IDC_SRMM_NICKLIST), m_btnFilter(this, IDC_SRMM_FILTER), @@ -45,8 +47,6 @@ CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si m_btnUnderline(this, IDC_SRMM_UNDERLINE), m_si(si), - m_pLog(nullptr), - m_pEntry(nullptr), m_hContact(0), m_clrInputBG(GetSysColor(COLOR_WINDOW)) { @@ -82,9 +82,10 @@ CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si CSrmmBaseDialog::CSrmmBaseDialog(const CSrmmBaseDialog&) : CDlgBase(0, 0), - m_btnColor(0, 0), m_btnBkColor(0, 0), m_nickList(0, 0), + m_btnColor(0, 0), m_btnBkColor(0, 0), m_btnBold(0, 0), m_btnItalic(0, 0), m_btnUnderline(0, 0), - m_btnFilter(0, 0), m_btnChannelMgr(0, 0), m_btnHistory(0, 0), m_btnNickList(0, 0) + m_btnFilter(0, 0), m_btnChannelMgr(0, 0), m_btnHistory(0, 0), m_btnNickList(0, 0), + m_nickList(0, 0), m_log(0, 0), m_message(0, 0) { } @@ -176,11 +177,11 @@ static LRESULT CALLBACK stubNicklistProc(HWND hwnd, UINT msg, WPARAM wParam, LPA void CSrmmBaseDialog::OnInitDialog() { - SetWindowLongPtr(m_pLog->GetHwnd(), GWLP_USERDATA, LPARAM(this)); - mir_subclassWindow(m_pLog->GetHwnd(), stubLogProc); + SetWindowLongPtr(m_log.GetHwnd(), GWLP_USERDATA, LPARAM(this)); + mir_subclassWindow(m_log.GetHwnd(), stubLogProc); - SetWindowLongPtr(m_pEntry->GetHwnd(), GWLP_USERDATA, LPARAM(this)); - mir_subclassWindow(m_pEntry->GetHwnd(), stubMessageProc); + SetWindowLongPtr(m_message.GetHwnd(), GWLP_USERDATA, LPARAM(this)); + mir_subclassWindow(m_message.GetHwnd(), stubMessageProc); SetWindowLongPtr(m_nickList.GetHwnd(), GWLP_USERDATA, LPARAM(this)); mir_subclassWindow(m_nickList.GetHwnd(), stubNicklistProc); @@ -195,8 +196,8 @@ void CSrmmBaseDialog::OnInitDialog() void CSrmmBaseDialog::OnDestroy() { SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0); - mir_unsubclassWindow(m_pLog->GetHwnd(), stubLogProc); - mir_unsubclassWindow(m_pEntry->GetHwnd(), stubMessageProc); + mir_unsubclassWindow(m_log.GetHwnd(), stubLogProc); + mir_unsubclassWindow(m_message.GetHwnd(), stubMessageProc); mir_unsubclassWindow(m_nickList.GetHwnd(), stubNicklistProc); } @@ -216,67 +217,64 @@ INT_PTR CSrmmBaseDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) break; 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) + LPNMHDR hdr = (LPNMHDR)lParam; + if (hdr->hwndFrom == m_log.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_log.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_log.SendMsg(EM_GETTEXTRANGE, 0, (LPARAM)&tr); + if (wcschr(tr.lpstrText, '@') != nullptr && wcschr(tr.lpstrText, ':') == nullptr && wcschr(tr.lpstrText, '/') == nullptr) + 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, nullptr)) { + case IDM_OPENLINK: + Utils_OpenUrlW(wszText); 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, '@') != nullptr && wcschr(tr.lpstrText, ':') == nullptr && wcschr(tr.lpstrText, '/') == nullptr) - 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, nullptr)) { - 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; + 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(); } - - DestroyMenu(hMenu); - SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE); - return TRUE; + break; } - Utils_OpenUrlW(wszText); - if (m_pEntry != nullptr) - SetFocus(m_pEntry->GetHwnd()); + DestroyMenu(hMenu); + SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE); + return TRUE; } + + Utils_OpenUrlW(wszText); + SetFocus(m_message.GetHwnd()); } } break; @@ -295,8 +293,7 @@ void CSrmmBaseDialog::AddLog() void CSrmmBaseDialog::ClearLog() { - if (m_pLog != nullptr) - m_pLog->SetText(L""); + m_log.SetText(L""); } void CSrmmBaseDialog::DoEventHook(int iType, const USERINFO *pUser, const wchar_t *pszText, INT_PTR dwItem) @@ -347,7 +344,7 @@ void CSrmmBaseDialog::onClick_Color(CCtrlButton *pButton) } else cf.crTextColor = m_clrInputFG; - m_pEntry->SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); + m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); } void CSrmmBaseDialog::onClick_BkColor(CCtrlButton *pButton) @@ -370,7 +367,7 @@ void CSrmmBaseDialog::onClick_BkColor(CCtrlButton *pButton) } else cf.crBackColor = m_clrInputBG; - m_pEntry->SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); + m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); } void CSrmmBaseDialog::onClick_BIU(CCtrlButton *pButton) @@ -389,7 +386,7 @@ void CSrmmBaseDialog::onClick_BIU(CCtrlButton *pButton) cf.dwEffects |= CFE_ITALIC; if (IsDlgButtonChecked(m_hwnd, IDC_SRMM_UNDERLINE)) cf.dwEffects |= CFE_UNDERLINE; - m_pEntry->SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); + m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); } void CSrmmBaseDialog::onClick_History(CCtrlButton *pButton) @@ -425,15 +422,15 @@ void CSrmmBaseDialog::onDblClick_List(CCtrlListBox *pList) bool bShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0; if (g_Settings->bDoubleClick4Privat ? bShift : !bShift) { - int selStart = LOWORD(m_pEntry->SendMsg(EM_GETSEL, 0, 0)); + int selStart = LOWORD(m_message.SendMsg(EM_GETSEL, 0, 0)); CMStringW tszName(ui->pszNick); if (selStart == 0) tszName.AppendChar(':'); tszName.AppendChar(' '); - m_pEntry->SendMsg(EM_REPLACESEL, FALSE, (LPARAM)tszName.GetString()); + m_message.SendMsg(EM_REPLACESEL, FALSE, (LPARAM)tszName.GetString()); PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0); - SetFocus(m_pEntry->GetHwnd()); + SetFocus(m_message.GetHwnd()); } else DoEventHook(GC_USER_PRIVMESS, ui, nullptr, 0); } @@ -502,7 +499,7 @@ void CSrmmBaseDialog::RefreshButtonStatus(void) CHARFORMAT2 cf; cf.cbSize = sizeof(CHARFORMAT2); cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_BACKCOLOR | CFM_COLOR; - m_pEntry->SendMsg(EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); + m_message.SendMsg(EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); MODULEINFO *mi = chatApi.MM_FindModule(m_si->pszModule); if (mi == nullptr) -- cgit v1.2.3