From 5ccc401594b2c465352b03df6b2868fffbf3ffc2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 31 Jul 2014 19:20:38 +0000 Subject: AVS: no need to rebuild the whole control for the same contact git-svn-id: http://svn.miranda-ng.org/main/trunk@10008 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/AVS/src/acc.cpp | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'plugins/AVS/src/acc.cpp') diff --git a/plugins/AVS/src/acc.cpp b/plugins/AVS/src/acc.cpp index 3d79469baf..72d9c3b3b6 100644 --- a/plugins/AVS/src/acc.cpp +++ b/plugins/AVS/src/acc.cpp @@ -374,6 +374,7 @@ static void DrawText(HDC hdc, HFONT hFont, const RECT &rc, const TCHAR *text) static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { ACCData *data = (ACCData*)GetWindowLongPtr(hwnd, 0); + char *szProto; switch (msg) { case WM_NCCREATE: @@ -414,33 +415,37 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP break; case AVATAR_SETCONTACT: - DestroyAnimation(hwnd, data); + if (lParam == 0) + return FALSE; - data->hContact = lParam; - if (lParam == NULL) - data->proto[0] = '\0'; - else - lstrcpynA(data->proto, GetContactProto(data->hContact), sizeof(data->proto)); + if (data->hContact != lParam) { + DestroyAnimation(hwnd, data); - StartAnimation(hwnd, data); + data->hContact = lParam; + if (lParam == NULL) + data->proto[0] = '\0'; + else + lstrcpynA(data->proto, GetContactProto(data->hContact), sizeof(data->proto)); - NotifyAvatarChange(hwnd); - Invalidate(hwnd); + StartAnimation(hwnd, data); + + NotifyAvatarChange(hwnd); + Invalidate(hwnd); + } return TRUE; case AVATAR_SETPROTOCOL: - DestroyAnimation(hwnd, data); - - data->hContact = NULL; - if (lParam == NULL) - data->proto[0] = '\0'; - else - lstrcpynA(data->proto, (char *)lParam, sizeof(data->proto)); + szProto = (lParam == NULL) ? "" : (char*)lParam; + if (data->hContact != 0 || strcmp(szProto, data->proto)) { + DestroyAnimation(hwnd, data); - StartAnimation(hwnd, data); + data->hContact = NULL; + strncpy_s(data->proto, szProto, _TRUNCATE); - NotifyAvatarChange(hwnd); - Invalidate(hwnd); + StartAnimation(hwnd, data); + NotifyAvatarChange(hwnd); + Invalidate(hwnd); + } return TRUE; case AVATAR_SETBKGCOLOR: -- cgit v1.2.3