From 685797951c34c866e27b5d24e3bdb9d7867356c5 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 2 Aug 2013 18:43:52 +0000 Subject: fix for the proper MS_GC_PROTO_GETTOOLTIPTEXT processing in chats git-svn-id: http://svn.miranda-ng.org/main/trunk@5552 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/window.cpp | 39 +++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'plugins/TabSRMM') diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 98670b688f..6c912da2d4 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -1447,19 +1447,24 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, POINT * pt, SESS ti.uId = 1; ti.rect = clientRect; - TCHAR ptszBuf[1024]; + TCHAR tszBuf[1024]; tszBuf[0] = 0; USERINFO *ui1 = SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, currentHovered); if (ui1) { - if ( ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) - ti.lpszText = (TCHAR*)ProtoCallService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui1->pszUID); - else { - mir_sntprintf(ptszBuf, SIZEOF(ptszBuf), _T("%s: %s\r\n%s: %s\r\n%s: %s"), + if ( ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) { + TCHAR *p = (TCHAR*)ProtoCallService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui1->pszUID); + if (p != NULL) { + _tcsncpy_s(tszBuf, SIZEOF(tszBuf), p, _TRUNCATE); + mir_free(p); + } + } + + if (tszBuf[0] == 0) + mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s: %s\r\n%s: %s\r\n%s: %s"), TranslateT("Nick name"), ui1->pszNick, TranslateT("Unique Id"), ui1->pszUID, TranslateT("Status"), TM_WordToString( parentdat->pStatuses, ui1->Status)); - ti.lpszText = ptszBuf; - } + ti.lpszText = tszBuf; } SendMessage(hwndToolTip, bNewTip ? TTM_ADDTOOL : TTM_UPDATETIPTEXT, 0, (LPARAM)&ti); @@ -1816,7 +1821,6 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, { CLCINFOTIP ti = {0}; USERINFO *ui1 = NULL; - TCHAR ptszBuf[1024]; POINT pt; struct TWindowData *dat = (struct TWindowData *)GetWindowLongPtr(hwndParent, GWLP_USERDATA); @@ -1839,17 +1843,22 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, if (ui1) { ti.cbSize = sizeof(ti); - if (ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) - _tcsncpy(ptszBuf, (TCHAR*)ProtoCallService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui1->pszUID), SIZEOF(ptszBuf)); - else - mir_sntprintf(ptszBuf, SIZEOF(ptszBuf), _T("%s:\t%s\n%s:\t%s\n%s:\t%s"), + TCHAR tszBuf[1024]; tszBuf[0] = 0; + if (ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) { + TCHAR *p = (TCHAR*)ProtoCallService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui1->pszUID); + if (p) { + _tcsncpy_s(tszBuf, SIZEOF(tszBuf), p, _TRUNCATE); + mir_free(p); + } + } + if (tszBuf[0] == 0) + mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s:\t%s\n%s:\t%s\n%s:\t%s"), TranslateT("Nick"), ui1->pszNick, TranslateT("Unique id"), ui1->pszUID, TranslateT("Status"), TM_WordToString(parentdat->pStatuses, ui1->Status)); - if (ptszBuf != NULL) - if (CallService("mToolTip/ShowTipW", (WPARAM)mir_tstrdup(ptszBuf), (LPARAM)&ti)) - isToolTip = TRUE; + if (CallService("mToolTip/ShowTipW", (WPARAM)tszBuf, (LPARAM)&ti)) + isToolTip = TRUE; } KillTimer(hwnd, 1); } -- cgit v1.2.3