From d9f1ce1a3740f213cd0b43085a399bd03f64f200 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 17 Feb 2013 12:38:33 +0000 Subject: gdi resources cleaning patch git-svn-id: http://svn.miranda-ng.org/main/trunk@3621 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/options/headerbar.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/modules/options/headerbar.cpp') diff --git a/src/modules/options/headerbar.cpp b/src/modules/options/headerbar.cpp index 5db6a627fc..a94c196567 100644 --- a/src/modules/options/headerbar.cpp +++ b/src/modules/options/headerbar.cpp @@ -112,13 +112,11 @@ static void MHeaderbar_FillRect(HDC hdc, int x, int y, int width, int height, CO static void MHeaderbar_DrawGradient(HDC hdc, int x, int y, int width, int height, RGBQUAD *rgb0, RGBQUAD *rgb1) { - int i; - int oldMode = SetBkMode(hdc, OPAQUE); COLORREF oldColor = SetBkColor(hdc, 0); RECT rc; SetRect(&rc, x, 0, x+width, 0); - for (i = y+height; --i >= y;) + for (int i = y+height; --i >= y;) { COLORREF color = RGB( ((height-i-1)*rgb0->rgbRed + i*rgb1->rgbRed) / height, @@ -193,7 +191,7 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, LOGFONT lf; GetObject(hFont, sizeof(lf), &lf); lf.lfWeight = FW_BOLD; - HFONT hFntBold = CreateFontIndirect(&lf); + HFONT hFntBold = CreateFontIndirect(&lf), hOldFont; if (mit->hIcon) DrawIcon(tempDC, 10, iTopSpace, mit->hIcon); @@ -218,7 +216,7 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, HANDLE hTheme = openThemeData(hwndDlg, L"Window"); textRect.left = 50; - SelectObject(tempDC, hFntBold); + hOldFont = (HFONT)SelectObject(tempDC, hFntBold); wchar_t *szTitleW = mir_t2u(szTitle); drawThemeTextEx(hTheme, tempDC, WP_CAPTION, CS_ACTIVE, szTitleW, -1, DT_TOP|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX|DT_NOCLIP|DT_END_ELLIPSIS, &textRect, &dto); @@ -236,7 +234,7 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, } else { textRect.left = 50; - SelectObject(tempDC, hFntBold); + hOldFont = (HFONT)SelectObject(tempDC, hFntBold); DrawText(tempDC, szTitle, -1, &textRect, DT_TOP|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX|DT_NOCLIP|DT_END_ELLIPSIS); if (szSubTitle) { @@ -277,6 +275,7 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, SelectObject(tempDC, hOldBmp); DeleteObject(hBmp); + SelectObject(tempDC,hOldFont); DeleteDC(tempDC); EndPaint(hwndDlg, &ps); -- cgit v1.2.3