diff options
author | George Hazan <george.hazan@gmail.com> | 2013-02-17 12:38:33 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-02-17 12:38:33 +0000 |
commit | d9f1ce1a3740f213cd0b43085a399bd03f64f200 (patch) | |
tree | e6e663b1ff92fb9780332a9318cfbfcb4c399c6d /src/modules/options | |
parent | 2ecfefaea1ef0eb0a9a85795d5ac0168b757d3ff (diff) |
gdi resources cleaning patch
git-svn-id: http://svn.miranda-ng.org/main/trunk@3621 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/options')
-rw-r--r-- | src/modules/options/headerbar.cpp | 11 | ||||
-rw-r--r-- | src/modules/options/iconheader.cpp | 17 |
2 files changed, 12 insertions, 16 deletions
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);
diff --git a/src/modules/options/iconheader.cpp b/src/modules/options/iconheader.cpp index 0bdbd3209d..6b51a0afe9 100644 --- a/src/modules/options/iconheader.cpp +++ b/src/modules/options/iconheader.cpp @@ -258,15 +258,10 @@ static void MIcoTab_DrawItem(HWND hwnd, HDC hdc, MIcoTabCtrl *dat, MIcoTab *tab, static LRESULT MIcoTab_OnPaint(HWND hwndDlg, MIcoTabCtrl *mit, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
- HBITMAP hBmp, hOldBmp;
- RECT temprc;
- int i;
HDC hdc = BeginPaint(hwndDlg, &ps);
HDC tempDC = CreateCompatibleDC(hdc);
- HFONT hFont = 0;
-
BITMAPINFO bmi;
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = mit->width;
@@ -274,11 +269,12 @@ static LRESULT MIcoTab_OnPaint(HWND hwndDlg, MIcoTabCtrl *mit, UINT msg, WPARAM bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
- hBmp = CreateDIBSection(tempDC, &bmi, DIB_RGB_COLORS, NULL, NULL, 0);
+ HBITMAP hBmp = CreateDIBSection(tempDC, &bmi, DIB_RGB_COLORS, NULL, NULL, 0);
- hOldBmp = (HBITMAP)SelectObject(tempDC, hBmp);
+ HBITMAP hOldBmp = (HBITMAP)SelectObject(tempDC, hBmp);
if (IsAeroMode()) {
+ RECT temprc;
temprc.left = 0;
temprc.right = mit->width;
temprc.top = 0;
@@ -299,11 +295,11 @@ static LRESULT MIcoTab_OnPaint(HWND hwndDlg, MIcoTabCtrl *mit, UINT msg, WPARAM } }
//Draw Items
- hFont = mit->hFont;
- SelectObject(tempDC, hFont);
+ HFONT hFont = mit->hFont;
+ HFONT hOldFont = (HFONT)SelectObject(tempDC, hFont);
SetBkMode(tempDC, TRANSPARENT);
- for (i=0; i<mit->pList.getCount(); i++) {
+ for (int i=0; i<mit->pList.getCount(); i++) {
MIcoTab *tab = (MIcoTab *)mit->pList[i];
MIcoTab_DrawItem(hwndDlg, tempDC, mit, tab, i);
}
@@ -312,6 +308,7 @@ static LRESULT MIcoTab_OnPaint(HWND hwndDlg, MIcoTabCtrl *mit, UINT msg, WPARAM BitBlt(hdc, mit->rc.left, mit->rc.top, mit->width, mit->height, tempDC, 0, 0, SRCCOPY);
SelectObject(tempDC, hOldBmp);
DeleteObject(hBmp);
+ SelectObject(tempDC,hOldFont);
DeleteDC(tempDC);
EndPaint(hwndDlg, &ps);
|