From fdce46bbb9b5f74237f422c55795f241d669653e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 9 Jan 2018 19:18:39 +0300 Subject: fixes #1076 --- src/mir_app/src/options.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'src/mir_app') diff --git a/src/mir_app/src/options.cpp b/src/mir_app/src/options.cpp index 7a6ba30b64..261841f39b 100644 --- a/src/mir_app/src/options.cpp +++ b/src/mir_app/src/options.cpp @@ -111,23 +111,25 @@ static void AeroPaintControl(HWND hwnd, HDC hdc, UINT msg, LPARAM lpFlags) BYTE *pBits; HBITMAP hBmp = CreateDIBSection(tempDC, &bmi, DIB_RGB_COLORS, (void **)&pBits, nullptr, 0); - HBITMAP hOldBmp = (HBITMAP)SelectObject(tempDC, hBmp); - - // paint - SetPropA(hwnd, "Miranda.AeroRender.Active", (HANDLE)TRUE); - mir_callNextSubclass(hwnd, AeroPaintSubclassProc, msg, (WPARAM)tempDC, lpFlags); - SetPropA(hwnd, "Miranda.AeroRender.Active", (HANDLE)FALSE); - - // Fix alpha channel - GdiFlush(); - for (int i = 0; i < rc.right*rc.bottom; i++, pBits += 4) - if (!pBits[3]) - pBits[3] = 255; - - // Copy to output - BitBlt(hdc, 0, 0, rc.right, rc.bottom, tempDC, 0, 0, SRCCOPY); - SelectObject(tempDC, hOldBmp); - DeleteObject(hBmp); + if (hBmp && pBits) { + HBITMAP hOldBmp = (HBITMAP)SelectObject(tempDC, hBmp); + + // paint + SetPropA(hwnd, "Miranda.AeroRender.Active", (HANDLE)TRUE); + mir_callNextSubclass(hwnd, AeroPaintSubclassProc, msg, (WPARAM)tempDC, lpFlags); + SetPropA(hwnd, "Miranda.AeroRender.Active", (HANDLE)FALSE); + + // Fix alpha channel + GdiFlush(); + for (int i = 0; i < rc.right*rc.bottom; i++, pBits += 4) + if (!pBits[3]) + pBits[3] = 255; + + // Copy to output + BitBlt(hdc, 0, 0, rc.right, rc.bottom, tempDC, 0, 0, SRCCOPY); + SelectObject(tempDC, hOldBmp); + DeleteObject(hBmp); + } DeleteDC(tempDC); } -- cgit v1.2.3