static void LoadContact(MCONTACT hContact) { ThumbInfo *pThumb = thumbList.FindThumbByContact(hContact); if (hContact == NULL) return; DWORD dwPos = db_get_dw(hContact, MODULE, "ThumbsPos", (DWORD)-1); if (dwPos != -1) { TCHAR *ptName = pcli->pfnGetContactDisplayName(hContact, 0); if (ptName != NULL) { int nX = DB_POS_GETX(dwPos); int nY = DB_POS_GETY(dwPos); CreateThumbWnd(ptName, hContact, nX, nY); pThumb->PositionThumb(nX, nY); } } }
static void LoadContact( HANDLE hContact ) { ThumbInfo *pThumb = thumbList.FindThumbByContact(hContact); if (hContact == NULL) return; DWORD dwPos = db_get_dw( hContact, MODULE, "ThumbsPos", (DWORD)-1); if ( dwPos != -1) { TCHAR *ptName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, (LPARAM)GCDNF_TCHAR); if ( ptName != NULL ) { int nX = DB_POS_GETX( dwPos ); int nY = DB_POS_GETY( dwPos ); CreateThumbWnd(ptName, hContact, nX, nY); pThumb->PositionThumb(nX, nY); } } }
static void CreateThumbWnd(TCHAR *ptszName, MCONTACT hContact, int nX, int nY) { ThumbInfo *pThumb = thumbList.FindThumbByContact(hContact); if (pThumb != NULL) return; // Prepare for window creation HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, WND_CLASS, ptszName, WS_POPUP, nX, nY, 50, 20, NULL, NULL, hInst, NULL); if (hwnd == NULL) return; pThumb = thumbList.AddThumb(hwnd, ptszName, hContact); SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pThumb); pThumb->ResizeThumb(); pThumb->SetThumbOpacity(fcOpt.thumbAlpha); ShowWindow(hwnd, (fcOpt.bHideAll || HideOnFullScreen() || fcOpt.bHideOffline || (fcOpt.bHideWhenCListShow && bIsCListShow)) ? SW_HIDE : SW_SHOWNA); pThumb->PositionThumb(nX, nY); // force repaint pThumb->UpdateContent(); }
static int OnContactDrag(WPARAM hContact, LPARAM) { POINT pt; GetCursorPos(&pt); ThumbInfo *pThumb = thumbList.FindThumbByContact(hContact); if (pThumb == NULL) { int idStatus = GetContactStatus(hContact); if (!fcOpt.bHideAll && !HideOnFullScreen() && (!fcOpt.bHideOffline || IsStatusVisible(idStatus)) && (!fcOpt.bHideWhenCListShow || !bIsCListShow)) { CreateThumbWnd(pcli->pfnGetContactDisplayName(hContact, 0), hContact, pt.x, pt.y); ThumbInfo *pNewThumb = thumbList.FindThumbByContact(hContact); ShowWindow(pNewThumb->hwnd, SW_SHOWNA); hNewContact = hContact; OnStatusChanged(); } } else if (hContact == hNewContact) pThumb->PositionThumb(pt.x - 5, pt.y - 5); return hNewContact != NULL; }
void ThumbInfo::ResizeThumb() { int index = FLT_FONTID_NOTONLIST; himlMiranda = Clist_GetImageList(); if (himlMiranda == nullptr) return; SIZEL sizeIcon; ImageList_GetIconSize_my(himlMiranda, sizeIcon); HDC hdc = GetWindowDC(hwnd); if (!db_get_b(hContact, "CList", "NotOnList", 0)) { char *szProto = GetContactProto(hContact); if (nullptr != szProto) { int nStatus = Proto_GetStatus(szProto); int nContactStatus = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); int nApparentMode = db_get_w(hContact, szProto, "ApparentMode", 0); if ((nStatus == ID_STATUS_INVISIBLE && nApparentMode == ID_STATUS_ONLINE) || (nStatus != ID_STATUS_INVISIBLE && nApparentMode == ID_STATUS_OFFLINE)) { if (ID_STATUS_OFFLINE == nContactStatus) index = FLT_FONTID_OFFINVIS; else index = FLT_FONTID_INVIS; } else if (ID_STATUS_OFFLINE == nContactStatus) index = FLT_FONTID_OFFLINE; else index = FLT_FONTID_CONTACTS; } } else index = FLT_FONTID_NOTONLIST; HFONT hOldFont = (HFONT)SelectObject(hdc, hFont[index]); // Get text and icon sizes SIZEL sizeText; GetTextExtentPoint32(hdc, ptszName, (int)mir_wstrlen(ptszName), &sizeText); SelectObject(hdc, hOldFont); // Transform text size POINT ptText; ptText.x = sizeText.cx; ptText.y = sizeText.cy; LPtoDP(hdc, &ptText, 1); szSize.cx = fcOpt.bFixedWidth ? fcOpt.nThumbWidth : sizeIcon.cx + ptText.x + 10; szSize.cy = ((sizeIcon.cy > ptText.y) ? sizeIcon.cy : ptText.y) + 4; SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, szSize.cx, szSize.cy, SWP_NOMOVE | SWP_NOACTIVATE); RefreshContactIcon(0xFFFFFFFF); ReleaseDC(hwnd, hdc); // Move the docked widnow if needed ThumbInfo *pNextThumb = thumbList.FindThumb(dockOpt.hwndRight); if (pNextThumb) { RECT rcThumb; GetThumbRect(&rcThumb); pNextThumb->PositionThumb(rcThumb.right, rcThumb.top); } }