Enabled @include to use variables.

Fixed the issue that the window becomes invalid when both window width and height are 0.
This commit is contained in:
spx 2010-05-27 22:03:09 +00:00
parent 3640c60810
commit 56f1c6a38d
2 changed files with 32 additions and 15 deletions

View File

@ -934,6 +934,7 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile, int depth)
if (wcsnicmp(strKey.c_str(), L"@include", 8) == 0) if (wcsnicmp(strKey.c_str(), L"@include", 8) == 0)
{ {
std::wstring strIncludeFile = buffer; std::wstring strIncludeFile = buffer;
ReadVariables();
ReplaceVariables(strIncludeFile); ReplaceVariables(strIncludeFile);
if (strIncludeFile.find(L':') == std::wstring::npos && if (strIncludeFile.find(L':') == std::wstring::npos &&
(strIncludeFile.length() < 2 || (strIncludeFile[0] != L'\\' && strIncludeFile[0] != L'/') || (strIncludeFile[1] != L'\\' && strIncludeFile[1] != L'/'))) (strIncludeFile.length() < 2 || (strIncludeFile[0] != L'\\' && strIncludeFile[0] != L'/') || (strIncludeFile[1] != L'\\' && strIncludeFile[1] != L'/')))

View File

@ -2100,7 +2100,15 @@ void CMeterWindow::Redraw()
} }
if (m_DoubleBuffer) delete m_DoubleBuffer; 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()); 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); 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"); FPUPDATELAYEREDWINDOW UpdateLayeredWindow = (FPUPDATELAYEREDWINDOW)GetProcAddress(m_User32Library, "UpdateLayeredWindow");
BLENDFUNCTION blendPixelFunction= {AC_SRC_OVER, 0, alpha, AC_SRC_ALPHA}; if (m_WindowW == 0 && m_WindowH == 0)
POINT ptWindowScreenPosition = {m_ScreenX, m_ScreenY}; {
POINT ptSrc = {0, 0}; // Reset window to avoid invalid state
SIZE szWindow = {m_WindowW, m_WindowH}; 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 dcScreen = GetDC(GetDesktopWindow());
HDC dcMemory = CreateCompatibleDC(dcScreen); HDC dcMemory = CreateCompatibleDC(dcScreen);
HBITMAP dbBitmap; HBITMAP dbBitmap;
m_DoubleBuffer->GetHBITMAP(Color(0, 0, 0, 0), &dbBitmap); m_DoubleBuffer->GetHBITMAP(Color(0, 0, 0, 0), &dbBitmap);
HBITMAP oldBitmap = (HBITMAP)SelectObject(dcMemory, dbBitmap); HBITMAP oldBitmap = (HBITMAP)SelectObject(dcMemory, dbBitmap);
UpdateLayeredWindow(m_Window, dcScreen, &ptWindowScreenPosition, &szWindow, dcMemory, &ptSrc, 0, &blendPixelFunction, ULW_ALPHA); UpdateLayeredWindow(m_Window, dcScreen, &ptWindowScreenPosition, &szWindow, dcMemory, &ptSrc, 0, &blendPixelFunction, ULW_ALPHA);
ReleaseDC(GetDesktopWindow(), dcScreen); ReleaseDC(GetDesktopWindow(), dcScreen);
SelectObject(dcMemory, oldBitmap); SelectObject(dcMemory, oldBitmap);
DeleteDC(dcMemory); DeleteDC(dcMemory);
DeleteObject(dbBitmap); DeleteObject(dbBitmap);
}
m_TransparencyValue = alpha; m_TransparencyValue = alpha;
} }