From 56f1c6a38d999f141b2d33d0d29a7309442bdcee Mon Sep 17 00:00:00 2001 From: spx Date: Thu, 27 May 2010 22:03:09 +0000 Subject: [PATCH] Enabled @include to use variables. Fixed the issue that the window becomes invalid when both window width and height are 0. --- Library/ConfigParser.cpp | 1 + Library/MeterWindow.cpp | 46 +++++++++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index c310421e..cb89c628 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -934,6 +934,7 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile, int depth) if (wcsnicmp(strKey.c_str(), L"@include", 8) == 0) { std::wstring strIncludeFile = buffer; + ReadVariables(); ReplaceVariables(strIncludeFile); if (strIncludeFile.find(L':') == std::wstring::npos && (strIncludeFile.length() < 2 || (strIncludeFile[0] != L'\\' && strIncludeFile[0] != L'/') || (strIncludeFile[1] != L'\\' && strIncludeFile[1] != L'/'))) diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 3635a67f..37e37d97 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -2100,7 +2100,15 @@ void CMeterWindow::Redraw() } if (m_DoubleBuffer) delete m_DoubleBuffer; - m_DoubleBuffer = new Bitmap(m_WindowW, m_WindowH, PixelFormat32bppARGB); + if (m_WindowW == 0 && m_WindowH == 0) + { + // Create a dummy bitmap to avoid invalid state + m_DoubleBuffer = new Bitmap(1, 1, PixelFormat32bppARGB); + } + else + { + m_DoubleBuffer = new Bitmap(m_WindowW, m_WindowH, PixelFormat32bppARGB); + } Graphics graphics(GetDoubleBuffer()); @@ -2270,22 +2278,30 @@ void CMeterWindow::UpdateTransparency(int alpha, bool reset) typedef BOOL (WINAPI * FPUPDATELAYEREDWINDOW)(HWND hWnd, HDC hdcDst, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags); FPUPDATELAYEREDWINDOW UpdateLayeredWindow = (FPUPDATELAYEREDWINDOW)GetProcAddress(m_User32Library, "UpdateLayeredWindow"); - BLENDFUNCTION blendPixelFunction= {AC_SRC_OVER, 0, alpha, AC_SRC_ALPHA}; - POINT ptWindowScreenPosition = {m_ScreenX, m_ScreenY}; - POINT ptSrc = {0, 0}; - SIZE szWindow = {m_WindowW, m_WindowH}; + if (m_WindowW == 0 && m_WindowH == 0) + { + // Reset window to avoid invalid state + UpdateLayeredWindow(m_Window, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0); + } + else + { + BLENDFUNCTION blendPixelFunction= {AC_SRC_OVER, 0, alpha, AC_SRC_ALPHA}; + POINT ptWindowScreenPosition = {m_ScreenX, m_ScreenY}; + POINT ptSrc = {0, 0}; + SIZE szWindow = {m_WindowW, m_WindowH}; - HDC dcScreen = GetDC(GetDesktopWindow()); - HDC dcMemory = CreateCompatibleDC(dcScreen); + HDC dcScreen = GetDC(GetDesktopWindow()); + HDC dcMemory = CreateCompatibleDC(dcScreen); - HBITMAP dbBitmap; - m_DoubleBuffer->GetHBITMAP(Color(0, 0, 0, 0), &dbBitmap); - HBITMAP oldBitmap = (HBITMAP)SelectObject(dcMemory, dbBitmap); - UpdateLayeredWindow(m_Window, dcScreen, &ptWindowScreenPosition, &szWindow, dcMemory, &ptSrc, 0, &blendPixelFunction, ULW_ALPHA); - ReleaseDC(GetDesktopWindow(), dcScreen); - SelectObject(dcMemory, oldBitmap); - DeleteDC(dcMemory); - DeleteObject(dbBitmap); + HBITMAP dbBitmap; + m_DoubleBuffer->GetHBITMAP(Color(0, 0, 0, 0), &dbBitmap); + HBITMAP oldBitmap = (HBITMAP)SelectObject(dcMemory, dbBitmap); + UpdateLayeredWindow(m_Window, dcScreen, &ptWindowScreenPosition, &szWindow, dcMemory, &ptSrc, 0, &blendPixelFunction, ULW_ALPHA); + ReleaseDC(GetDesktopWindow(), dcScreen); + SelectObject(dcMemory, oldBitmap); + DeleteDC(dcMemory); + DeleteObject(dbBitmap); + } m_TransparencyValue = alpha; }