From 1dd73910cbbf9062b62b4713ff88427011fcac85 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Fri, 6 Mar 2015 23:28:19 +0000 Subject: Clist_nicer: - Minor cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@12364 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_nicer/src/Coolsb/coolsblib.cpp | 2 ++ plugins/Clist_nicer/src/alphablend.cpp | 28 +++++++---------- plugins/Clist_nicer/src/clcmsgs.cpp | 2 +- plugins/Clist_nicer/src/clui.cpp | 4 +-- plugins/Clist_nicer/src/extBackg.cpp | 47 ++++++++++++++++++---------- plugins/Clist_nicer/src/viewmodes.cpp | 4 +-- 6 files changed, 48 insertions(+), 39 deletions(-) (limited to 'plugins/Clist_nicer/src') diff --git a/plugins/Clist_nicer/src/Coolsb/coolsblib.cpp b/plugins/Clist_nicer/src/Coolsb/coolsblib.cpp index 538f77f2a7..542493674a 100644 --- a/plugins/Clist_nicer/src/Coolsb/coolsblib.cpp +++ b/plugins/Clist_nicer/src/Coolsb/coolsblib.cpp @@ -388,6 +388,8 @@ int WINAPI CoolSB_SetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi, BOOL fR } SCROLLBAR *sbar = GetScrollBarFromHwnd(hwnd, fnBar); + if (sbar == NULL) + return; if ((lpsi->fMask & SIF_DISABLENOSCROLL) || (sbar->fScrollFlags & CSBS_THUMBALWAYS)) { if (!sbar->fScrollVisible) { diff --git a/plugins/Clist_nicer/src/alphablend.cpp b/plugins/Clist_nicer/src/alphablend.cpp index 1142ccf91f..a7bcb016ca 100644 --- a/plugins/Clist_nicer/src/alphablend.cpp +++ b/plugins/Clist_nicer/src/alphablend.cpp @@ -81,9 +81,9 @@ void __forceinline DrawBorderStyle(HDC hdcwnd, RECT *rc, DWORD BORDERSTYLE) } void DrawAlpha(HDC hdcwnd, PRECT rc, DWORD basecolor, int alpha, DWORD basecolor2, BOOL transparent, BYTE FLG_GRADIENT, BYTE FLG_CORNER, DWORD BORDERSTYLE, ImageItem *imageItem) { - HBRUSH BrMask; - HBRUSH holdbrush; - HDC hdc; + if (rc == NULL) + return; + BLENDFUNCTION bf; HBITMAP hbitmap; HBITMAP holdbitmap; @@ -128,8 +128,6 @@ void DrawAlpha(HDC hdcwnd, PRECT rc, DWORD basecolor, int alpha, DWORD basecolor return; } - if (rc == NULL) - return; if (rc->right < rc->left || rc->bottom < rc->top || (realHeight <= 0) || (realWidth <= 0)) return; @@ -167,9 +165,6 @@ void DrawAlpha(HDC hdcwnd, PRECT rc, DWORD basecolor, int alpha, DWORD basecolor saved_alpha = (UCHAR) (basecolor >> 24); if (alpha < 100) { - BLENDFUNCTION bf; - HDC hdc; - HBITMAP hbm, hbmOld; LONG width = rc->right - rc->left, height = rc->bottom - rc->top; tvtx[0].x = tvtx[0].y = 0; @@ -178,15 +173,16 @@ void DrawAlpha(HDC hdcwnd, PRECT rc, DWORD basecolor, int alpha, DWORD basecolor basecolor = argb_from_cola(revcolref(basecolor), alpha); basecolor2 = argb_from_cola(revcolref(basecolor2), alpha); + BLENDFUNCTION bf; bf.BlendOp = AC_SRC_OVER; bf.BlendFlags = 0; bf.SourceConstantAlpha = percent_to_byte((UINT32)alpha); bf.AlphaFormat = 0; // so it will use our specified alpha value - hdc = CreateCompatibleDC(hdcwnd); + HDC hdc = CreateCompatibleDC(hdcwnd); if ( !hdc) return; - hbm = CreateCompatibleBitmap(hdcwnd, width, height); - hbmOld = reinterpret_cast(SelectObject(hdc, hbm)); + HBITMAP hbm = CreateCompatibleBitmap(hdcwnd, width, height); + HBITMAP hbmOld = reinterpret_cast(SelectObject(hdc, hbm)); GdiGradientFill(hdc, tvtx, 2, &grect, 1, (FLG_GRADIENT & GRADIENT_TB || FLG_GRADIENT & GRADIENT_BT) ? GRADIENT_FILL_RECT_V : GRADIENT_FILL_RECT_H); GdiAlphaBlend(hdcwnd, rc->left, rc->top, width, height, hdc, 0, 0, width, height, bf); @@ -206,8 +202,8 @@ void DrawAlpha(HDC hdcwnd, PRECT rc, DWORD basecolor, int alpha, DWORD basecolor return; } - hdc = CreateCompatibleDC(hdcwnd); - if ( !hdc) + HDC hdc = CreateCompatibleDC(hdcwnd); + if (!hdc) return; memset(&bmi, 0, sizeof(BITMAPINFO)); @@ -230,9 +226,6 @@ void DrawAlpha(HDC hdcwnd, PRECT rc, DWORD basecolor, int alpha, DWORD basecolor bmi.bmiHeader.biCompression = BI_RGB; bmi.bmiHeader.biSizeImage = ulBitmapWidth * ulBitmapHeight * 4; - if (ulBitmapWidth <= 0 || ulBitmapHeight <= 0) - return; - hbitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, &pvBits, NULL, 0x0); if (hbitmap == NULL || pvBits == NULL) { DeleteDC(hdc); @@ -290,7 +283,8 @@ void DrawAlpha(HDC hdcwnd, PRECT rc, DWORD basecolor, int alpha, DWORD basecolor saved_alpha = (UCHAR) (basecolor >> 24); // corners - BrMask = CreateSolidBrush(RGB(0xFF, 0x00, 0xFF)); + HBRUSH holdbrush; + HBRUSH BrMask = CreateSolidBrush(RGB(0xFF, 0x00, 0xFF)); { bmi.bmiHeader.biWidth = ulBitmapWidth = realHeightHalf; bmi.bmiHeader.biHeight = ulBitmapHeight = realHeight; diff --git a/plugins/Clist_nicer/src/clcmsgs.cpp b/plugins/Clist_nicer/src/clcmsgs.cpp index 637b8547e3..dc85033317 100644 --- a/plugins/Clist_nicer/src/clcmsgs.cpp +++ b/plugins/Clist_nicer/src/clcmsgs.cpp @@ -87,7 +87,7 @@ LRESULT ProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM return 0; case CLM_SETFONT: - if (HIWORD(lParam)<0 || HIWORD(lParam)>FONTID_LAST) + if (HIWORD(lParam)>FONTID_LAST) return 0; dat->fontInfo[HIWORD(lParam)].hFont = (HFONT)wParam; dat->fontInfo[HIWORD(lParam)].changed = 1; diff --git a/plugins/Clist_nicer/src/clui.cpp b/plugins/Clist_nicer/src/clui.cpp index 4beb623b86..ea83885538 100644 --- a/plugins/Clist_nicer/src/clui.cpp +++ b/plugins/Clist_nicer/src/clui.cpp @@ -496,7 +496,7 @@ void BlitWallpaper(HDC hdc, RECT *rc, struct ClcData *dat) HRGN my_rgn = CreateRectRgn(rc->left, rc->top, rc->right, rc->bottom); SelectClipRgn(hdc, my_rgn); maxx = dat->backgroundBmpUse & CLBF_TILEH ? rc->right : rc->left + 1; - maxy = dat->backgroundBmpUse & CLBF_TILEV ? maxy = rc->bottom : y + 1; + maxy = dat->backgroundBmpUse & CLBF_TILEV ? rc->bottom : y + 1; switch (dat->backgroundBmpUse & CLBM_TYPE) { case CLB_STRETCH: if (dat->backgroundBmpUse & CLBF_PROPORTIONAL) { @@ -1052,7 +1052,7 @@ skipbg: case WM_WINDOWPOSCHANGING: if (pcli->hwndContactList != NULL) { WINDOWPOS *wp = (WINDOWPOS *)lParam; - if (wp && wp->flags & SWP_NOSIZE) + if (!wp || (wp->flags & SWP_NOSIZE)) return FALSE; RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp index 61892d0c33..b43cececcd 100644 --- a/plugins/Clist_nicer/src/extBackg.cpp +++ b/plugins/Clist_nicer/src/extBackg.cpp @@ -1219,7 +1219,7 @@ void IMG_LoadItems() void LoadPerContactSkins(TCHAR *tszFileName) { - char *p, szItem[100]; + char szItem[100]; char *szSections = reinterpret_cast(malloc(3002)); StatusItems_t *items = NULL, *this_item; int i = 1; @@ -1230,7 +1230,7 @@ void LoadPerContactSkins(TCHAR *tszFileName) ReadItem(&default_item, "%Default", file); memset(szSections, 0, 3000); - p = szSections; + char *p = szSections; GetPrivateProfileSectionNamesA(szSections, 3000, file); szSections[3001] = szSections[3000] = 0; p = szSections; @@ -1264,7 +1264,8 @@ void LoadPerContactSkins(TCHAR *tszFileName) char *uid = (char *)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid != NULL) { DBVARIANT dbv = {0}; - db_get(hContact, szProto, uid, &dbv); + if (db_get(hContact, szProto, uid, &dbv)) + return; char UIN[40]; switch (dbv.type) { @@ -1328,20 +1329,32 @@ void extbk_import(char *file, HWND hwndDlg) if (p->statusID == ID_EXTBKSEPARATOR) continue; - char *pszEnd = buffer + mir_snprintf(buffer, SIZEOF(buffer), "%s_", p->szDBname); - strcpy(pszEnd, "ALPHA"); GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->ALPHA), sizeof(p->ALPHA), file); - strcpy(pszEnd, "COLOR"); GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->COLOR), sizeof(p->COLOR), file); - strcpy(pszEnd, "COLOR2"); GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->COLOR2), sizeof(p->COLOR2), file); - strcpy(pszEnd, "COLOR2_TRANSPARENT"); GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->COLOR2_TRANSPARENT), sizeof(p->COLOR2_TRANSPARENT), file); - strcpy(pszEnd, "TEXTCOLOR"); GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->TEXTCOLOR), sizeof(p->TEXTCOLOR), file); - strcpy(pszEnd, "CORNER"); GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->CORNER), sizeof(p->CORNER), file); - strcpy(pszEnd, "GRADIENT"); GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->GRADIENT), sizeof(p->GRADIENT), file); - strcpy(pszEnd, "IGNORED"); GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->IGNORED), sizeof(p->IGNORED), file); - strcpy(pszEnd, "MARGIN_BOTTOM"); GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_BOTTOM), sizeof(p->MARGIN_BOTTOM), file); - strcpy(pszEnd, "MARGIN_LEFT"); GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_LEFT), sizeof(p->MARGIN_LEFT), file); - strcpy(pszEnd, "MARGIN_RIGHT"); GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_RIGHT), sizeof(p->MARGIN_RIGHT), file); - strcpy(pszEnd, "MARGIN_TOP"); GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_TOP), sizeof(p->MARGIN_TOP), file); - strcpy(pszEnd, "BORDERSTYLE"); GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->BORDERSTYLE), sizeof(p->BORDERSTYLE), file); + mir_snprintf(buffer, SIZEOF(buffer), "%s_ALPHA", p->szDBname); + GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->ALPHA), sizeof(p->ALPHA), file); + mir_snprintf(buffer, SIZEOF(buffer), "%s_COLOR", p->szDBname); + GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->COLOR), sizeof(p->COLOR), file); + mir_snprintf(buffer, SIZEOF(buffer), "%s_COLOR2", p->szDBname); + GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->COLOR2), sizeof(p->COLOR2), file); + mir_snprintf(buffer, SIZEOF(buffer), "%s_COLOR2_TRANSPARENT", p->szDBname); + GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->COLOR2_TRANSPARENT), sizeof(p->COLOR2_TRANSPARENT), file); + mir_snprintf(buffer, SIZEOF(buffer), "%s_TEXTCOLOR", p->szDBname); + GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->TEXTCOLOR), sizeof(p->TEXTCOLOR), file); + mir_snprintf(buffer, SIZEOF(buffer), "%s_CORNER", p->szDBname); + GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->CORNER), sizeof(p->CORNER), file); + mir_snprintf(buffer, SIZEOF(buffer), "%s_GRADIENT", p->szDBname); + GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->GRADIENT), sizeof(p->GRADIENT), file); + mir_snprintf(buffer, SIZEOF(buffer), "%s_IGNORED", p->szDBname); + GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->IGNORED), sizeof(p->IGNORED), file); + mir_snprintf(buffer, SIZEOF(buffer), "%s_MARGIN_BOTTOM", p->szDBname); + GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_BOTTOM), sizeof(p->MARGIN_BOTTOM), file); + mir_snprintf(buffer, SIZEOF(buffer), "%s_MARGIN_LEFT", p->szDBname); + GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_LEFT), sizeof(p->MARGIN_LEFT), file); + mir_snprintf(buffer, SIZEOF(buffer), "%s_MARGIN_RIGHT", p->szDBname); + GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_RIGHT), sizeof(p->MARGIN_RIGHT), file); + mir_snprintf(buffer, SIZEOF(buffer), "%s_MARGIN_TOP", p->szDBname); + GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_TOP), sizeof(p->MARGIN_TOP), file); + mir_snprintf(buffer, SIZEOF(buffer), "%s_BORDERSTYLE", p->szDBname); + GetPrivateProfileStructA("ExtBKSettings", buffer, &(p->BORDERSTYLE), sizeof(p->BORDERSTYLE), file); } data = 0; diff --git a/plugins/Clist_nicer/src/viewmodes.cpp b/plugins/Clist_nicer/src/viewmodes.cpp index 23a5e5326f..b5908f5c6a 100644 --- a/plugins/Clist_nicer/src/viewmodes.cpp +++ b/plugins/Clist_nicer/src/viewmodes.cpp @@ -972,8 +972,8 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM mii.fMask = MIIM_STRING; mii.dwTypeData = szTemp; mii.cch = 256; - GetMenuItemInfoA(hViewModeMenu, selection, FALSE, &mii); - ApplyViewMode(szTemp); + if(GetMenuItemInfoA(hViewModeMenu, selection, FALSE, &mii)) + ApplyViewMode(szTemp); } break; } -- cgit v1.2.3