diff options
author | George Hazan <ghazan@miranda.im> | 2016-12-19 20:22:56 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2016-12-19 20:22:56 +0300 |
commit | 82b95bacaf3da5ea519151e14d3281426e07bf2c (patch) | |
tree | db380529aed4507784a499ab52feafc804c68942 /src | |
parent | e1ab2684f17f146e1ef5127ceeba14f4c025987f (diff) |
SRMM window packed into a class
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdmsg/src/globals.h | 25 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 1148 | ||||
-rw-r--r-- | src/core/stdmsg/src/msglog.cpp | 22 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.cpp | 25 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.h | 113 |
5 files changed, 659 insertions, 674 deletions
diff --git a/src/core/stdmsg/src/globals.h b/src/core/stdmsg/src/globals.h index 62ac31a094..2623cd40bc 100644 --- a/src/core/stdmsg/src/globals.h +++ b/src/core/stdmsg/src/globals.h @@ -61,4 +61,29 @@ void ReloadGlobals(); extern GlobalMessageData g_dat;
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct CREOleCallback : public IRichEditOleCallback
+{
+ CREOleCallback() : refCount(0), nextStgId(0), pictStg(NULL) {}
+ unsigned refCount;
+ IStorage *pictStg;
+ int nextStgId;
+
+ STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * lplpObj);
+ STDMETHOD_(ULONG, AddRef)(THIS);
+ STDMETHOD_(ULONG, Release)(THIS);
+
+ STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode);
+ STDMETHOD(GetNewStorage)(LPSTORAGE FAR * lplpstg);
+ STDMETHOD(GetInPlaceContext)(LPOLEINPLACEFRAME FAR * lplpFrame, LPOLEINPLACEUIWINDOW FAR * lplpDoc, LPOLEINPLACEFRAMEINFO lpFrameInfo);
+ STDMETHOD(ShowContainerUI)(BOOL fShow);
+ STDMETHOD(QueryInsertObject)(LPCLSID lpclsid, LPSTORAGE lpstg, LONG cp);
+ STDMETHOD(DeleteObject)(LPOLEOBJECT lpoleobj);
+ STDMETHOD(QueryAcceptData)(LPDATAOBJECT lpdataobj, CLIPFORMAT FAR * lpcfFormat, DWORD reco, BOOL fReally, HGLOBAL hMetaPict);
+ STDMETHOD(GetClipboardData)(CHARRANGE FAR *lpchrg, DWORD reco, LPDATAOBJECT FAR * lplpdataobj);
+ STDMETHOD(GetDragDropEffect)(BOOL fDrag, DWORD grfKeyState, LPDWORD pdwEffect);
+ STDMETHOD(GetContextMenu)(WORD seltype, LPOLEOBJECT lpoleobj, CHARRANGE FAR * lpchrg, HMENU FAR * lphmenu);
+};
+
#endif
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index ec5488d3a4..aff232bdf0 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -118,32 +118,32 @@ static void UpdateReadChars(HWND hwndDlg, HWND hwndStatus) }
}
-static void ShowTime(SrmmWindowData *dat)
+static void ShowTime(CSrmmWindow *dat)
{
- if (dat->hwndStatus && dat->hTimeZone) {
+ if (dat->m_hwndStatus && dat->m_hTimeZone) {
SYSTEMTIME st;
GetSystemTime(&st);
- if (dat->wMinute != st.wMinute) {
+ if (dat->m_wMinute != st.wMinute) {
wchar_t buf[32];
unsigned i = g_dat.bShowReadChar ? 2 : 1;
- TimeZone_PrintDateTime(dat->hTimeZone, L"t", buf, _countof(buf), 0);
- SendMessage(dat->hwndStatus, SB_SETTEXT, i, (LPARAM)buf);
- dat->wMinute = st.wMinute;
+ TimeZone_PrintDateTime(dat->m_hTimeZone, L"t", buf, _countof(buf), 0);
+ SendMessage(dat->m_hwndStatus, SB_SETTEXT, i, (LPARAM)buf);
+ dat->m_wMinute = st.wMinute;
}
}
}
-static void SetupStatusBar(HWND hwndDlg, SrmmWindowData *dat)
+static void SetupStatusBar(HWND hwndDlg, CSrmmWindow *dat)
{
int i = 0, statwidths[4];
- int icons_width = GetStatusIconsCount(dat->hContact) * (GetSystemMetrics(SM_CXSMICON) + 2) + SB_GRIP_WIDTH;
+ int icons_width = GetStatusIconsCount(dat->m_hContact) * (GetSystemMetrics(SM_CXSMICON) + 2) + SB_GRIP_WIDTH;
RECT rc;
- GetWindowRect(dat->hwndStatus, &rc);
+ GetWindowRect(dat->m_hwndStatus, &rc);
int cx = rc.right - rc.left;
- if (dat->hTimeZone) {
+ if (dat->m_hTimeZone) {
if (g_dat.bShowReadChar)
statwidths[i++] = cx - SB_TIME_WIDTH - SB_CHAR_WIDTH - icons_width;
statwidths[i++] = cx - SB_TIME_WIDTH - icons_width;
@@ -153,50 +153,13 @@ static void SetupStatusBar(HWND hwndDlg, SrmmWindowData *dat) statwidths[i++] = cx - icons_width;
statwidths[i++] = -1;
- SendMessage(dat->hwndStatus, SB_SETPARTS, i, (LPARAM)statwidths);
+ SendMessage(dat->m_hwndStatus, SB_SETPARTS, i, (LPARAM)statwidths);
- UpdateReadChars(hwndDlg, dat->hwndStatus);
+ UpdateReadChars(hwndDlg, dat->m_hwndStatus);
ShowTime(dat);
SendMessage(hwndDlg, DM_STATUSICONCHANGE, 0, 0);
}
-static void SetDialogToType(HWND hwndDlg)
-{
- SrmmWindowData *dat = (SrmmWindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
-
- CustomButtonData *cbd;
- for (int i = 0; cbd = Srmm_GetNthButton(i); i++) {
- HWND hwndButton = GetDlgItem(hwndDlg, cbd->m_dwButtonCID);
- if (hwndButton == NULL)
- continue;
-
- bool bShow = false;
- if (dat->hContact) {
- if (cbd->m_dwButtonCID == IDC_ADD) {
- bShow = 0 != db_get_b(dat->hContact, "CList", "NotOnList", 0);
- cbd->m_bHidden = !bShow;
- }
- else bShow = g_dat.bShowButtons;
- }
- ShowWindow(hwndButton, (bShow) ? SW_SHOW : SW_HIDE);
- }
-
- if (!dat->hwndStatus) {
- int grip = (GetWindowLongPtr(hwndDlg, GWL_STYLE) & WS_THICKFRAME) ? SBARS_SIZEGRIP : 0;
- dat->hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | grip, 0, 0, 0, 0, hwndDlg, NULL, g_hInst, NULL);
- SendMessage(dat->hwndStatus, SB_SETMINHEIGHT, GetSystemMetrics(SM_CYSMICON), 0);
- }
-
- ShowWindow(GetDlgItem(hwndDlg, IDCANCEL), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_SPLITTERY), SW_SHOW);
- ShowWindow(GetDlgItem(hwndDlg, IDOK), g_dat.bSendButton ? SW_SHOW : SW_HIDE);
- EnableWindow(GetDlgItem(hwndDlg, IDOK), GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE)) != 0);
- if (dat->avatarPic == NULL || !g_dat.bShowAvatar)
- ShowWindow(GetDlgItem(hwndDlg, IDC_AVATAR), SW_HIDE);
- SendMessage(hwndDlg, DM_UPDATETITLE, 0, 0);
- SendMessage(hwndDlg, WM_SIZE, 0, 0);
-}
-
struct MsgEditSubclassData
{
DWORD lastEnterTime;
@@ -212,7 +175,7 @@ static void SetEditorText(HWND hwnd, const wchar_t* txt) static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- SrmmWindowData *pdat = (SrmmWindowData *)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA);
+ CSrmmWindow *pdat = (CSrmmWindow *)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA);
struct MsgEditSubclassData *dat = (struct MsgEditSubclassData *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
switch (msg) {
@@ -267,32 +230,32 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar }
if (wParam == VK_UP && (GetKeyState(VK_CONTROL) & 0x8000) && g_dat.bCtrlSupport && !g_dat.bAutoClose) {
- if (pdat->cmdList.getCount()) {
- if (pdat->cmdListInd < 0) {
- pdat->cmdListInd = pdat->cmdList.getCount() - 1;
- SetEditorText(hwnd, pdat->cmdList[pdat->cmdListInd]);
+ if (pdat->m_cmdList.getCount()) {
+ if (pdat->m_cmdListInd < 0) {
+ pdat->m_cmdListInd = pdat->m_cmdList.getCount() - 1;
+ SetEditorText(hwnd, pdat->m_cmdList[pdat->m_cmdListInd]);
}
- else if (pdat->cmdListInd > 0) {
- SetEditorText(hwnd, pdat->cmdList[--pdat->cmdListInd]);
+ else if (pdat->m_cmdListInd > 0) {
+ SetEditorText(hwnd, pdat->m_cmdList[--pdat->m_cmdListInd]);
}
}
EnableWindow(GetDlgItem(GetParent(hwnd), IDOK), GetWindowTextLength(hwnd) != 0);
- UpdateReadChars(GetParent(hwnd), pdat->hwndStatus);
+ UpdateReadChars(GetParent(hwnd), pdat->m_hwndStatus);
return 0;
}
if (wParam == VK_DOWN && (GetKeyState(VK_CONTROL) & 0x8000) && g_dat.bCtrlSupport && !g_dat.bAutoClose) {
- if (pdat->cmdList.getCount() && pdat->cmdListInd >= 0) {
- if (pdat->cmdListInd < (pdat->cmdList.getCount() - 1))
- SetEditorText(hwnd, pdat->cmdList[++pdat->cmdListInd]);
+ if (pdat->m_cmdList.getCount() && pdat->m_cmdListInd >= 0) {
+ if (pdat->m_cmdListInd < (pdat->m_cmdList.getCount() - 1))
+ SetEditorText(hwnd, pdat->m_cmdList[++pdat->m_cmdListInd]);
else {
- pdat->cmdListInd = -1;
- SetEditorText(hwnd, pdat->cmdList[pdat->cmdList.getCount() - 1]);
+ pdat->m_cmdListInd = -1;
+ SetEditorText(hwnd, pdat->m_cmdList[pdat->m_cmdList.getCount() - 1]);
}
}
EnableWindow(GetDlgItem(GetParent(hwnd), IDOK), GetWindowTextLength(hwnd) != 0);
- UpdateReadChars(GetParent(hwnd), pdat->hwndStatus);
+ UpdateReadChars(GetParent(hwnd), pdat->m_hwndStatus);
}
break;
@@ -320,7 +283,7 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar mwpd.cbSize = sizeof(mwpd);
mwpd.uType = MSG_WINDOWPOPUP_SHOWING;
mwpd.uFlags = MSG_WINDOWPOPUP_INPUT;
- mwpd.hContact = pdat->hContact;
+ mwpd.hContact = pdat->m_hContact;
mwpd.hwnd = hwnd;
HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT));
@@ -466,78 +429,303 @@ static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, static int MessageDialogResize(HWND, LPARAM lParam, UTILRESIZECONTROL *urc)
{
- SrmmWindowData *dat = (SrmmWindowData*)lParam;
+ CSrmmWindow *dat = (CSrmmWindow*)lParam;
switch (urc->wId) {
case IDC_LOG:
if (!g_dat.bShowButtons)
- urc->rcItem.top -= dat->lineHeight;
- urc->rcItem.bottom -= dat->splitterPos - dat->originalSplitterPos;
+ urc->rcItem.top -= dat->m_lineHeight;
+ urc->rcItem.bottom -= dat->m_splitterPos - dat->m_originalSplitterPos;
return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
case IDC_SPLITTERY:
- urc->rcItem.top -= dat->splitterPos - dat->originalSplitterPos;
- urc->rcItem.bottom -= dat->splitterPos - dat->originalSplitterPos;
+ urc->rcItem.top -= dat->m_splitterPos - dat->m_originalSplitterPos;
+ urc->rcItem.bottom -= dat->m_splitterPos - dat->m_originalSplitterPos;
return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
case IDC_MESSAGE:
if (!g_dat.bSendButton)
urc->rcItem.right = urc->dlgNewSize.cx - urc->rcItem.left;
- if (g_dat.bShowAvatar && dat->avatarPic)
- urc->rcItem.left = dat->avatarWidth + 4;
+ if (g_dat.bShowAvatar && dat->m_avatarPic)
+ urc->rcItem.left = dat->m_avatarWidth + 4;
- urc->rcItem.top -= dat->splitterPos - dat->originalSplitterPos;
+ urc->rcItem.top -= dat->m_splitterPos - dat->m_originalSplitterPos;
if (!g_dat.bSendButton)
return RD_ANCHORX_CUSTOM | RD_ANCHORY_BOTTOM;
return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
case IDCANCEL:
case IDOK:
- urc->rcItem.top -= dat->splitterPos - dat->originalSplitterPos;
+ urc->rcItem.top -= dat->m_splitterPos - dat->m_originalSplitterPos;
return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
case IDC_AVATAR:
- urc->rcItem.top = urc->rcItem.bottom - (dat->avatarHeight + 2);
- urc->rcItem.right = urc->rcItem.left + (dat->avatarWidth + 2);
+ urc->rcItem.top = urc->rcItem.bottom - (dat->m_avatarHeight + 2);
+ urc->rcItem.right = urc->rcItem.left + (dat->m_avatarWidth + 2);
return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
}
return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
}
-void ShowAvatar(HWND hwndDlg, SrmmWindowData *dat)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+CSrmmWindow::CSrmmWindow(MCONTACT hContact, bool noActivate, const char *szInitialText, bool bIsUnicode)
+ : CDlgBase(g_hInst, IDD_MSG),
+ m_cmdList(20),
+ m_bNoActivate(noActivate),
+ m_hContact(hContact)
{
- if (g_dat.bShowAvatar) {
- AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, dat->getActiveContact(), 0);
- if (ace && (INT_PTR)ace != CALLSERVICE_NOTFOUND && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST))
- dat->avatarPic = ace->hbmPic;
+ m_wszInitialText = (bIsUnicode) ? mir_wstrdup((wchar_t*)szInitialText) : mir_a2u(szInitialText);
+}
+
+void CSrmmWindow::OnInitDialog()
+{
+ SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LPARAM)this);
+
+ m_bIsMeta = db_mc_isMeta(m_hContact) != 0;
+ m_hTimeZone = TimeZone_CreateByContact(m_hContact, 0, TZF_KNOWNONLY);
+ m_wMinute = 61;
+
+ NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_OPENING);
+ if (m_wszInitialText) {
+ SetDlgItemText(m_hwnd, IDC_MESSAGE, m_wszInitialText);
+
+ int len = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_MESSAGE));
+ PostMessage(GetDlgItem(m_hwnd, IDC_MESSAGE), EM_SETSEL, len, len);
+ mir_free(m_wszInitialText);
+ }
+
+ m_szProto = GetContactProto(m_hContact);
+ RichUtil_SubClass(GetDlgItem(m_hwnd, IDC_LOG));
+ RichUtil_SubClass(GetDlgItem(m_hwnd, IDC_MESSAGE));
+
+ // avatar stuff
+ m_limitAvatarH = db_get_b(NULL, SRMMMOD, SRMSGSET_LIMITAVHEIGHT, SRMSGDEFSET_LIMITAVHEIGHT) ? db_get_dw(NULL, SRMMMOD, SRMSGSET_AVHEIGHT, SRMSGDEFSET_AVHEIGHT) : 0;
+
+ if (m_hContact && m_szProto != NULL)
+ m_wStatus = db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE);
+ else
+ m_wStatus = ID_STATUS_OFFLINE;
+ m_wOldStatus = m_wStatus;
+ m_splitterPos = (int)db_get_dw(g_dat.bSavePerContact ? m_hContact : NULL, SRMMMOD, "splitterPos", (DWORD)-1);
+ m_cmdListInd = -1;
+ m_nTypeMode = PROTOTYPE_SELFTYPING_OFF;
+ SetTimer(m_hwnd, TIMERID_TYPE, 1000, NULL);
+
+ RECT rc;
+ GetWindowRect(GetDlgItem(m_hwnd, IDC_SPLITTERY), &rc);
+ POINT pt = { 0, (rc.top + rc.bottom) / 2 };
+ ScreenToClient(m_hwnd, &pt);
+ m_originalSplitterPos = pt.y;
+ if (m_splitterPos == -1)
+ m_splitterPos = m_originalSplitterPos;
+
+ Srmm_CreateToolbarIcons(m_hwnd, BBBF_ISIMBUTTON);
+
+ WindowList_Add(pci->hWindowList, m_hwnd, m_hContact);
+ GetWindowRect(GetDlgItem(m_hwnd, IDC_MESSAGE), &m_minEditInit);
+ SendMessage(m_hwnd, DM_UPDATESIZEBAR, 0, 0);
+ m_hwndStatus = NULL;
+
+ EnableWindow(GetDlgItem(m_hwnd, IDC_AVATAR), FALSE);
+
+ SendDlgItemMessage(m_hwnd, IDC_LOG, EM_SETOLECALLBACK, 0, (LPARAM)&reOleCallback);
+ SendDlgItemMessage(m_hwnd, IDC_LOG, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_LINK | ENM_SCROLL);
+ SendDlgItemMessage(m_hwnd, IDC_LOG, EM_AUTOURLDETECT, TRUE, 0);
+
+ if (m_hContact && m_szProto) {
+ int nMax = CallProtoService(m_szProto, PS_GETCAPS, PFLAG_MAXLENOFMESSAGE, m_hContact);
+ if (nMax)
+ SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_LIMITTEXT, nMax, 0);
+
+ // get around a lame bug in the Windows template resource code where richedits are limited to 0x7FFF
+ SendDlgItemMessage(m_hwnd, IDC_LOG, EM_LIMITTEXT, sizeof(wchar_t) * 0x7FFFFFFF, 0);
+ }
+
+ mir_subclassWindow(GetDlgItem(m_hwnd, IDC_MESSAGE), MessageEditSubclassProc);
+ SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_SUBCLASSED, 0, 0);
+ mir_subclassWindow(GetDlgItem(m_hwnd, IDC_SPLITTERY), SplitterSubclassProc);
+
+ if (m_hContact) {
+ int historyMode = db_get_b(NULL, SRMMMOD, SRMSGSET_LOADHISTORY, SRMSGDEFSET_LOADHISTORY);
+ // This finds the first message to display, it works like shit
+ m_hDbEventFirst = db_event_firstUnread(m_hContact);
+ switch (historyMode) {
+ case LOADHISTORY_COUNT:
+ for (int i = db_get_w(NULL, SRMMMOD, SRMSGSET_LOADCOUNT, SRMSGDEFSET_LOADCOUNT); i--;) {
+ MEVENT hPrevEvent;
+ if (m_hDbEventFirst == NULL)
+ hPrevEvent = db_event_last(m_hContact);
+ else
+ hPrevEvent = db_event_prev(m_hContact, m_hDbEventFirst);
+ if (hPrevEvent == NULL)
+ break;
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ m_hDbEventFirst = hPrevEvent;
+ db_event_get(hPrevEvent, &dbei);
+ if (!DbEventIsShown(&dbei))
+ i++;
+ }
+ break;
+
+ case LOADHISTORY_TIME:
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if (m_hDbEventFirst == NULL)
+ dbei.timestamp = (DWORD)time(NULL);
+ else
+ db_event_get(m_hDbEventFirst, &dbei);
+
+ DWORD firstTime = dbei.timestamp - 60 * db_get_w(NULL, SRMMMOD, SRMSGSET_LOADTIME, SRMSGDEFSET_LOADTIME);
+ for (;;) {
+ MEVENT hPrevEvent;
+ if (m_hDbEventFirst == NULL)
+ hPrevEvent = db_event_last(m_hContact);
+ else
+ hPrevEvent = db_event_prev(m_hContact, m_hDbEventFirst);
+ if (hPrevEvent == NULL)
+ break;
+
+ dbei.cbBlob = 0;
+ db_event_get(hPrevEvent, &dbei);
+ if (dbei.timestamp < firstTime)
+ break;
+ m_hDbEventFirst = hPrevEvent;
+ }
+ break;
+ }
+ }
+
+ MEVENT hdbEvent = db_event_last(m_hContact);
+ if (hdbEvent) {
+ do {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hdbEvent, &dbei);
+ if ((dbei.eventType == EVENTTYPE_MESSAGE) && !(dbei.flags & DBEF_SENT)) {
+ m_lastMessage = dbei.timestamp;
+ PostMessage(m_hwnd, DM_UPDATELASTMESSAGE, 0, 0);
+ break;
+ }
+ } while (hdbEvent = db_event_prev(m_hContact, hdbEvent));
+ }
+
+ SendMessage(m_hwnd, DM_OPTIONSAPPLIED, 1, 0);
+
+ // restore saved msg if any...
+ if (m_hContact) {
+ DBVARIANT dbv;
+ if (!db_get_ws(m_hContact, SRMSGMOD, DBSAVEDMSG, &dbv)) {
+ if (dbv.ptszVal[0]) {
+ SetDlgItemText(m_hwnd, IDC_MESSAGE, dbv.ptszVal);
+ EnableWindow(GetDlgItem(m_hwnd, IDOK), TRUE);
+ UpdateReadChars(m_hwnd, m_hwndStatus);
+ PostMessage(GetDlgItem(m_hwnd, IDC_MESSAGE), EM_SETSEL, -1, -1);
+ }
+ db_free(&dbv);
+ }
+ }
+ SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_SETEVENTMASK, 0, ENM_CHANGE);
+
+ int flag = m_bNoActivate ? RWPF_HIDDEN : 0;
+ if (Utils_RestoreWindowPosition(m_hwnd, g_dat.bSavePerContact ? m_hContact : NULL, SRMMMOD, "", flag)) {
+ if (g_dat.bSavePerContact) {
+ if (Utils_RestoreWindowPosition(m_hwnd, NULL, SRMMMOD, "", flag | RWPF_NOMOVE))
+ SetWindowPos(m_hwnd, 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW);
+ }
+ else SetWindowPos(m_hwnd, 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW);
+ }
+
+ if (!g_dat.bSavePerContact && g_dat.bCascade)
+ WindowList_Broadcast(pci->hWindowList, DM_CASCADENEWWINDOW, (WPARAM)m_hwnd, (LPARAM)&m_windowWasCascaded);
+
+ if (m_bNoActivate) {
+ SetWindowPos(m_hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
+ SetTimer(m_hwnd, TIMERID_FLASHWND, TIMEOUT_FLASHWND, NULL);
+ }
+ else {
+ SetWindowPos(m_hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
+ SetForegroundWindow(m_hwnd);
+ SetFocus(GetDlgItem(m_hwnd, IDC_MESSAGE));
+ }
+
+ SendMessage(m_hwnd, DM_GETAVATAR, 0, 0);
+ NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_OPEN);
+}
+
+void CSrmmWindow::OnDestroy()
+{
+ SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0);
+ NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_CLOSING);
+
+ // save string from the editor
+ if (m_hContact) {
+ int len = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_MESSAGE)) + 1;
+ wchar_t *msg = (wchar_t*)alloca(sizeof(wchar_t)*len);
+ GetDlgItemText(m_hwnd, IDC_MESSAGE, msg, len);
+ if (msg[0])
+ db_set_ws(m_hContact, SRMSGMOD, DBSAVEDMSG, msg);
else
- dat->avatarPic = NULL;
+ db_unset(m_hContact, SRMSGMOD, DBSAVEDMSG);
}
- else dat->avatarPic = NULL;
+ KillTimer(m_hwnd, TIMERID_TYPE);
+ if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON)
+ NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
- SendMessage(hwndDlg, DM_UPDATESIZEBAR, 0, 0);
- SendMessage(hwndDlg, DM_AVATARSIZECHANGE, 0, 0);
+ if (m_hBkgBrush)
+ DeleteObject(m_hBkgBrush);
+ if (m_hwndStatus)
+ DestroyWindow(m_hwndStatus);
+
+ for (int i = 0; i < m_cmdList.getCount(); i++)
+ mir_free(m_cmdList[i]);
+ m_cmdList.destroy();
+
+ WindowList_Remove(pci->hWindowList, m_hwnd);
+
+ MCONTACT hContact = (g_dat.bSavePerContact) ? m_hContact : NULL;
+ db_set_dw(hContact ? m_hContact : NULL, SRMMMOD, "splitterPos", m_splitterPos);
+
+ if (m_hFont) {
+ DeleteObject(m_hFont);
+ m_hFont = NULL;
+ }
+
+ WINDOWPLACEMENT wp = { sizeof(wp) };
+ GetWindowPlacement(m_hwnd, &wp);
+ if (!m_windowWasCascaded) {
+ db_set_dw(hContact, SRMMMOD, "x", wp.rcNormalPosition.left);
+ db_set_dw(hContact, SRMMMOD, "y", wp.rcNormalPosition.top);
+ }
+ db_set_dw(hContact, SRMMMOD, "width", wp.rcNormalPosition.right - wp.rcNormalPosition.left);
+ db_set_dw(hContact, SRMMMOD, "height", wp.rcNormalPosition.bottom - wp.rcNormalPosition.top);
+
+ NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_CLOSE);
+ if (m_hContact && g_dat.bDeleteTempCont)
+ if (db_get_b(m_hContact, "CList", "NotOnList", 0))
+ db_delete_contact(m_hContact);
+
+ Window_FreeIcon_IcoLib(m_hwnd);
}
-static void NotifyTyping(SrmmWindowData *dat, int mode)
+void CSrmmWindow::NotifyTyping(int mode)
{
- if (!dat->hContact)
+ if (!m_hContact)
return;
+
// Don't send to protocols who don't support typing
// Don't send to users who are unchecked in the typing notification options
// Don't send to protocols that are offline
// Don't send to users who are not visible and
// Don't send to users who are not on the visible list when you are in invisible mode.
-
- if (!db_get_b(dat->hContact, SRMMMOD, SRMSGSET_TYPING, db_get_b(NULL, SRMMMOD, SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW)))
+ if (!db_get_b(m_hContact, SRMMMOD, SRMSGSET_TYPING, db_get_b(NULL, SRMMMOD, SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW)))
return;
- if (!dat->szProto)
+ if (!m_szProto)
return;
- DWORD protoStatus = CallProtoService(dat->szProto, PS_GETSTATUS, 0, 0);
- DWORD protoCaps = CallProtoService(dat->szProto, PS_GETCAPS, PFLAGNUM_1, 0);
- DWORD typeCaps = CallProtoService(dat->szProto, PS_GETCAPS, PFLAGNUM_4, 0);
+ DWORD protoStatus = CallProtoService(m_szProto, PS_GETSTATUS, 0, 0);
+ DWORD protoCaps = CallProtoService(m_szProto, PS_GETCAPS, PFLAGNUM_1, 0);
+ DWORD typeCaps = CallProtoService(m_szProto, PS_GETCAPS, PFLAGNUM_4, 0);
if (!(typeCaps & PF4_SUPPORTTYPING))
return;
@@ -545,232 +733,65 @@ static void NotifyTyping(SrmmWindowData *dat, int mode) if (protoStatus < ID_STATUS_ONLINE)
return;
- if (protoCaps & PF1_VISLIST && db_get_w(dat->hContact, dat->szProto, "ApparentMode", 0) == ID_STATUS_OFFLINE)
+ if (protoCaps & PF1_VISLIST && db_get_w(m_hContact, m_szProto, "ApparentMode", 0) == ID_STATUS_OFFLINE)
return;
- if (protoCaps & PF1_INVISLIST && protoStatus == ID_STATUS_INVISIBLE && db_get_w(dat->hContact, dat->szProto, "ApparentMode", 0) != ID_STATUS_ONLINE)
+ if (protoCaps & PF1_INVISLIST && protoStatus == ID_STATUS_INVISIBLE && db_get_w(m_hContact, m_szProto, "ApparentMode", 0) != ID_STATUS_ONLINE)
return;
- if (!g_dat.bTypingUnknown && db_get_b(dat->hContact, "CList", "NotOnList", 0))
+ if (!g_dat.bTypingUnknown && db_get_b(m_hContact, "CList", "NotOnList", 0))
return;
// End user check
- dat->nTypeMode = mode;
- CallService(MS_PROTO_SELFISTYPING, dat->hContact, dat->nTypeMode);
+ m_nTypeMode = mode;
+ CallService(MS_PROTO_SELFISTYPING, m_hContact, m_nTypeMode);
}
-INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+void CSrmmWindow::ShowAvatar()
+{
+ if (g_dat.bShowAvatar) {
+ AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, getActiveContact(), 0);
+ if (ace && (INT_PTR)ace != CALLSERVICE_NOTFOUND && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST))
+ m_avatarPic = ace->hbmPic;
+ else
+ m_avatarPic = NULL;
+ }
+ else m_avatarPic = NULL;
+
+ SendMessage(m_hwnd, DM_UPDATESIZEBAR, 0, 0);
+ SendMessage(m_hwnd, DM_AVATARSIZECHANGE, 0, 0);
+}
+
+INT_PTR CALLBACK CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- SrmmWindowData *dat = (SrmmWindowData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
ENLINK *pLink;
CHARRANGE sel;
switch (uMsg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- {
- NewMessageWindowLParam *newData = (NewMessageWindowLParam *)lParam;
- dat = new SrmmWindowData();
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
-
- dat->hContact = newData->hContact;
- dat->bIsMeta = db_mc_isMeta(dat->hContact) != 0;
- dat->hTimeZone = TimeZone_CreateByContact(dat->hContact, 0, TZF_KNOWNONLY);
- dat->wMinute = 61;
-
- NotifyLocalWinEvent(dat->hContact, hwndDlg, MSG_WINDOW_EVT_OPENING);
- if (newData->szInitialText) {
- if (newData->isWchar)
- SetDlgItemText(hwndDlg, IDC_MESSAGE, (wchar_t*)newData->szInitialText);
- else
- SetDlgItemTextA(hwndDlg, IDC_MESSAGE, newData->szInitialText);
-
- int len = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE));
- PostMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_SETSEL, len, len);
- }
-
- dat->szProto = GetContactProto(dat->hContact);
- RichUtil_SubClass(GetDlgItem(hwndDlg, IDC_LOG));
- RichUtil_SubClass(GetDlgItem(hwndDlg, IDC_MESSAGE));
-
- // avatar stuff
- dat->limitAvatarH = db_get_b(NULL, SRMMMOD, SRMSGSET_LIMITAVHEIGHT, SRMSGDEFSET_LIMITAVHEIGHT) ? db_get_dw(NULL, SRMMMOD, SRMSGSET_AVHEIGHT, SRMSGDEFSET_AVHEIGHT) : 0;
-
- if (dat->hContact && dat->szProto != NULL)
- dat->wStatus = db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE);
- else
- dat->wStatus = ID_STATUS_OFFLINE;
- dat->wOldStatus = dat->wStatus;
- dat->splitterPos = (int)db_get_dw(g_dat.bSavePerContact ? dat->hContact : NULL, SRMMMOD, "splitterPos", (DWORD)-1);
- dat->cmdListInd = -1;
- dat->nTypeMode = PROTOTYPE_SELFTYPING_OFF;
- SetTimer(hwndDlg, TIMERID_TYPE, 1000, NULL);
-
- RECT rc;
- GetWindowRect(GetDlgItem(hwndDlg, IDC_SPLITTERY), &rc);
- POINT pt = { 0, (rc.top + rc.bottom) / 2 };
- ScreenToClient(hwndDlg, &pt);
- dat->originalSplitterPos = pt.y;
- if (dat->splitterPos == -1)
- dat->splitterPos = dat->originalSplitterPos;
-
- Srmm_CreateToolbarIcons(hwndDlg, BBBF_ISIMBUTTON);
-
- WindowList_Add(pci->hWindowList, hwndDlg, dat->hContact);
- GetWindowRect(GetDlgItem(hwndDlg, IDC_MESSAGE), &dat->minEditInit);
- SendMessage(hwndDlg, DM_UPDATESIZEBAR, 0, 0);
- dat->hwndStatus = NULL;
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_AVATAR), FALSE);
-
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETOLECALLBACK, 0, (LPARAM)&reOleCallback);
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_LINK | ENM_SCROLL);
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_AUTOURLDETECT, TRUE, 0);
-
- if (dat->hContact && dat->szProto) {
- int nMax = CallProtoService(dat->szProto, PS_GETCAPS, PFLAG_MAXLENOFMESSAGE, dat->hContact);
- if (nMax)
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_LIMITTEXT, nMax, 0);
-
- // get around a lame bug in the Windows template resource code where richedits are limited to 0x7FFF
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_LIMITTEXT, sizeof(wchar_t) * 0x7FFFFFFF, 0);
- }
-
- mir_subclassWindow(GetDlgItem(hwndDlg, IDC_MESSAGE), MessageEditSubclassProc);
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SUBCLASSED, 0, 0);
- mir_subclassWindow(GetDlgItem(hwndDlg, IDC_SPLITTERY), SplitterSubclassProc);
-
- if (dat->hContact) {
- int historyMode = db_get_b(NULL, SRMMMOD, SRMSGSET_LOADHISTORY, SRMSGDEFSET_LOADHISTORY);
- // This finds the first message to display, it works like shit
- dat->hDbEventFirst = db_event_firstUnread(dat->hContact);
- switch (historyMode) {
- case LOADHISTORY_COUNT:
- for (int i = db_get_w(NULL, SRMMMOD, SRMSGSET_LOADCOUNT, SRMSGDEFSET_LOADCOUNT); i--;) {
- MEVENT hPrevEvent;
- if (dat->hDbEventFirst == NULL)
- hPrevEvent = db_event_last(dat->hContact);
- else
- hPrevEvent = db_event_prev(dat->hContact, dat->hDbEventFirst);
- if (hPrevEvent == NULL)
- break;
-
- DBEVENTINFO dbei = { sizeof(dbei) };
- dat->hDbEventFirst = hPrevEvent;
- db_event_get(hPrevEvent, &dbei);
- if (!DbEventIsShown(&dbei))
- i++;
- }
- break;
-
- case LOADHISTORY_TIME:
- DBEVENTINFO dbei = { sizeof(dbei) };
- if (dat->hDbEventFirst == NULL)
- dbei.timestamp = (DWORD)time(NULL);
- else
- db_event_get(dat->hDbEventFirst, &dbei);
-
- DWORD firstTime = dbei.timestamp - 60 * db_get_w(NULL, SRMMMOD, SRMSGSET_LOADTIME, SRMSGDEFSET_LOADTIME);
- for (;;) {
- MEVENT hPrevEvent;
- if (dat->hDbEventFirst == NULL)
- hPrevEvent = db_event_last(dat->hContact);
- else
- hPrevEvent = db_event_prev(dat->hContact, dat->hDbEventFirst);
- if (hPrevEvent == NULL)
- break;
-
- dbei.cbBlob = 0;
- db_event_get(hPrevEvent, &dbei);
- if (dbei.timestamp < firstTime)
- break;
- dat->hDbEventFirst = hPrevEvent;
- }
- break;
- }
- }
-
- MEVENT hdbEvent = db_event_last(dat->hContact);
- if (hdbEvent) {
- do {
- DBEVENTINFO dbei = { sizeof(dbei) };
- db_event_get(hdbEvent, &dbei);
- if ((dbei.eventType == EVENTTYPE_MESSAGE) && !(dbei.flags & DBEF_SENT)) {
- dat->lastMessage = dbei.timestamp;
- PostMessage(hwndDlg, DM_UPDATELASTMESSAGE, 0, 0);
- break;
- }
- } while (hdbEvent = db_event_prev(dat->hContact, hdbEvent));
- }
-
- SendMessage(hwndDlg, DM_OPTIONSAPPLIED, 1, 0);
-
- // restore saved msg if any...
- if (dat->hContact) {
- DBVARIANT dbv;
- if (!db_get_ws(dat->hContact, SRMSGMOD, DBSAVEDMSG, &dbv)) {
- if (dbv.ptszVal[0]) {
- SetDlgItemText(hwndDlg, IDC_MESSAGE, dbv.ptszVal);
- EnableWindow(GetDlgItem(hwndDlg, IDOK), TRUE);
- UpdateReadChars(hwndDlg, dat->hwndStatus);
- PostMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_SETSEL, -1, -1);
- }
- db_free(&dbv);
- }
- }
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETEVENTMASK, 0, ENM_CHANGE);
- {
- int flag = newData->noActivate ? RWPF_HIDDEN : 0;
- if (Utils_RestoreWindowPosition(hwndDlg, g_dat.bSavePerContact ? dat->hContact : NULL, SRMMMOD, "", flag)) {
- if (g_dat.bSavePerContact) {
- if (Utils_RestoreWindowPosition(hwndDlg, NULL, SRMMMOD, "", flag | RWPF_NOMOVE))
- SetWindowPos(hwndDlg, 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW);
- }
- else SetWindowPos(hwndDlg, 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW);
- }
- if (!g_dat.bSavePerContact && g_dat.bCascade)
- WindowList_Broadcast(pci->hWindowList, DM_CASCADENEWWINDOW, (WPARAM)hwndDlg, (LPARAM)&dat->windowWasCascaded);
- }
- if (newData->noActivate) {
- SetWindowPos(hwndDlg, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
- SetTimer(hwndDlg, TIMERID_FLASHWND, TIMEOUT_FLASHWND, NULL);
- }
- else {
- SetWindowPos(hwndDlg, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
- SetForegroundWindow(hwndDlg);
- SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
- }
- }
-
- SendMessage(hwndDlg, DM_GETAVATAR, 0, 0);
-
- NotifyLocalWinEvent(dat->hContact, hwndDlg, MSG_WINDOW_EVT_OPEN);
- return FALSE;
-
case WM_CONTEXTMENU:
- if (dat->hwndStatus && dat->hwndStatus == (HWND)wParam) {
+ if (m_hwndStatus && m_hwndStatus == (HWND)wParam) {
POINT pt, pt2;
GetCursorPos(&pt);
pt2.x = pt.x; pt2.y = pt.y;
- ScreenToClient(dat->hwndStatus, &pt);
+ ScreenToClient(m_hwndStatus, &pt);
// no popup menu for status icons - this is handled via NM_RCLICK notification and the plugins that added the icons
RECT rc;
- SendMessage(dat->hwndStatus, SB_GETRECT, SendMessage(dat->hwndStatus, SB_GETPARTS, 0, 0) - 1, (LPARAM)&rc);
+ SendMessage(m_hwndStatus, SB_GETRECT, SendMessage(m_hwndStatus, SB_GETPARTS, 0, 0) - 1, (LPARAM)&rc);
if (pt.x >= rc.left)
break;
- HMENU hMenu = Menu_BuildContactMenu(dat->hContact);
- TrackPopupMenu(hMenu, 0, pt2.x, pt2.y, 0, hwndDlg, NULL);
+ HMENU hMenu = Menu_BuildContactMenu(m_hContact);
+ TrackPopupMenu(hMenu, 0, pt2.x, pt2.y, 0, m_hwnd, NULL);
DestroyMenu(hMenu);
}
break;
case WM_DROPFILES: // Mod from tabsrmm
- if (dat->szProto == NULL) break;
- if (!(CallProtoService(dat->szProto, PS_GETCAPS, PFLAGNUM_1, 0)&PF1_FILESEND)) break;
- if (dat->wStatus == ID_STATUS_OFFLINE) break;
- if (dat->hContact != NULL) {
+ if (m_szProto == NULL) break;
+ if (!(CallProtoService(m_szProto, PS_GETCAPS, PFLAGNUM_1, 0)&PF1_FILESEND)) break;
+ if (m_wStatus == ID_STATUS_OFFLINE) break;
+ if (m_hContact != NULL) {
wchar_t szFilename[MAX_PATH];
HDROP hDrop = (HDROP)wParam;
int fileCount = DragQueryFile(hDrop, -1, NULL, 0), totalCount = 0, i;
@@ -779,7 +800,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l DragQueryFile(hDrop, i, szFilename, _countof(szFilename));
AddToFileList(&ppFiles, &totalCount, szFilename);
}
- CallServiceSync(MS_FILE_SENDSPECIFICFILEST, dat->hContact, (LPARAM)ppFiles);
+ CallServiceSync(MS_FILE_SENDSPECIFICFILEST, m_hContact, (LPARAM)ppFiles);
for (i = 0; ppFiles[i]; i++)
mir_free(ppFiles[i]);
mir_free(ppFiles);
@@ -787,82 +808,82 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l break;
case HM_AVATARACK:
- ShowAvatar(hwndDlg, dat);
+ ShowAvatar();
break;
case DM_AVATARCALCSIZE:
- if (dat->avatarPic == NULL || !g_dat.bShowAvatar) {
- dat->avatarWidth = 50;
- dat->avatarHeight = 50;
- ShowWindow(GetDlgItem(hwndDlg, IDC_AVATAR), SW_HIDE);
+ if (m_avatarPic == NULL || !g_dat.bShowAvatar) {
+ m_avatarWidth = 50;
+ m_avatarHeight = 50;
+ ShowWindow(GetDlgItem(m_hwnd, IDC_AVATAR), SW_HIDE);
return 0;
}
else {
BITMAP bminfo;
- GetObject(dat->avatarPic, sizeof(bminfo), &bminfo);
- dat->avatarWidth = bminfo.bmWidth + 2;
- dat->avatarHeight = bminfo.bmHeight + 2;
- if (dat->limitAvatarH && dat->avatarHeight > dat->limitAvatarH) {
- dat->avatarWidth = bminfo.bmWidth * dat->limitAvatarH / bminfo.bmHeight + 2;
- dat->avatarHeight = dat->limitAvatarH + 2;
+ GetObject(m_avatarPic, sizeof(bminfo), &bminfo);
+ m_avatarWidth = bminfo.bmWidth + 2;
+ m_avatarHeight = bminfo.bmHeight + 2;
+ if (m_limitAvatarH && m_avatarHeight > m_limitAvatarH) {
+ m_avatarWidth = bminfo.bmWidth * m_limitAvatarH / bminfo.bmHeight + 2;
+ m_avatarHeight = m_limitAvatarH + 2;
}
- ShowWindow(GetDlgItem(hwndDlg, IDC_AVATAR), SW_SHOW);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_AVATAR), SW_SHOW);
}
break;
case DM_UPDATESIZEBAR:
- dat->minEditBoxSize.cx = dat->minEditInit.right - dat->minEditInit.left;
- dat->minEditBoxSize.cy = dat->minEditInit.bottom - dat->minEditInit.top;
+ m_minEditBoxSize.cx = m_minEditInit.right - m_minEditInit.left;
+ m_minEditBoxSize.cy = m_minEditInit.bottom - m_minEditInit.top;
if (g_dat.bShowAvatar) {
- SendMessage(hwndDlg, DM_AVATARCALCSIZE, 0, 0);
- if (dat->avatarPic && dat->minEditBoxSize.cy <= dat->avatarHeight)
- dat->minEditBoxSize.cy = dat->avatarHeight;
+ SendMessage(m_hwnd, DM_AVATARCALCSIZE, 0, 0);
+ if (m_avatarPic && m_minEditBoxSize.cy <= m_avatarHeight)
+ m_minEditBoxSize.cy = m_avatarHeight;
}
break;
case DM_AVATARSIZECHANGE:
{
RECT rc;
- GetWindowRect(GetDlgItem(hwndDlg, IDC_MESSAGE), &rc);
- if (rc.bottom - rc.top < dat->minEditBoxSize.cy)
- SendMessage(hwndDlg, DM_SPLITTERMOVED, rc.top - (rc.bottom - rc.top - dat->minEditBoxSize.cy - 4), (LPARAM)GetDlgItem(hwndDlg, IDC_SPLITTERY));
+ GetWindowRect(GetDlgItem(m_hwnd, IDC_MESSAGE), &rc);
+ if (rc.bottom - rc.top < m_minEditBoxSize.cy)
+ SendMessage(m_hwnd, DM_SPLITTERMOVED, rc.top - (rc.bottom - rc.top - m_minEditBoxSize.cy - 4), (LPARAM)GetDlgItem(m_hwnd, IDC_SPLITTERY));
- SendMessage(hwndDlg, WM_SIZE, 0, 0);
+ SendMessage(m_hwnd, WM_SIZE, 0, 0);
}
break;
case DM_GETAVATAR:
{
PROTO_AVATAR_INFORMATION ai = {};
- ai.hContact = dat->hContact;
- CallProtoService(dat->szProto, PS_GETAVATARINFO, GAIF_FORCE, (LPARAM)&ai);
+ ai.hContact = m_hContact;
+ CallProtoService(m_szProto, PS_GETAVATARINFO, GAIF_FORCE, (LPARAM)&ai);
- ShowAvatar(hwndDlg, dat);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, 1);
+ ShowAvatar();
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, 1);
}
break;
case DM_TYPING:
- dat->nTypeSecs = (INT_PTR)lParam > 0 ? (int)lParam : 0;
+ m_nTypeSecs = (INT_PTR)lParam > 0 ? (int)lParam : 0;
break;
case DM_UPDATEWINICON:
if (g_dat.bUseStatusWinIcon) {
- Window_FreeIcon_IcoLib(hwndDlg);
+ Window_FreeIcon_IcoLib(m_hwnd);
- if (dat->szProto) {
- WORD wStatus = db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE);
- Window_SetProtoIcon_IcoLib(hwndDlg, dat->szProto, wStatus);
+ if (m_szProto) {
+ WORD wStatus = db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE);
+ Window_SetProtoIcon_IcoLib(m_hwnd, m_szProto, wStatus);
break;
}
}
- Window_SetSkinIcon_IcoLib(hwndDlg, SKINICON_EVENT_MESSAGE);
+ Window_SetSkinIcon_IcoLib(m_hwnd, SKINICON_EVENT_MESSAGE);
break;
case DM_USERNAMETOCLIP:
- if (dat->hContact) {
- ptrW id(Contact_GetInfo(CNF_UNIQUEID, dat->hContact, dat->szProto));
- if (id != NULL && OpenClipboard(hwndDlg)) {
+ if (m_hContact) {
+ ptrW id(Contact_GetInfo(CNF_UNIQUEID, m_hContact, m_szProto));
+ if (id != NULL && OpenClipboard(m_hwnd)) {
EmptyClipboard();
HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, mir_wstrlen(id) * sizeof(wchar_t) + 1);
mir_wstrcpy((wchar_t*)GlobalLock(hData), id);
@@ -874,53 +895,85 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l break;
case DM_UPDATELASTMESSAGE:
- if (!dat->hwndStatus || dat->nTypeSecs)
+ if (!m_hwndStatus || m_nTypeSecs)
break;
- if (dat->lastMessage) {
+ if (m_lastMessage) {
wchar_t date[64], time[64], fmt[128];
- TimeZone_PrintTimeStamp(NULL, dat->lastMessage, L"d", date, _countof(date), 0);
- TimeZone_PrintTimeStamp(NULL, dat->lastMessage, L"t", time, _countof(time), 0);
+ TimeZone_PrintTimeStamp(NULL, m_lastMessage, L"d", date, _countof(date), 0);
+ TimeZone_PrintTimeStamp(NULL, m_lastMessage, L"t", time, _countof(time), 0);
mir_snwprintf(fmt, TranslateT("Last message received on %s at %s."), date, time);
- SendMessage(dat->hwndStatus, SB_SETTEXT, 0, (LPARAM)fmt);
+ SendMessage(m_hwndStatus, SB_SETTEXT, 0, (LPARAM)fmt);
}
- else SendMessage(dat->hwndStatus, SB_SETTEXT, 0, (LPARAM)L"");
+ else SendMessage(m_hwndStatus, SB_SETTEXT, 0, (LPARAM)L"");
- SendMessage(dat->hwndStatus, SB_SETICON, 0, 0);
+ SendMessage(m_hwndStatus, SB_SETICON, 0, 0);
break;
case DM_OPTIONSAPPLIED:
- SetDialogToType(hwndDlg);
- if (dat->hBkgBrush)
- DeleteObject(dat->hBkgBrush);
+ {
+ CustomButtonData *cbd;
+ for (int i = 0; cbd = Srmm_GetNthButton(i); i++) {
+ HWND hwndButton = GetDlgItem(m_hwnd, cbd->m_dwButtonCID);
+ if (hwndButton == NULL)
+ continue;
+
+ bool bShow = false;
+ if (m_hContact) {
+ if (cbd->m_dwButtonCID == IDC_ADD) {
+ bShow = 0 != db_get_b(m_hContact, "CList", "NotOnList", 0);
+ cbd->m_bHidden = !bShow;
+ }
+ else bShow = g_dat.bShowButtons;
+ }
+ ShowWindow(hwndButton, (bShow) ? SW_SHOW : SW_HIDE);
+ }
+
+ if (!m_hwndStatus) {
+ int grip = (GetWindowLongPtr(m_hwnd, GWL_STYLE) & WS_THICKFRAME) ? SBARS_SIZEGRIP : 0;
+ m_hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | grip, 0, 0, 0, 0, m_hwnd, NULL, g_hInst, NULL);
+ SendMessage(m_hwndStatus, SB_SETMINHEIGHT, GetSystemMetrics(SM_CYSMICON), 0);
+ }
+
+ ShowWindow(GetDlgItem(m_hwnd, IDCANCEL), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_SPLITTERY), SW_SHOW);
+ ShowWindow(GetDlgItem(m_hwnd, IDOK), g_dat.bSendButton ? SW_SHOW : SW_HIDE);
+ EnableWindow(GetDlgItem(m_hwnd, IDOK), GetWindowTextLength(GetDlgItem(m_hwnd, IDC_MESSAGE)) != 0);
+ if (m_avatarPic == NULL || !g_dat.bShowAvatar)
+ ShowWindow(GetDlgItem(m_hwnd, IDC_AVATAR), SW_HIDE);
+ SendMessage(m_hwnd, DM_UPDATETITLE, 0, 0);
+ SendMessage(m_hwnd, WM_SIZE, 0, 0);
+ }
+ if (m_hBkgBrush)
+ DeleteObject(m_hBkgBrush);
{
COLORREF colour = db_get_dw(NULL, SRMMMOD, SRMSGSET_BKGCOLOUR, SRMSGDEFSET_BKGCOLOUR);
- dat->hBkgBrush = CreateSolidBrush(colour);
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETBKGNDCOLOR, 0, colour);
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETBKGNDCOLOR, 0, colour);
+ m_hBkgBrush = CreateSolidBrush(colour);
+ SendDlgItemMessage(m_hwnd, IDC_LOG, EM_SETBKGNDCOLOR, 0, colour);
+ SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_SETBKGNDCOLOR, 0, colour);
// avatar stuff
- dat->avatarPic = NULL;
- dat->limitAvatarH = 0;
- if (CallProtoService(dat->szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_AVATARS)
- dat->limitAvatarH = db_get_b(NULL, SRMMMOD, SRMSGSET_LIMITAVHEIGHT, SRMSGDEFSET_LIMITAVHEIGHT) ?
+ m_avatarPic = NULL;
+ m_limitAvatarH = 0;
+ if (CallProtoService(m_szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_AVATARS)
+ m_limitAvatarH = db_get_b(NULL, SRMMMOD, SRMSGSET_LIMITAVHEIGHT, SRMSGDEFSET_LIMITAVHEIGHT) ?
db_get_dw(NULL, SRMMMOD, SRMSGSET_AVHEIGHT, SRMSGDEFSET_AVHEIGHT) : 0;
if (!wParam)
- SendMessage(hwndDlg, DM_GETAVATAR, 0, 0);
+ SendMessage(m_hwnd, DM_GETAVATAR, 0, 0);
}
- InvalidateRect(GetDlgItem(hwndDlg, IDC_MESSAGE), NULL, FALSE);
+ InvalidateRect(GetDlgItem(m_hwnd, IDC_MESSAGE), NULL, FALSE);
{
LOGFONT lf;
CHARFORMAT cf = {};
- if (dat->hFont) DeleteObject(dat->hFont);
+ if (m_hFont) DeleteObject(m_hFont);
LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, &lf, &cf.crTextColor);
- dat->hFont = CreateFontIndirect(&lf);
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, WM_SETFONT, (WPARAM)dat->hFont, MAKELPARAM(TRUE, 0));
+ m_hFont = CreateFontIndirect(&lf);
+ SendDlgItemMessage(m_hwnd, IDC_MESSAGE, WM_SETFONT, (WPARAM)m_hFont, MAKELPARAM(TRUE, 0));
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_COLOR;
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETCHARFORMAT, SCF_ALL, (WPARAM)&cf);
+ SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_SETCHARFORMAT, SCF_ALL, (WPARAM)&cf);
}
// configure message history for proper RTL formatting
@@ -931,78 +984,78 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l pf2.wEffects = PFE_RTLPARA;
pf2.dwMask = PFM_RTLPARA;
- SetDlgItemText(hwndDlg, IDC_LOG, L"");
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
+ SetDlgItemText(m_hwnd, IDC_LOG, L"");
+ SendDlgItemMessage(m_hwnd, IDC_LOG, EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
pf2.wEffects = 0;
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETLANGOPTIONS, 0, SendDlgItemMessage(hwndDlg, IDC_LOG, EM_GETLANGOPTIONS, 0, 0) & ~IMF_AUTOKEYBOARD);
+ SendDlgItemMessage(m_hwnd, IDC_LOG, EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
+ SendDlgItemMessage(m_hwnd, IDC_LOG, EM_SETLANGOPTIONS, 0, SendDlgItemMessage(m_hwnd, IDC_LOG, EM_GETLANGOPTIONS, 0, 0) & ~IMF_AUTOKEYBOARD);
}
- SendMessage(hwndDlg, DM_REMAKELOG, 0, 0);
- SendMessage(hwndDlg, DM_UPDATEWINICON, 0, 0);
+ SendMessage(m_hwnd, DM_REMAKELOG, 0, 0);
+ SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0);
break;
case DM_UPDATETITLE:
wchar_t newtitle[256];
- if (dat->hContact && dat->szProto) {
- dat->wStatus = db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE);
- wchar_t *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
+ if (m_hContact && m_szProto) {
+ m_wStatus = db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE);
+ wchar_t *contactName = pcli->pfnGetContactDisplayName(m_hContact, 0);
- wchar_t *szStatus = pcli->pfnGetStatusModeDescription(dat->szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE), 0);
+ wchar_t *szStatus = pcli->pfnGetStatusModeDescription(m_szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE), 0);
if (g_dat.bUseStatusWinIcon)
mir_snwprintf(newtitle, L"%s - %s", contactName, TranslateT("Message session"));
else
mir_snwprintf(newtitle, L"%s (%s): %s", contactName, szStatus, TranslateT("Message session"));
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)wParam;
- if (!cws || (!mir_strcmp(cws->szModule, dat->szProto) && !mir_strcmp(cws->szSetting, "Status"))) {
- if (dat->szProto) {
- int dwStatus = db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE);
- HICON hIcon = Skin_LoadProtoIcon(dat->szProto, dwStatus);
+ if (!cws || (!mir_strcmp(cws->szModule, m_szProto) && !mir_strcmp(cws->szSetting, "Status"))) {
+ if (m_szProto) {
+ int dwStatus = db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE);
+ HICON hIcon = Skin_LoadProtoIcon(m_szProto, dwStatus);
if (hIcon) {
- SendDlgItemMessage(hwndDlg, IDC_USERMENU, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
+ SendDlgItemMessage(m_hwnd, IDC_USERMENU, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
IcoLib_ReleaseIcon(hIcon);
return TRUE;
}
}
if (g_dat.bUseStatusWinIcon)
- SendMessage(hwndDlg, DM_UPDATEWINICON, 0, 0);
+ SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0);
}
- dat->wOldStatus = dat->wStatus;
+ m_wOldStatus = m_wStatus;
}
else mir_wstrncpy(newtitle, TranslateT("Message session"), _countof(newtitle));
wchar_t oldtitle[256];
- GetWindowText(hwndDlg, oldtitle, _countof(oldtitle));
+ GetWindowText(m_hwnd, oldtitle, _countof(oldtitle));
if (mir_wstrcmp(newtitle, oldtitle)) { //swt() flickers even if the title hasn't actually changed
- SetWindowText(hwndDlg, newtitle);
- SendMessage(hwndDlg, WM_SIZE, 0, 0);
+ SetWindowText(m_hwnd, newtitle);
+ SendMessage(m_hwnd, WM_SIZE, 0, 0);
}
break;
case DM_NEWTIMEZONE:
- dat->hTimeZone = TimeZone_CreateByContact(dat->hContact, 0, TZF_KNOWNONLY);
- dat->wMinute = 61;
- SendMessage(hwndDlg, WM_SIZE, 0, 0);
+ m_hTimeZone = TimeZone_CreateByContact(m_hContact, 0, TZF_KNOWNONLY);
+ m_wMinute = 61;
+ SendMessage(m_hwnd, WM_SIZE, 0, 0);
break;
case DM_GETWINDOWSTATE:
{
UINT state = MSG_WINDOW_STATE_EXISTS;
- if (IsWindowVisible(hwndDlg))
+ if (IsWindowVisible(m_hwnd))
state |= MSG_WINDOW_STATE_VISIBLE;
- if (GetForegroundWindow() == hwndDlg)
+ if (GetForegroundWindow() == m_hwnd)
state |= MSG_WINDOW_STATE_FOCUS;
- if (IsIconic(hwndDlg))
+ if (IsIconic(m_hwnd))
state |= MSG_WINDOW_STATE_ICONIC;
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, state);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, state);
}
return TRUE;
case DM_CASCADENEWWINDOW:
- if ((HWND)wParam != hwndDlg) {
+ if ((HWND)wParam != m_hwnd) {
RECT rcThis, rcNew;
- GetWindowRect(hwndDlg, &rcThis);
+ GetWindowRect(m_hwnd, &rcThis);
GetWindowRect((HWND)wParam, &rcNew);
if (abs(rcThis.left - rcNew.left) < 3 && abs(rcThis.top - rcNew.top) < 3) {
int offset = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME);
@@ -1016,103 +1069,103 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l if (LOWORD(wParam) != WA_ACTIVE)
break;
- SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
+ SetFocus(GetDlgItem(m_hwnd, IDC_MESSAGE));
// fall through
case WM_MOUSEACTIVATE:
- if (KillTimer(hwndDlg, TIMERID_FLASHWND))
- FlashWindow(hwndDlg, FALSE);
+ if (KillTimer(m_hwnd, TIMERID_FLASHWND))
+ FlashWindow(m_hwnd, FALSE);
break;
case WM_GETMINMAXINFO:
{
MINMAXINFO *mmi = (MINMAXINFO *)lParam;
RECT rcWindow, rcLog;
- GetWindowRect(hwndDlg, &rcWindow);
- GetWindowRect(GetDlgItem(hwndDlg, IDC_LOG), &rcLog);
- mmi->ptMinTrackSize.x = rcWindow.right - rcWindow.left - ((rcLog.right - rcLog.left) - dat->minEditBoxSize.cx);
- mmi->ptMinTrackSize.y = rcWindow.bottom - rcWindow.top - ((rcLog.bottom - rcLog.top) - dat->minEditBoxSize.cy);
+ GetWindowRect(m_hwnd, &rcWindow);
+ GetWindowRect(GetDlgItem(m_hwnd, IDC_LOG), &rcLog);
+ mmi->ptMinTrackSize.x = rcWindow.right - rcWindow.left - ((rcLog.right - rcLog.left) - m_minEditBoxSize.cx);
+ mmi->ptMinTrackSize.y = rcWindow.bottom - rcWindow.top - ((rcLog.bottom - rcLog.top) - m_minEditBoxSize.cy);
}
return 0;
case WM_CBD_LOADICONS:
- Srmm_UpdateToolbarIcons(hwndDlg);
+ Srmm_UpdateToolbarIcons(m_hwnd);
break;
case WM_CBD_UPDATED:
- SetButtonsPos(hwndDlg, false);
+ SetButtonsPos(m_hwnd, false);
break;
case WM_SIZE:
- if (!IsIconic(hwndDlg)) {
+ if (!IsIconic(m_hwnd)) {
BOOL bottomScroll = TRUE;
- if (dat->hwndStatus) {
- SendMessage(dat->hwndStatus, WM_SIZE, 0, 0);
- SetupStatusBar(hwndDlg, dat);
+ if (m_hwndStatus) {
+ SendMessage(m_hwndStatus, WM_SIZE, 0, 0);
+ SetupStatusBar(m_hwnd, this);
}
- if (GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG), GWL_STYLE) & WS_VSCROLL) {
+ if (GetWindowLongPtr(GetDlgItem(m_hwnd, IDC_LOG), GWL_STYLE) & WS_VSCROLL) {
SCROLLINFO si = {};
si.cbSize = sizeof(si);
si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
- GetScrollInfo(GetDlgItem(hwndDlg, IDC_LOG), SB_VERT, &si);
+ GetScrollInfo(GetDlgItem(m_hwnd, IDC_LOG), SB_VERT, &si);
bottomScroll = (si.nPos + (int)si.nPage + 5) >= si.nMax;
}
- Utils_ResizeDialog(hwndDlg, g_hInst, MAKEINTRESOURCEA(IDD_MSG), MessageDialogResize, (LPARAM)dat);
- SetButtonsPos(hwndDlg, false);
+ Utils_ResizeDialog(m_hwnd, g_hInst, MAKEINTRESOURCEA(IDD_MSG), MessageDialogResize, (LPARAM)this);
+ SetButtonsPos(m_hwnd, false);
// The statusbar sometimes draws over these 2 controls so
// redraw them
- if (dat->hwndStatus) {
- RedrawWindow(GetDlgItem(hwndDlg, IDOK), NULL, NULL, RDW_INVALIDATE);
- RedrawWindow(GetDlgItem(hwndDlg, IDC_MESSAGE), NULL, NULL, RDW_INVALIDATE);
+ if (m_hwndStatus) {
+ RedrawWindow(GetDlgItem(m_hwnd, IDOK), NULL, NULL, RDW_INVALIDATE);
+ RedrawWindow(GetDlgItem(m_hwnd, IDC_MESSAGE), NULL, NULL, RDW_INVALIDATE);
}
- if (g_dat.bShowAvatar && dat->avatarPic)
- RedrawWindow(GetDlgItem(hwndDlg, IDC_AVATAR), NULL, NULL, RDW_INVALIDATE);
+ if (g_dat.bShowAvatar && m_avatarPic)
+ RedrawWindow(GetDlgItem(m_hwnd, IDC_AVATAR), NULL, NULL, RDW_INVALIDATE);
if (bottomScroll)
- PostMessage(hwndDlg, DM_SCROLLLOGTOBOTTOM, 0, 0);
+ PostMessage(m_hwnd, DM_SCROLLLOGTOBOTTOM, 0, 0);
}
- break;
+ return TRUE;
case DM_SPLITTERMOVED:
- if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_SPLITTERY)) {
- HWND hwndLog = GetDlgItem(hwndDlg, IDC_LOG);
+ if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_SPLITTERY)) {
+ HWND hwndLog = GetDlgItem(m_hwnd, IDC_LOG);
RECT rc, rcLog;
- GetClientRect(hwndDlg, &rc);
+ GetClientRect(m_hwnd, &rc);
GetWindowRect(hwndLog, &rcLog);
POINT pt;
pt.x = 0;
pt.y = wParam;
- ScreenToClient(hwndDlg, &pt);
+ ScreenToClient(m_hwnd, &pt);
- int oldSplitterY = dat->splitterPos;
- dat->splitterPos = rc.bottom - pt.y + 23;
- GetWindowRect(GetDlgItem(hwndDlg, IDC_MESSAGE), &rc);
- if (rc.bottom - rc.top + (dat->splitterPos - oldSplitterY) < dat->minEditBoxSize.cy)
- dat->splitterPos = oldSplitterY + dat->minEditBoxSize.cy - (rc.bottom - rc.top);
- if (rcLog.bottom - rcLog.top - (dat->splitterPos - oldSplitterY) < dat->minEditBoxSize.cy)
- dat->splitterPos = oldSplitterY - dat->minEditBoxSize.cy + (rcLog.bottom - rcLog.top);
+ int oldSplitterY = m_splitterPos;
+ m_splitterPos = rc.bottom - pt.y + 23;
+ GetWindowRect(GetDlgItem(m_hwnd, IDC_MESSAGE), &rc);
+ if (rc.bottom - rc.top + (m_splitterPos - oldSplitterY) < m_minEditBoxSize.cy)
+ m_splitterPos = oldSplitterY + m_minEditBoxSize.cy - (rc.bottom - rc.top);
+ if (rcLog.bottom - rcLog.top - (m_splitterPos - oldSplitterY) < m_minEditBoxSize.cy)
+ m_splitterPos = oldSplitterY - m_minEditBoxSize.cy + (rcLog.bottom - rcLog.top);
- SendMessage(hwndDlg, WM_SIZE, 0, 0);
+ SendMessage(m_hwnd, WM_SIZE, 0, 0);
}
break;
case DM_REMAKELOG:
- StreamInEvents(hwndDlg, dat->hDbEventFirst, -1, 0);
+ StreamInEvents(m_hwnd, m_hDbEventFirst, -1, 0);
break;
case DM_APPENDTOLOG: //takes wParam=hDbEvent
- StreamInEvents(hwndDlg, wParam, 1, 1);
+ StreamInEvents(m_hwnd, wParam, 1, 1);
break;
case DM_SCROLLLOGTOBOTTOM:
{
- HWND hwndLog = GetDlgItem(hwndDlg, IDC_LOG);
+ HWND hwndLog = GetDlgItem(m_hwnd, IDC_LOG);
if (GetWindowLongPtr(hwndLog, GWL_STYLE) & WS_VSCROLL) {
SCROLLINFO si = {};
si.cbSize = sizeof(si);
@@ -1127,10 +1180,10 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l break;
case HM_DBEVENTADDED:
- if (wParam == dat->hContact) {
+ if (wParam == m_hContact) {
MEVENT hDbEvent = lParam;
- if (dat->hDbEventFirst == NULL)
- dat->hDbEventFirst = hDbEvent;
+ if (m_hDbEventFirst == NULL)
+ m_hDbEventFirst = hDbEvent;
DBEVENTINFO dbei = { sizeof(dbei) };
db_event_get(hDbEvent, &dbei);
@@ -1138,89 +1191,89 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l if (DbEventIsShown(&dbei)) {
// Sounds *only* for sent messages, not for custom events
if (isMessage && !isSent) {
- if (GetForegroundWindow() == hwndDlg)
+ if (GetForegroundWindow() == m_hwnd)
SkinPlaySound("RecvMsgActive");
else
SkinPlaySound("RecvMsgInactive");
}
if (isMessage && !isSent) {
- dat->lastMessage = dbei.timestamp;
- SendMessage(hwndDlg, DM_UPDATELASTMESSAGE, 0, 0);
+ m_lastMessage = dbei.timestamp;
+ SendMessage(m_hwnd, DM_UPDATELASTMESSAGE, 0, 0);
}
- if (hDbEvent != dat->hDbEventFirst && db_event_next(dat->hContact, hDbEvent) == NULL)
- SendMessage(hwndDlg, DM_APPENDTOLOG, lParam, 0);
+ if (hDbEvent != m_hDbEventFirst && db_event_next(m_hContact, hDbEvent) == NULL)
+ SendMessage(m_hwnd, DM_APPENDTOLOG, lParam, 0);
else
- SendMessage(hwndDlg, DM_REMAKELOG, 0, 0);
+ SendMessage(m_hwnd, DM_REMAKELOG, 0, 0);
// Flash window *only* for messages, not for custom events
if (isMessage && !isSent) {
- if (GetActiveWindow() == hwndDlg && GetForegroundWindow() == hwndDlg) {
- HWND hwndLog = GetDlgItem(hwndDlg, IDC_LOG);
+ if (GetActiveWindow() == m_hwnd && GetForegroundWindow() == m_hwnd) {
+ HWND hwndLog = GetDlgItem(m_hwnd, IDC_LOG);
if (GetWindowLongPtr(hwndLog, GWL_STYLE) & WS_VSCROLL) {
SCROLLINFO si = {};
si.cbSize = sizeof(si);
si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
GetScrollInfo(hwndLog, SB_VERT, &si);
if ((si.nPos + (int)si.nPage + 5) < si.nMax)
- SetTimer(hwndDlg, TIMERID_FLASHWND, TIMEOUT_FLASHWND, NULL);
+ SetTimer(m_hwnd, TIMERID_FLASHWND, TIMEOUT_FLASHWND, NULL);
}
}
- else SetTimer(hwndDlg, TIMERID_FLASHWND, TIMEOUT_FLASHWND, NULL);
+ else SetTimer(m_hwnd, TIMERID_FLASHWND, TIMEOUT_FLASHWND, NULL);
}
}
}
break;
case WM_TIMECHANGE:
- PostMessage(hwndDlg, DM_NEWTIMEZONE, 0, 0);
- PostMessage(hwndDlg, DM_REMAKELOG, 0, 0);
+ PostMessage(m_hwnd, DM_NEWTIMEZONE, 0, 0);
+ PostMessage(m_hwnd, DM_REMAKELOG, 0, 0);
break;
case WM_TIMER:
if (wParam == TIMERID_FLASHWND) {
- FlashWindow(hwndDlg, TRUE);
- if (dat->nFlash > 2 * g_dat.nFlashMax) {
- KillTimer(hwndDlg, TIMERID_FLASHWND);
- FlashWindow(hwndDlg, FALSE);
- dat->nFlash = 0;
+ FlashWindow(m_hwnd, TRUE);
+ if (m_nFlash > 2 * g_dat.nFlashMax) {
+ KillTimer(m_hwnd, TIMERID_FLASHWND);
+ FlashWindow(m_hwnd, FALSE);
+ m_nFlash = 0;
}
- dat->nFlash++;
+ m_nFlash++;
}
else if (wParam == TIMERID_TYPE) {
- ShowTime(dat);
- if (dat->nTypeMode == PROTOTYPE_SELFTYPING_ON && GetTickCount() - dat->nLastTyping > TIMEOUT_TYPEOFF)
- NotifyTyping(dat, PROTOTYPE_SELFTYPING_OFF);
-
- if (dat->showTyping) {
- if (dat->nTypeSecs) {
- dat->nTypeSecs--;
- if (GetForegroundWindow() == hwndDlg)
- SendMessage(hwndDlg, DM_UPDATEWINICON, 0, 0);
+ ShowTime(this);
+ if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON && GetTickCount() - m_nLastTyping > TIMEOUT_TYPEOFF)
+ NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
+
+ if (m_bShowTyping) {
+ if (m_nTypeSecs) {
+ m_nTypeSecs--;
+ if (GetForegroundWindow() == m_hwnd)
+ SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0);
}
else {
- SendMessage(hwndDlg, DM_UPDATELASTMESSAGE, 0, 0);
+ SendMessage(m_hwnd, DM_UPDATELASTMESSAGE, 0, 0);
if (g_dat.bShowTypingWin)
- SendMessage(hwndDlg, DM_UPDATEWINICON, 0, 0);
- dat->showTyping = 0;
+ SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0);
+ m_bShowTyping = false;
}
}
else {
- if (dat->nTypeSecs) {
+ if (m_nTypeSecs) {
wchar_t szBuf[256];
- wchar_t* szContactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
+ wchar_t* szContactName = pcli->pfnGetContactDisplayName(m_hContact, 0);
HICON hTyping = Skin_LoadIcon(SKINICON_OTHER_TYPING);
mir_snwprintf(szBuf, TranslateT("%s is typing a message..."), szContactName);
- dat->nTypeSecs--;
+ m_nTypeSecs--;
- SendMessage(dat->hwndStatus, SB_SETTEXT, 0, (LPARAM)szBuf);
- SendMessage(dat->hwndStatus, SB_SETICON, 0, (LPARAM)hTyping);
- if (g_dat.bShowTypingWin && GetForegroundWindow() != hwndDlg) {
- HICON hIcon = (HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0);
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hTyping);
+ SendMessage(m_hwndStatus, SB_SETTEXT, 0, (LPARAM)szBuf);
+ SendMessage(m_hwndStatus, SB_SETICON, 0, (LPARAM)hTyping);
+ if (g_dat.bShowTypingWin && GetForegroundWindow() != m_hwnd) {
+ HICON hIcon = (HICON)SendMessage(m_hwnd, WM_GETICON, ICON_SMALL, 0);
+ SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hTyping);
IcoLib_ReleaseIcon(hIcon);
}
- dat->showTyping = 1;
+ m_bShowTyping = true;
}
}
}
@@ -1240,26 +1293,26 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l if (dis->CtlType == ODT_MENU)
return Menu_DrawItem(lParam);
- if (dis->hwndItem == dat->hwndStatus) {
- DrawStatusIcons(dat->hContact, dis->hDC, dis->rcItem, 2);
+ if (dis->hwndItem == m_hwndStatus) {
+ DrawStatusIcons(m_hContact, dis->hDC, dis->rcItem, 2);
return TRUE;
}
- if (dis->CtlID == IDC_AVATAR && dat->avatarPic && g_dat.bShowAvatar) {
+ if (dis->CtlID == IDC_AVATAR && m_avatarPic && g_dat.bShowAvatar) {
HPEN hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
HPEN hOldPen = (HPEN)SelectObject(dis->hDC, hPen);
- Rectangle(dis->hDC, 0, 0, dat->avatarWidth, dat->avatarHeight);
+ Rectangle(dis->hDC, 0, 0, m_avatarWidth, m_avatarHeight);
SelectObject(dis->hDC, hOldPen);
DeleteObject(hPen);
BITMAP bminfo;
- GetObject(dat->avatarPic, sizeof(bminfo), &bminfo);
+ GetObject(m_avatarPic, sizeof(bminfo), &bminfo);
HDC hdcMem = CreateCompatibleDC(dis->hDC);
- HBITMAP hbmMem = (HBITMAP)SelectObject(hdcMem, dat->avatarPic);
+ HBITMAP hbmMem = (HBITMAP)SelectObject(hdcMem, m_avatarPic);
SetStretchBltMode(dis->hDC, HALFTONE);
- StretchBlt(dis->hDC, 1, 1, dat->avatarWidth - 2, dat->avatarHeight - 2, hdcMem, 0, 0,
+ StretchBlt(dis->hDC, 1, 1, m_avatarWidth - 2, m_avatarHeight - 2, hdcMem, 0, 0,
bminfo.bmWidth, bminfo.bmHeight, SRCCOPY);
SelectObject(hdcMem, hbmMem);
@@ -1270,96 +1323,96 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l break;
case WM_COMMAND:
- if (!lParam && Clist_MenuProcessCommand(LOWORD(wParam), MPCF_CONTACTMENU, dat->hContact))
+ if (!lParam && Clist_MenuProcessCommand(LOWORD(wParam), MPCF_CONTACTMENU, m_hContact))
break;
// custom button handling
if (HIWORD(wParam) == BN_CLICKED)
if (LOWORD(wParam) >= MIN_CBUTTONID && LOWORD(wParam) <= MAX_CBUTTONID) {
- Srmm_ClickToolbarIcon(dat->hContact, LOWORD(wParam), GetDlgItem(hwndDlg, LOWORD(wParam)), 0);
+ Srmm_ClickToolbarIcon(m_hContact, LOWORD(wParam), GetDlgItem(m_hwnd, LOWORD(wParam)), 0);
break;
}
switch (LOWORD(wParam)) {
case IDOK:
- if (IsWindowEnabled(GetDlgItem(hwndDlg, IDOK))) {
- int bufSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE)) + 1;
+ if (IsWindowEnabled(GetDlgItem(m_hwnd, IDOK))) {
+ int bufSize = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_MESSAGE)) + 1;
wchar_t *temp = (wchar_t*)alloca(bufSize * sizeof(wchar_t));
- GetDlgItemText(hwndDlg, IDC_MESSAGE, temp, bufSize);
+ GetDlgItemText(m_hwnd, IDC_MESSAGE, temp, bufSize);
if (!temp[0])
break;
- int sendId = SendMessageDirect(rtrimw(temp), dat->hContact);
+ int sendId = SendMessageDirect(rtrimw(temp), m_hContact);
if (sendId) {
- dat->cmdList.insert(mir_wstrdup(temp));
+ m_cmdList.insert(mir_wstrdup(temp));
- dat->cmdListInd = -1;
- if (dat->nTypeMode == PROTOTYPE_SELFTYPING_ON)
- NotifyTyping(dat, PROTOTYPE_SELFTYPING_OFF);
+ m_cmdListInd = -1;
+ if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON)
+ NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
- EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
- SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
+ EnableWindow(GetDlgItem(m_hwnd, IDOK), FALSE);
+ SetFocus(GetDlgItem(m_hwnd, IDC_MESSAGE));
- SetDlgItemText(hwndDlg, IDC_MESSAGE, L"");
+ SetDlgItemText(m_hwnd, IDC_MESSAGE, L"");
if (g_dat.bAutoClose)
- DestroyWindow(hwndDlg);
+ DestroyWindow(m_hwnd);
else if (g_dat.bAutoMin)
- ShowWindow(hwndDlg, SW_MINIMIZE);
+ ShowWindow(m_hwnd, SW_MINIMIZE);
}
return TRUE;
}
break;
case IDCANCEL:
- DestroyWindow(hwndDlg);
+ DestroyWindow(m_hwnd);
return TRUE;
case IDC_USERMENU:
if (GetKeyState(VK_SHIFT) & 0x8000) // copy user name
- SendMessage(hwndDlg, DM_USERNAMETOCLIP, 0, 0);
+ SendMessage(m_hwnd, DM_USERNAMETOCLIP, 0, 0);
else {
RECT rc;
- HMENU hMenu = Menu_BuildContactMenu(dat->hContact);
- GetWindowRect(GetDlgItem(hwndDlg, LOWORD(wParam)), &rc);
- TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
+ HMENU hMenu = Menu_BuildContactMenu(m_hContact);
+ GetWindowRect(GetDlgItem(m_hwnd, LOWORD(wParam)), &rc);
+ TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, m_hwnd, NULL);
DestroyMenu(hMenu);
}
break;
case IDC_HISTORY:
- CallService(MS_HISTORY_SHOWCONTACTHISTORY, dat->hContact, 0);
+ CallService(MS_HISTORY_SHOWCONTACTHISTORY, m_hContact, 0);
break;
case IDC_DETAILS:
- CallService(MS_USERINFO_SHOWDIALOG, dat->hContact, 0);
+ CallService(MS_USERINFO_SHOWDIALOG, m_hContact, 0);
break;
case IDC_ADD:
{
ADDCONTACTSTRUCT acs = {};
- acs.hContact = dat->hContact;
+ acs.hContact = m_hContact;
acs.handleType = HANDLE_CONTACT;
acs.szProto = 0;
- CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs);
+ CallService(MS_ADDCONTACT_SHOW, (WPARAM)m_hwnd, (LPARAM)&acs);
}
- if (!db_get_b(dat->hContact, "CList", "NotOnList", 0))
- ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE);
+ if (!db_get_b(m_hContact, "CList", "NotOnList", 0))
+ ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), FALSE);
break;
case IDC_MESSAGE:
if (HIWORD(wParam) == EN_CHANGE) {
- int len = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE));
- UpdateReadChars(hwndDlg, dat->hwndStatus);
- EnableWindow(GetDlgItem(hwndDlg, IDOK), len != 0);
+ int len = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_MESSAGE));
+ UpdateReadChars(m_hwnd, m_hwndStatus);
+ EnableWindow(GetDlgItem(m_hwnd, IDOK), len != 0);
if (!(GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_SHIFT) & 0x8000)) {
- dat->nLastTyping = GetTickCount();
+ m_nLastTyping = GetTickCount();
if (len) {
- if (dat->nTypeMode == PROTOTYPE_SELFTYPING_OFF)
- NotifyTyping(dat, PROTOTYPE_SELFTYPING_ON);
+ if (m_nTypeMode == PROTOTYPE_SELFTYPING_OFF)
+ NotifyTyping(PROTOTYPE_SELFTYPING_ON);
}
- else if (dat->nTypeMode == PROTOTYPE_SELFTYPING_ON)
- NotifyTyping(dat, PROTOTYPE_SELFTYPING_OFF);
+ else if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON)
+ NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
}
}
break;
@@ -1367,14 +1420,14 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l break;
case WM_NOTIFY:
- if (dat && ((LPNMHDR)lParam)->hwndFrom == dat->hwndStatus) {
+ if (this && ((LPNMHDR)lParam)->hwndFrom == m_hwndStatus) {
if (((LPNMHDR)lParam)->code == NM_CLICK || ((LPNMHDR)lParam)->code == NM_RCLICK) {
NMMOUSE *nm = (NMMOUSE *)lParam;
RECT rc;
- SendMessage(dat->hwndStatus, SB_GETRECT, SendMessage(dat->hwndStatus, SB_GETPARTS, 0, 0) - 1, (LPARAM)&rc);
+ SendMessage(m_hwndStatus, SB_GETRECT, SendMessage(m_hwndStatus, SB_GETPARTS, 0, 0) - 1, (LPARAM)&rc);
if (nm->pt.x >= rc.left)
- CheckStatusIconClick(dat->hContact, dat->hwndStatus, nm->pt, rc, 2, ((LPNMHDR)lParam)->code == NM_RCLICK ? MBCF_RIGHTBUTTON : 0);
+ CheckStatusIconClick(m_hContact, m_hwndStatus, nm->pt, rc, 2, ((LPNMHDR)lParam)->code == NM_RCLICK ? MBCF_RIGHTBUTTON : 0);
return TRUE;
}
}
@@ -1388,7 +1441,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l case WM_LBUTTONDOWN:
hCur = GetCursor();
if (hCur == LoadCursor(NULL, IDC_SIZENS) || hCur == LoadCursor(NULL, IDC_SIZEWE) || hCur == LoadCursor(NULL, IDC_SIZENESW) || hCur == LoadCursor(NULL, IDC_SIZENWSE)) {
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
return TRUE;
}
break;
@@ -1412,7 +1465,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l POINT pt = { GET_X_LPARAM(pLink->lParam), GET_Y_LPARAM(pLink->lParam) };
ClientToScreen(pLink->nmhdr.hwndFrom, &pt);
- switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL)) {
+ switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_hwnd, NULL)) {
case IDM_COPY:
SendMessage(pLink->nmhdr.hwndFrom, WM_COPY, 0, 0);
break;
@@ -1425,13 +1478,13 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l SendMessage(pLink->nmhdr.hwndFrom, EM_EXSETSEL, 0, (LPARAM)&all);
break;
case IDM_CLEAR:
- SetDlgItemText(hwndDlg, IDC_LOG, L"");
- dat->hDbEventFirst = NULL;
+ SetDlgItemText(m_hwnd, IDC_LOG, L"");
+ m_hDbEventFirst = NULL;
break;
}
DestroyMenu(hSubMenu);
DestroyMenu(hMenu);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
return TRUE;
}
break;
@@ -1443,8 +1496,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
GetScrollInfo((HWND)lParam, SB_VERT, &si);
if ((si.nPos + (int)si.nPage + 5) >= si.nMax)
- if (KillTimer(hwndDlg, TIMERID_FLASHWND))
- FlashWindow(hwndDlg, FALSE);
+ if (KillTimer(m_hwnd, TIMERID_FLASHWND))
+ FlashWindow(m_hwnd, FALSE);
}
break;
@@ -1453,19 +1506,19 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l switch (pLink->msg) {
case WM_SETCURSOR:
SetCursor(hCurHyperlinkHand);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
return TRUE;
case WM_RBUTTONDOWN:
case WM_LBUTTONUP:
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_EXGETSEL, 0, (LPARAM)&sel);
+ SendDlgItemMessage(m_hwnd, IDC_LOG, EM_EXGETSEL, 0, (LPARAM)&sel);
if (sel.cpMin != sel.cpMax)
break;
TEXTRANGE tr;
tr.chrg = pLink->chrg;
tr.lpstrText = (wchar_t*)_alloca((tr.chrg.cpMax - tr.chrg.cpMin + 8) * sizeof(wchar_t));
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
+ SendDlgItemMessage(m_hwnd, IDC_LOG, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
if (wcschr(tr.lpstrText, '@') != NULL && wcschr(tr.lpstrText, ':') == NULL && wcschr(tr.lpstrText, '/') == NULL) {
memmove(tr.lpstrText + 7, tr.lpstrText, (tr.chrg.cpMax - tr.chrg.cpMin + 1) * sizeof(wchar_t));
memcpy(tr.lpstrText, L"mailto:", 7 * sizeof(wchar_t));
@@ -1479,13 +1532,13 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l 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, hwndDlg, NULL)) {
+ switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_hwnd, NULL)) {
case IDM_OPENLINK:
ShellExecute(NULL, L"open", tr.lpstrText, NULL, NULL, SW_SHOW);
break;
case IDM_COPYLINK:
- if (OpenClipboard(hwndDlg)) {
+ if (OpenClipboard(m_hwnd)) {
EmptyClipboard();
HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, (mir_wstrlen(tr.lpstrText) + 1) * sizeof(wchar_t));
mir_wstrcpy((wchar_t*)GlobalLock(hData), tr.lpstrText);
@@ -1497,12 +1550,12 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l }
DestroyMenu(hMenu);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
return TRUE;
}
ShellExecute(NULL, L"open", tr.lpstrText, NULL, NULL, SW_SHOW);
- SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
+ SetFocus(GetDlgItem(m_hwnd, IDC_MESSAGE));
break;
}
}
@@ -1510,69 +1563,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l break;
case DM_STATUSICONCHANGE:
- SendMessage(dat->hwndStatus, SB_SETTEXT, (SBT_OWNERDRAW | (SendMessage(dat->hwndStatus, SB_GETPARTS, 0, 0) - 1)), 0);
- break;
-
- case WM_CLOSE:
- DestroyWindow(hwndDlg);
- break;
-
- case WM_DESTROY:
- if (dat) {
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
- NotifyLocalWinEvent(dat->hContact, hwndDlg, MSG_WINDOW_EVT_CLOSING);
-
- // save string from the editor
- if (dat->hContact) {
- int len = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE)) + 1;
- wchar_t *msg = (wchar_t*)alloca(sizeof(wchar_t)*len);
- GetDlgItemText(hwndDlg, IDC_MESSAGE, msg, len);
- if (msg[0])
- db_set_ws(dat->hContact, SRMSGMOD, DBSAVEDMSG, msg);
- else
- db_unset(dat->hContact, SRMSGMOD, DBSAVEDMSG);
- }
- KillTimer(hwndDlg, TIMERID_TYPE);
- if (dat->nTypeMode == PROTOTYPE_SELFTYPING_ON)
- NotifyTyping(dat, PROTOTYPE_SELFTYPING_OFF);
-
- if (dat->hBkgBrush)
- DeleteObject(dat->hBkgBrush);
- if (dat->hwndStatus)
- DestroyWindow(dat->hwndStatus);
-
- for (int i = 0; i < dat->cmdList.getCount(); i++)
- mir_free(dat->cmdList[i]);
- dat->cmdList.destroy();
-
- WindowList_Remove(pci->hWindowList, hwndDlg);
-
- MCONTACT hContact = (g_dat.bSavePerContact) ? dat->hContact : NULL;
- db_set_dw(hContact ? dat->hContact : NULL, SRMMMOD, "splitterPos", dat->splitterPos);
-
- if (dat->hFont) {
- DeleteObject(dat->hFont);
- dat->hFont = NULL;
- }
-
- WINDOWPLACEMENT wp = { sizeof(wp) };
- GetWindowPlacement(hwndDlg, &wp);
- if (!dat->windowWasCascaded) {
- db_set_dw(hContact, SRMMMOD, "x", wp.rcNormalPosition.left);
- db_set_dw(hContact, SRMMMOD, "y", wp.rcNormalPosition.top);
- }
- db_set_dw(hContact, SRMMMOD, "width", wp.rcNormalPosition.right - wp.rcNormalPosition.left);
- db_set_dw(hContact, SRMMMOD, "height", wp.rcNormalPosition.bottom - wp.rcNormalPosition.top);
-
- NotifyLocalWinEvent(dat->hContact, hwndDlg, MSG_WINDOW_EVT_CLOSE);
- if (dat->hContact && g_dat.bDeleteTempCont)
- if (db_get_b(dat->hContact, "CList", "NotOnList", 0))
- db_delete_contact(dat->hContact);
-
- Window_FreeIcon_IcoLib(hwndDlg);
- delete dat;
- }
+ SendMessage(m_hwndStatus, SB_SETTEXT, (SBT_OWNERDRAW | (SendMessage(m_hwndStatus, SB_GETPARTS, 0, 0) - 1)), 0);
break;
}
- return FALSE;
+ return CDlgBase::DlgProc(uMsg, wParam, lParam);
}
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index a2383902f0..da340abd88 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -43,7 +43,7 @@ struct LogStreamData int bufferOffset, bufferLen;
int eventsToInsert;
int isEmpty;
- SrmmWindowData *dlgDat;
+ CSrmmWindow *dlgDat;
};
static int logPixelSY;
@@ -147,7 +147,7 @@ static void AppendToBufferWithRTF(CMStringA &buf, const wchar_t *line) #define FONT_FORMAT "{\\f%u\\fnil\\fcharset%u %S;}"
-static char* CreateRTFHeader(SrmmWindowData*)
+static char* CreateRTFHeader(CSrmmWindow*)
{
HDC hdc = GetDC(NULL);
logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
@@ -175,7 +175,7 @@ static char* CreateRTFHeader(SrmmWindowData*) }
// mir_free() the return value
-static char* CreateRTFTail(SrmmWindowData*)
+static char* CreateRTFTail(CSrmmWindow*)
{
return mir_strdup("}");
}
@@ -203,7 +203,7 @@ int DbEventIsShown(DBEVENTINFO *dbei) }
//mir_free() the return value
-static char* CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, MEVENT hDbEvent, struct LogStreamData *streamData)
+static char* CreateRTFFromDbEvent(CSrmmWindow *dat, MCONTACT hContact, MEVENT hDbEvent, struct LogStreamData *streamData)
{
int showColon = 0;
@@ -227,18 +227,18 @@ static char* CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, MEVENT }
CMStringA buffer;
- if (!dat->bIsAutoRTL && !streamData->isEmpty)
+ if (!dat->m_bIsAutoRTL && !streamData->isEmpty)
buffer.Append("\\par");
if (dbei.flags & DBEF_RTL) {
buffer.Append("\\rtlpar");
- dat->bIsAutoRTL = TRUE;
+ dat->m_bIsAutoRTL = TRUE;
}
else buffer.Append("\\ltrpar");
streamData->isEmpty = 0;
- if (dat->bIsAutoRTL) {
+ if (dat->m_bIsAutoRTL) {
if (dbei.flags & DBEF_RTL)
buffer.Append("\\ltrch\\rtlch");
else
@@ -339,7 +339,7 @@ static char* CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, MEVENT mir_free(msg);
}
- if (dat->bIsAutoRTL)
+ if (dat->m_bIsAutoRTL)
buffer.Append("\\par");
mir_free(dbei.pBlob);
@@ -398,7 +398,7 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG void StreamInEvents(HWND hwndDlg, MEVENT hDbEventFirst, int count, int fAppend)
{
- SrmmWindowData *dat = (SrmmWindowData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ CSrmmWindow *dat = (CSrmmWindow*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
CHARRANGE oldSel, sel;
BOOL bottomScroll = TRUE;
POINT scrollPos;
@@ -409,7 +409,7 @@ void StreamInEvents(HWND hwndDlg, MEVENT hDbEventFirst, int count, int fAppend) SendMessage(hwndLog, EM_EXGETSEL, 0, (LPARAM)&oldSel);
LogStreamData streamData = {};
- streamData.hContact = dat->hContact;
+ streamData.hContact = dat->m_hContact;
streamData.hDbEvent = hDbEventFirst;
streamData.dlgDat = dat;
streamData.eventsToInsert = count;
@@ -457,7 +457,7 @@ void StreamInEvents(HWND hwndDlg, MEVENT hDbEventFirst, int count, int fAppend) if (bottomScroll)
RedrawWindow(hwndLog, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
- dat->hDbEventLast = streamData.hDbEventLast;
+ dat->m_hDbEventLast = streamData.hDbEventLast;
}
#define RTFPICTHEADERMAXSIZE 78
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index a8b914577b..68602d180d 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -83,10 +83,8 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam) char *szProto = GetContactProto(hContact);
if (szProto && (g_dat.openFlags & SRMMStatusToPf2(CallProtoService(szProto, PS_GETSTATUS, 0, 0)))) {
- NewMessageWindowLParam newData = {};
- newData.hContact = hContact;
- newData.noActivate = g_dat.bDoNotStealFocus;
- CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), NULL, DlgProcMessage, (LPARAM)&newData);
+ CSrmmWindow *pDlg = new CSrmmWindow(hContact, g_dat.bDoNotStealFocus);
+ pDlg->Show();
return 0;
}
@@ -127,11 +125,8 @@ INT_PTR SendMessageCmd(MCONTACT hContact, char *msg, int isWchar) SetForegroundWindow(hwnd);
}
else {
- NewMessageWindowLParam newData = {};
- newData.hContact = hContact;
- newData.szInitialText = msg;
- newData.isWchar = isWchar;
- CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), NULL, DlgProcMessage, (LPARAM)&newData);
+ CSrmmWindow *pDlg = new CSrmmWindow(hContact, false, msg, isWchar != 0);
+ pDlg->Show();
}
return 0;
}
@@ -255,10 +250,8 @@ static void RestoreUnreadMessageAlerts(void) autoPopup = true;
if (autoPopup && !windowAlreadyExists) {
- NewMessageWindowLParam newData = {};
- newData.hContact = hContact;
- newData.noActivate = g_dat.bDoNotStealFocus;
- CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), NULL, DlgProcMessage, (LPARAM)&newData);
+ CSrmmWindow *pDlg = new CSrmmWindow(hContact, g_dat.bDoNotStealFocus);
+ pDlg->Show();
}
else arEvents.insert(new MSavedEvent(hContact, hDbEvent));
}
@@ -503,7 +496,7 @@ static INT_PTR SetStatusText(WPARAM wParam, LPARAM lParam) if (hwnd == NULL)
return 1;
- SrmmWindowData *dat = (SrmmWindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ CSrmmWindow *dat = (CSrmmWindow*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (dat == NULL)
return 1;
@@ -511,8 +504,8 @@ static INT_PTR SetStatusText(WPARAM wParam, LPARAM lParam) if (st != NULL && st->cbSize != sizeof(StatusTextData))
return 1;
- SendMessage(dat->hwndStatus, SB_SETICON, 0, (LPARAM)(st == NULL ? 0 : st->hIcon));
- SendMessage(dat->hwndStatus, SB_SETTEXT, 0, (LPARAM)(st == NULL ? L"" : st->tszText));
+ SendMessage(dat->m_hwndStatus, SB_SETICON, 0, (LPARAM)(st == NULL ? 0 : st->hIcon));
+ SendMessage(dat->m_hwndStatus, SB_SETTEXT, 0, (LPARAM)(st == NULL ? L"" : st->tszText));
return 0;
}
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index c8d1ce7083..716e8ecfa8 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -25,54 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <richedit.h>
#include <richole.h>
-struct NewMessageWindowLParam
-{
- MCONTACT hContact;
- const char *szInitialText;
- int isWchar;
- int noActivate;
-};
-
-struct SrmmWindowData : public MZeroedObject
-{
- SrmmWindowData() :
- cmdList(20)
- {}
-
- MCONTACT hContact;
- MEVENT hDbEventFirst, hDbEventLast;
- HBRUSH hBkgBrush;
- HFONT hFont;
- int splitterPos, originalSplitterPos;
- SIZE minEditBoxSize;
- RECT minEditInit;
- int lineHeight;
- int windowWasCascaded;
- DWORD nFlash;
- int nTypeSecs;
- int nTypeMode;
- int avatarWidth;
- int avatarHeight;
- int limitAvatarH;
- HBITMAP avatarPic;
- DWORD nLastTyping;
- int showTyping;
- DWORD lastMessage;
- HWND hwndStatus;
- HANDLE hTimeZone;
- char *szProto;
- WORD wStatus;
- WORD wOldStatus;
- int cmdListInd;
- LIST<wchar_t> cmdList;
- bool bIsAutoRTL, bIsMeta;
- WORD wMinute;
-
- __forceinline MCONTACT getActiveContact() const
- { return (bIsMeta) ? db_mc_getSrmmSub(hContact) : hContact;
- }
-};
-
#define DM_REMAKELOG (WM_USER+11)
#define HM_DBEVENTADDED (WM_USER+12)
#define DM_CASCADENEWWINDOW (WM_USER+13)
@@ -97,30 +49,53 @@ struct SrmmWindowData : public MZeroedObject #define EVENTTYPE_JABBER_CHATSTATES 2000
#define EVENTTYPE_JABBER_PRESENCE 2001
-struct CREOleCallback : public IRichEditOleCallback
+class CSrmmWindow : public CDlgBase, public MZeroedObject
{
- CREOleCallback() : refCount(0), nextStgId(0), pictStg(NULL) {}
- unsigned refCount;
- IStorage *pictStg;
- int nextStgId;
-
- STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * lplpObj);
- STDMETHOD_(ULONG,AddRef)(THIS);
- STDMETHOD_(ULONG,Release)(THIS);
-
- STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode);
- STDMETHOD(GetNewStorage)(LPSTORAGE FAR * lplpstg);
- STDMETHOD(GetInPlaceContext)(LPOLEINPLACEFRAME FAR * lplpFrame, LPOLEINPLACEUIWINDOW FAR * lplpDoc, LPOLEINPLACEFRAMEINFO lpFrameInfo);
- STDMETHOD(ShowContainerUI)(BOOL fShow);
- STDMETHOD(QueryInsertObject)(LPCLSID lpclsid, LPSTORAGE lpstg, LONG cp);
- STDMETHOD(DeleteObject)(LPOLEOBJECT lpoleobj);
- STDMETHOD(QueryAcceptData)(LPDATAOBJECT lpdataobj, CLIPFORMAT FAR * lpcfFormat, DWORD reco, BOOL fReally, HGLOBAL hMetaPict);
- STDMETHOD(GetClipboardData)(CHARRANGE FAR *lpchrg, DWORD reco, LPDATAOBJECT FAR * lplpdataobj);
- STDMETHOD(GetDragDropEffect)(BOOL fDrag, DWORD grfKeyState, LPDWORD pdwEffect);
- STDMETHOD(GetContextMenu)(WORD seltype, LPOLEOBJECT lpoleobj, CHARRANGE FAR * lpchrg, HMENU FAR * lphmenu) ;
+ void NotifyTyping(int mode);
+ void ShowAvatar();
+
+public:
+ MCONTACT m_hContact;
+ MEVENT m_hDbEventFirst, m_hDbEventLast;
+ HBRUSH m_hBkgBrush;
+ HFONT m_hFont;
+ int m_splitterPos, m_originalSplitterPos;
+ SIZE m_minEditBoxSize;
+ RECT m_minEditInit;
+ int m_lineHeight;
+ int m_windowWasCascaded;
+ DWORD m_nFlash;
+ int m_nTypeSecs;
+ int m_nTypeMode;
+ int m_avatarWidth;
+ int m_avatarHeight;
+ int m_limitAvatarH;
+ HBITMAP m_avatarPic;
+ DWORD m_nLastTyping;
+ DWORD m_lastMessage;
+ HWND m_hwndStatus;
+ HANDLE m_hTimeZone;
+ char *m_szProto;
+ WORD m_wStatus;
+ WORD m_wOldStatus;
+ int m_cmdListInd;
+ LIST<wchar_t> m_cmdList;
+ bool m_bIsAutoRTL, m_bIsMeta, m_bShowTyping, m_bNoActivate;
+ WORD m_wMinute;
+ wchar_t *m_wszInitialText;
+
+ CSrmmWindow(MCONTACT hContact, bool bNoActivate, const char *szInitialText = NULL, bool bIsUnicode = false);
+
+ virtual void OnInitDialog() override;
+ virtual void OnDestroy() override;
+
+ virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
+
+ __forceinline MCONTACT getActiveContact() const
+ { return (m_bIsMeta) ? db_mc_getSrmmSub(m_hContact) : m_hContact;
+ }
};
-INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK ErrorDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
int DbEventIsForMsgWindow(DBEVENTINFO *dbei);
int DbEventIsShown(DBEVENTINFO *dbei);
|