From 81337e86426dd4a79836554342bdc2e7e6195769 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 18 Jun 2013 14:12:13 +0000 Subject: massive extinction of stupid service name's buffers git-svn-id: http://svn.miranda-ng.org/main/trunk@5010 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/ModernOpt/src/mopt_selector.cpp | 80 ++++++++++++++++----------------- 1 file changed, 38 insertions(+), 42 deletions(-) (limited to 'plugins/ModernOpt') diff --git a/plugins/ModernOpt/src/mopt_selector.cpp b/plugins/ModernOpt/src/mopt_selector.cpp index 126622113a..73316f82a0 100644 --- a/plugins/ModernOpt/src/mopt_selector.cpp +++ b/plugins/ModernOpt/src/mopt_selector.cpp @@ -27,59 +27,55 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void sttApplySkin(MODERNOPTOBJECT *obj, TCHAR *fn) { - char svc[128]; - mir_snprintf(svc, SIZEOF(svc), "%s%s", obj->lpzThemeModuleName, TS_SKIN_APPLY); - CallService(svc, NULL, (LPARAM)fn); + CallProtoService(obj->lpzThemeModuleName, TS_SKIN_APPLY, NULL, (LPARAM)fn); } static TCHAR *sttGetActiveSkin(MODERNOPTOBJECT *obj) { - char svc[128]; - mir_snprintf(svc, SIZEOF(svc), "%s%s", obj->lpzThemeModuleName, TS_SKIN_ACTIVE); - return ServiceExists(svc) ? (TCHAR *)CallService(svc, 0, 0) : 0; + return ProtoServiceExists(obj->lpzThemeModuleName, TS_SKIN_ACTIVE) ? + (TCHAR*)CallProtoService(obj->lpzThemeModuleName, TS_SKIN_ACTIVE, 0, 0) : 0; } static void sttPreviewSkin(MODERNOPTOBJECT *obj, TCHAR *fn, LPDRAWITEMSTRUCT lps) { if (!fn) return; - char svc[128]; - mir_snprintf(svc, SIZEOF(svc), "%s%s", obj->lpzThemeModuleName, TS_SKIN_PREVIEW); - if (ServiceExists(svc)) - CallService(svc, (WPARAM)lps, (LPARAM)fn); - else { - char *afn = mir_t2a(fn); - char *fnpreview = (char *)mir_alloc(lstrlenA(afn) + 10); - lstrcpyA(fnpreview, afn); - lstrcatA(fnpreview, ".png"); - HBITMAP hbmPreview = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)fnpreview); - mir_free(afn); - mir_free(fnpreview); - - if (!hbmPreview) return; - - BITMAP bmp; - GetObject(hbmPreview, sizeof(bmp), &bmp); - - SIZE szDst = { abs(bmp.bmWidth), abs(bmp.bmHeight) }; - if ((szDst.cx > lps->rcItem.right-lps->rcItem.left) || (szDst.cy > lps->rcItem.bottom-lps->rcItem.top)) { - float q = min( - float(lps->rcItem.right-lps->rcItem.left) / szDst.cx, - float(lps->rcItem.bottom-lps->rcItem.top) / szDst.cy); - szDst.cx *= q; - szDst.cy *= q; - } - POINT ptDst = { - (lps->rcItem.left+lps->rcItem.right-szDst.cx) / 2, - (lps->rcItem.top+lps->rcItem.bottom-szDst.cy) / 2 }; - - HDC hdc = CreateCompatibleDC(lps->hDC); - SelectObject(hdc, hbmPreview); - SetStretchBltMode(hdc, HALFTONE); - StretchBlt(lps->hDC, ptDst.x, ptDst.y, szDst.cx, szDst.cy, hdc, 0, 0, abs(bmp.bmWidth), abs(bmp.bmHeight), SRCCOPY); - DeleteDC(hdc); - DeleteObject(hbmPreview); + if ( ProtoServiceExists(obj->lpzThemeModuleName, TS_SKIN_PREVIEW)) { + CallProtoService(obj->lpzThemeModuleName, TS_SKIN_PREVIEW, (WPARAM)lps, (LPARAM)fn); + return; + } + + char *afn = mir_t2a(fn); + char *fnpreview = (char *)mir_alloc(lstrlenA(afn) + 10); + lstrcpyA(fnpreview, afn); + lstrcatA(fnpreview, ".png"); + HBITMAP hbmPreview = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)fnpreview); + mir_free(afn); + mir_free(fnpreview); + + if (!hbmPreview) return; + + BITMAP bmp; + GetObject(hbmPreview, sizeof(bmp), &bmp); + + SIZE szDst = { abs(bmp.bmWidth), abs(bmp.bmHeight) }; + if ((szDst.cx > lps->rcItem.right-lps->rcItem.left) || (szDst.cy > lps->rcItem.bottom-lps->rcItem.top)) { + float q = min( + float(lps->rcItem.right-lps->rcItem.left) / szDst.cx, + float(lps->rcItem.bottom-lps->rcItem.top) / szDst.cy); + szDst.cx *= q; + szDst.cy *= q; } + POINT ptDst = { + (lps->rcItem.left+lps->rcItem.right-szDst.cx) / 2, + (lps->rcItem.top+lps->rcItem.bottom-szDst.cy) / 2 }; + + HDC hdc = CreateCompatibleDC(lps->hDC); + SelectObject(hdc, hbmPreview); + SetStretchBltMode(hdc, HALFTONE); + StretchBlt(lps->hDC, ptDst.x, ptDst.y, szDst.cx, szDst.cy, hdc, 0, 0, abs(bmp.bmWidth), abs(bmp.bmHeight), SRCCOPY); + DeleteDC(hdc); + DeleteObject(hbmPreview); } struct TSkinListItem -- cgit v1.2.3