diff options
author | George Hazan <ghazan@miranda.im> | 2016-11-02 18:30:41 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2016-11-02 18:30:50 +0300 |
commit | 2c5081fe7d0e6b155847c5ead1b32b4b42bfe4ae (patch) | |
tree | 27cadc2a6f39c3de5ff94fd8a0edf714936434c2 /src/core | |
parent | 2e8ebf3ad76d00ad32d4a492b32d360db87cb28e (diff) |
- common mouse hovering processing code moved to MIR_APP_DLL
- now all chats support mToolTip
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/stdmsg/src/chat_window.cpp | 86 |
1 files changed, 1 insertions, 85 deletions
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index e0bdf171c2..6dac99e58e 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -945,70 +945,6 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR return mir_callNextSubclass(hwnd, TabSubclassProc, msg, wParam, lParam); } -static void ProcessNickListHovering(HWND hwnd, int hoveredItem, SESSION_INFO *si) -{ - static int currentHovered = -1; - static HWND hwndToolTip = NULL; - static HWND oldParent = NULL; - - if (hoveredItem == currentHovered) - return; - - currentHovered = hoveredItem; - - if (oldParent != hwnd && hwndToolTip) { - SendMessage(hwndToolTip, TTM_DELTOOL, 0, 0); - DestroyWindow(hwndToolTip); - hwndToolTip = NULL; - } - if (hoveredItem == -1) { - SendMessage(hwndToolTip, TTM_ACTIVATE, 0, 0); - return; - } - - BOOL bNewTip = FALSE; - if (!hwndToolTip) { - hwndToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, - WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - hwnd, NULL, g_hInst, NULL); - bNewTip = TRUE; - } - - RECT clientRect; - GetClientRect(hwnd, &clientRect); - TOOLINFO ti = { sizeof(TOOLINFO) }; - ti.uFlags = TTF_SUBCLASS; - ti.hinst = g_hInst; - ti.hwnd = hwnd; - ti.uId = 1; - ti.rect = clientRect; - - wchar_t tszBuf[1024]; tszBuf[0] = 0; - USERINFO *ui = pci->SM_GetUserFromIndex(si->ptszID, si->pszModule, currentHovered); - if (ui) { - if (ProtoServiceExists(si->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) { - wchar_t *p = (wchar_t*)CallProtoService(si->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)si->ptszID, (LPARAM)ui->pszUID); - if (p != NULL) { - wcsncpy_s(tszBuf, p, _TRUNCATE); - mir_free(p); - } - } - - if (tszBuf[0] == 0) - mir_snwprintf(tszBuf, L"%s: %s\r\n%s: %s\r\n%s: %s", - TranslateT("Nickname"), ui->pszNick, - TranslateT("Unique ID"), ui->pszUID, - TranslateT("Status"), pci->TM_WordToString(si->pStatuses, ui->Status)); - - ti.lpszText = tszBuf; - } - - SendMessage(hwndToolTip, bNewTip ? TTM_ADDTOOL : TTM_UPDATETIPTEXT, 0, (LPARAM)&ti); - SendMessage(hwndToolTip, TTM_ACTIVATE, ti.lpszText != NULL, 0); - SendMessage(hwndToolTip, TTM_SETMAXTIPWIDTH, 0, 400); -} - static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { SESSION_INFO *si = (SESSION_INFO*)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA); @@ -1115,27 +1051,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, break; case WM_MOUSEMOVE: - POINT pt = { LOWORD(lParam), HIWORD(lParam) }; - RECT clientRect; - GetClientRect(hwnd, &clientRect); - BOOL bInClient = PtInRect(&clientRect, pt); - // Mouse capturing/releasing - if (bInClient && GetCapture() != hwnd) - SetCapture(hwnd); - else if (!bInClient) - ReleaseCapture(); - - if (bInClient) { - // hit test item under mouse - DWORD nItemUnderMouse = (DWORD)SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam); - if (HIWORD(nItemUnderMouse) == 1) - nItemUnderMouse = (DWORD)(-1); - else - nItemUnderMouse &= 0xFFFF; - - ProcessNickListHovering(hwnd, (int)nItemUnderMouse, si); - } - else ProcessNickListHovering(hwnd, -1, NULL); + Chat_HoverMouse(si, hwnd, lParam, ServiceExists("mToolTip/HideTip")); break; } |