mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
- Now retries UpdateLayeredWindow if it fails for some reason. (E.g. when SetLayeredWindowAttributes is called by other application process.)
- Replaced Get(Set)WindowLong with Get(Set)WindowLongPtr. - Code cosmetics.
This commit is contained in:
parent
476eaf1679
commit
8e4d37a8ea
@ -67,7 +67,7 @@ INT_PTR CDialog::OnActivate(WPARAM wParam, LPARAM lParam)
|
||||
|
||||
void CDialog::SetDialogRTL()
|
||||
{
|
||||
SetWindowLong(m_Window, GWL_EXSTYLE, GetWindowLong(m_Window, GWL_EXSTYLE) | WS_EX_LAYOUTRTL);
|
||||
SetWindowLongPtr(m_Window, GWL_EXSTYLE, GetWindowLongPtr(m_Window, GWL_EXSTYLE) | WS_EX_LAYOUTRTL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -376,7 +376,7 @@ void CDialogManage::CTabSkins::Initialize()
|
||||
|
||||
// Get rid of the EDITTEXT control border
|
||||
item = GetDlgItem(m_Window, IDC_MANAGESKINS_DESCRIPTION_TEXT);
|
||||
SetWindowLong(item, GWL_EXSTYLE, GetWindowLong(item, GWL_EXSTYLE) &~ WS_EX_CLIENTEDGE);
|
||||
SetWindowLongPtr(item, GWL_EXSTYLE, GetWindowLongPtr(item, GWL_EXSTYLE) &~ WS_EX_CLIENTEDGE);
|
||||
SetWindowPos(item, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
|
||||
|
||||
item = GetDlgItem(m_Window, IDC_MANAGESKINS_DISPLAYMONITOR_BUTTON);
|
||||
|
@ -313,6 +313,24 @@ void CMeterWindow::IgnoreAeroPeek()
|
||||
}
|
||||
}
|
||||
|
||||
void CMeterWindow::AddWindowExStyle(LONG_PTR flag)
|
||||
{
|
||||
LONG_PTR style = GetWindowLongPtr(m_Window, GWL_EXSTYLE);
|
||||
if ((style & flag) == 0)
|
||||
{
|
||||
SetWindowLongPtr(m_Window, GWL_EXSTYLE, style | flag);
|
||||
}
|
||||
}
|
||||
|
||||
void CMeterWindow::RemoveWindowExStyle(LONG_PTR flag)
|
||||
{
|
||||
LONG_PTR style = GetWindowLongPtr(m_Window, GWL_EXSTYLE);
|
||||
if ((style & flag) != 0)
|
||||
{
|
||||
SetWindowLongPtr(m_Window, GWL_EXSTYLE, style & ~flag);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Unloads the skin with delay to avoid crash (and for fade to complete).
|
||||
**
|
||||
@ -400,11 +418,7 @@ void CMeterWindow::Refresh(bool init, bool all)
|
||||
InitializeMeters();
|
||||
|
||||
// Remove transparent flag
|
||||
LONG style = GetWindowLong(m_Window, GWL_EXSTYLE);
|
||||
if ((style & WS_EX_TRANSPARENT) != 0)
|
||||
{
|
||||
SetWindowLong(m_Window, GWL_EXSTYLE, style & ~WS_EX_TRANSPARENT);
|
||||
}
|
||||
RemoveWindowExStyle(WS_EX_TRANSPARENT);
|
||||
|
||||
m_Hidden = m_WindowStartHidden;
|
||||
|
||||
@ -636,7 +650,7 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all)
|
||||
// Find the "backmost" topmost window
|
||||
while (winPos = ::GetNextWindow(winPos, GW_HWNDPREV))
|
||||
{
|
||||
if (GetWindowLong(winPos, GWL_EXSTYLE) & WS_EX_TOPMOST)
|
||||
if (GetWindowLongPtr(winPos, GWL_EXSTYLE) & WS_EX_TOPMOST)
|
||||
{
|
||||
// Insert after the found window
|
||||
if (0 != SetWindowPos(m_Window, winPos, 0, 0, 0, 0, ZPOS_FLAGS))
|
||||
@ -2874,9 +2888,7 @@ void CMeterWindow::UpdateTransparency(int alpha, bool reset)
|
||||
{
|
||||
if (reset)
|
||||
{
|
||||
// Add the window flag
|
||||
LONG style = GetWindowLong(m_Window, GWL_EXSTYLE);
|
||||
SetWindowLong(m_Window, GWL_EXSTYLE, style | WS_EX_LAYERED);
|
||||
AddWindowExStyle(WS_EX_LAYERED);
|
||||
}
|
||||
|
||||
BLENDFUNCTION blendPixelFunction = {AC_SRC_OVER, 0, alpha, AC_SRC_ALPHA};
|
||||
@ -2888,7 +2900,14 @@ void CMeterWindow::UpdateTransparency(int alpha, bool reset)
|
||||
HDC dcMemory = CreateCompatibleDC(dcScreen);
|
||||
SelectObject(dcMemory, m_DIBSectionBuffer);
|
||||
|
||||
UpdateLayeredWindow(m_Window, dcScreen, &ptWindowScreenPosition, &szWindow, dcMemory, &ptSrc, 0, &blendPixelFunction, ULW_ALPHA);
|
||||
BOOL ret = UpdateLayeredWindow(m_Window, dcScreen, &ptWindowScreenPosition, &szWindow, dcMemory, &ptSrc, 0, &blendPixelFunction, ULW_ALPHA);
|
||||
if (!ret)
|
||||
{
|
||||
// Retry after resetting WS_EX_LAYERED flag
|
||||
RemoveWindowExStyle(WS_EX_LAYERED);
|
||||
AddWindowExStyle(WS_EX_LAYERED);
|
||||
UpdateLayeredWindow(m_Window, dcScreen, &ptWindowScreenPosition, &szWindow, dcMemory, &ptSrc, 0, &blendPixelFunction, ULW_ALPHA);
|
||||
}
|
||||
|
||||
ReleaseDC(0, dcScreen);
|
||||
DeleteDC(dcMemory);
|
||||
@ -2899,9 +2918,7 @@ void CMeterWindow::UpdateTransparency(int alpha, bool reset)
|
||||
{
|
||||
if (reset)
|
||||
{
|
||||
// Remove the window flag
|
||||
LONG style = GetWindowLong(m_Window, GWL_EXSTYLE);
|
||||
SetWindowLong(m_Window, GWL_EXSTYLE, style & ~WS_EX_LAYERED);
|
||||
RemoveWindowExStyle(WS_EX_LAYERED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3129,11 +3146,7 @@ void CMeterWindow::ShowWindowIfAppropriate()
|
||||
if (!inside || keyDown)
|
||||
{
|
||||
// If Alt, shift or control is down, remove the transparent flag
|
||||
LONG style = GetWindowLong(m_Window, GWL_EXSTYLE);
|
||||
if ((style & WS_EX_TRANSPARENT) != 0)
|
||||
{
|
||||
SetWindowLong(m_Window, GWL_EXSTYLE, style & ~WS_EX_TRANSPARENT);
|
||||
}
|
||||
RemoveWindowExStyle(WS_EX_TRANSPARENT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3327,11 +3340,7 @@ LRESULT CMeterWindow::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (m_ClickThrough)
|
||||
{
|
||||
LONG style = GetWindowLong(m_Window, GWL_EXSTYLE);
|
||||
if ((style & WS_EX_TRANSPARENT) == 0)
|
||||
{
|
||||
SetWindowLong(m_Window, GWL_EXSTYLE, style | WS_EX_TRANSPARENT);
|
||||
}
|
||||
AddWindowExStyle(WS_EX_TRANSPARENT);
|
||||
}
|
||||
|
||||
if (!m_Hidden)
|
||||
@ -3366,8 +3375,8 @@ LRESULT CMeterWindow::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
if (!m_ClickThrough || keyDown)
|
||||
{
|
||||
POINT pos;
|
||||
pos.x = (SHORT)LOWORD(lParam);
|
||||
pos.y = (SHORT)HIWORD(lParam);
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
|
||||
if (uMsg == WM_NCMOUSEMOVE)
|
||||
{
|
||||
@ -3599,11 +3608,7 @@ void CMeterWindow::SetClickThrough(bool b)
|
||||
if (!m_ClickThrough)
|
||||
{
|
||||
// Remove transparent flag
|
||||
LONG style = GetWindowLong(m_Window, GWL_EXSTYLE);
|
||||
if ((style & WS_EX_TRANSPARENT) != 0)
|
||||
{
|
||||
SetWindowLong(m_Window, GWL_EXSTYLE, style & ~WS_EX_TRANSPARENT);
|
||||
}
|
||||
RemoveWindowExStyle(WS_EX_TRANSPARENT);
|
||||
}
|
||||
|
||||
if (m_MouseOver)
|
||||
@ -3775,8 +3780,8 @@ LRESULT CMeterWindow::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
if (m_WindowDraggable && !m_Rainmeter->GetDisableDragging())
|
||||
{
|
||||
POINT pos;
|
||||
pos.x = (SHORT)LOWORD(lParam);
|
||||
pos.y = (SHORT)HIWORD(lParam);
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
MapWindowPoints(NULL, m_Window, &pos, 1);
|
||||
|
||||
int x1 = m_DragMargins.left;
|
||||
@ -4002,8 +4007,8 @@ LRESULT CMeterWindow::OnSettingChange(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT CMeterWindow::OnLeftButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
POINT pos;
|
||||
pos.x = (SHORT)LOWORD(lParam);
|
||||
pos.y = (SHORT)HIWORD(lParam);
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
|
||||
if (uMsg == WM_NCLBUTTONDOWN)
|
||||
{
|
||||
@ -4034,8 +4039,8 @@ LRESULT CMeterWindow::OnLeftButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT CMeterWindow::OnLeftButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
POINT pos;
|
||||
pos.x = (SHORT)LOWORD(lParam);
|
||||
pos.y = (SHORT)HIWORD(lParam);
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
|
||||
if (uMsg == WM_NCLBUTTONUP)
|
||||
{
|
||||
@ -4058,8 +4063,8 @@ LRESULT CMeterWindow::OnLeftButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT CMeterWindow::OnLeftButtonDoubleClick(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
POINT pos;
|
||||
pos.x = (SHORT)LOWORD(lParam);
|
||||
pos.y = (SHORT)HIWORD(lParam);
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
|
||||
if (uMsg == WM_NCLBUTTONDBLCLK)
|
||||
{
|
||||
@ -4085,8 +4090,8 @@ LRESULT CMeterWindow::OnLeftButtonDoubleClick(UINT uMsg, WPARAM wParam, LPARAM l
|
||||
LRESULT CMeterWindow::OnRightButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
POINT pos;
|
||||
pos.x = (SHORT)LOWORD(lParam);
|
||||
pos.y = (SHORT)HIWORD(lParam);
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
|
||||
if (uMsg == WM_NCRBUTTONDOWN)
|
||||
{
|
||||
@ -4109,8 +4114,8 @@ LRESULT CMeterWindow::OnRightButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT CMeterWindow::OnRightButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
POINT pos;
|
||||
pos.x = (SHORT)LOWORD(lParam);
|
||||
pos.y = (SHORT)HIWORD(lParam);
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
|
||||
// Handle buttons
|
||||
HandleButtons(pos, BUTTONPROC_MOVE);
|
||||
@ -4132,8 +4137,8 @@ LRESULT CMeterWindow::OnRightButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT CMeterWindow::OnRightButtonDoubleClick(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
POINT pos;
|
||||
pos.x = (SHORT)LOWORD(lParam);
|
||||
pos.y = (SHORT)HIWORD(lParam);
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
|
||||
if (uMsg == WM_NCRBUTTONDBLCLK)
|
||||
{
|
||||
@ -4159,8 +4164,8 @@ LRESULT CMeterWindow::OnRightButtonDoubleClick(UINT uMsg, WPARAM wParam, LPARAM
|
||||
LRESULT CMeterWindow::OnMiddleButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
POINT pos;
|
||||
pos.x = (SHORT)LOWORD(lParam);
|
||||
pos.y = (SHORT)HIWORD(lParam);
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
|
||||
if (uMsg == WM_NCMBUTTONDOWN)
|
||||
{
|
||||
@ -4183,8 +4188,8 @@ LRESULT CMeterWindow::OnMiddleButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||
LRESULT CMeterWindow::OnMiddleButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
POINT pos;
|
||||
pos.x = (SHORT)LOWORD(lParam);
|
||||
pos.y = (SHORT)HIWORD(lParam);
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
|
||||
if (uMsg == WM_NCMBUTTONUP)
|
||||
{
|
||||
@ -4207,8 +4212,8 @@ LRESULT CMeterWindow::OnMiddleButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT CMeterWindow::OnMiddleButtonDoubleClick(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
POINT pos;
|
||||
pos.x = (SHORT)LOWORD(lParam);
|
||||
pos.y = (SHORT)HIWORD(lParam);
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
|
||||
if (uMsg == WM_NCMBUTTONDBLCLK)
|
||||
{
|
||||
@ -4245,8 +4250,8 @@ LRESULT CMeterWindow::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.x = (SHORT)LOWORD(lParam);
|
||||
pos.y = (SHORT)HIWORD(lParam);
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
|
||||
// Transform the point to client rect
|
||||
POINT posc = {pos.x - rect.left, pos.y - rect.top};
|
||||
@ -4593,8 +4598,8 @@ LRESULT CMeterWindow::OnMove(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
// and in parent-client coordinates for child windows.
|
||||
|
||||
// Store the new window position
|
||||
m_ScreenX = (SHORT)LOWORD(lParam);
|
||||
m_ScreenY = (SHORT)HIWORD(lParam);
|
||||
m_ScreenX = GET_X_LPARAM(lParam);
|
||||
m_ScreenY = GET_Y_LPARAM(lParam);
|
||||
|
||||
SetWindowPositionVariables(m_ScreenX, m_ScreenY);
|
||||
|
||||
|
@ -336,6 +336,8 @@ private:
|
||||
bool DoMoveAction(int x, int y, MOUSE mouse);
|
||||
bool ResizeWindow(bool reset);
|
||||
void IgnoreAeroPeek();
|
||||
void AddWindowExStyle(LONG_PTR flag);
|
||||
void RemoveWindowExStyle(LONG_PTR flag);
|
||||
void BlurBehindWindow(BOOL fEnable);
|
||||
void SetWindowPositionVariables(int x, int y);
|
||||
void SetWindowSizeVariables(int w, int h);
|
||||
|
@ -814,7 +814,7 @@ void CSystem::PrepareHelperWindow(HWND WorkerW)
|
||||
HWND hwnd = WorkerW;
|
||||
while (hwnd = ::GetNextWindow(hwnd, GW_HWNDPREV))
|
||||
{
|
||||
if (GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
|
||||
if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
|
||||
{
|
||||
WCHAR className[64], windowText[64];
|
||||
|
||||
@ -832,7 +832,7 @@ void CSystem::PrepareHelperWindow(HWND WorkerW)
|
||||
if (logging)
|
||||
{
|
||||
LogWithArgs(LOG_DEBUG, L"System: HelperWindow: hwnd=0x%p (WorkerW=0x%p), hwndInsertAfter=0x%p (\"%s\" %s) - %s",
|
||||
c_HelperWindow, WorkerW, hwnd, windowText, className, (GetWindowLong(c_HelperWindow, GWL_EXSTYLE) & WS_EX_TOPMOST) ? L"TOPMOST" : L"NORMAL");
|
||||
c_HelperWindow, WorkerW, hwnd, windowText, className, (GetWindowLongPtr(c_HelperWindow, GWL_EXSTYLE) & WS_EX_TOPMOST) ? L"TOPMOST" : L"NORMAL");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -849,7 +849,7 @@ void CSystem::PrepareHelperWindow(HWND WorkerW)
|
||||
if (logging)
|
||||
{
|
||||
LogWithArgs(LOG_DEBUG, L"System: HelperWindow: hwnd=0x%p (WorkerW=0x%p), hwndInsertAfter=HWND_TOPMOST - %s",
|
||||
c_HelperWindow, WorkerW, (GetWindowLong(c_HelperWindow, GWL_EXSTYLE) & WS_EX_TOPMOST) ? L"TOPMOST" : L"NORMAL");
|
||||
c_HelperWindow, WorkerW, (GetWindowLongPtr(c_HelperWindow, GWL_EXSTYLE) & WS_EX_TOPMOST) ? L"TOPMOST" : L"NORMAL");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -860,7 +860,7 @@ void CSystem::PrepareHelperWindow(HWND WorkerW)
|
||||
if (logging)
|
||||
{
|
||||
LogWithArgs(LOG_DEBUG, L"System: HelperWindow: hwnd=0x%p (WorkerW=0x%p), hwndInsertAfter=HWND_BOTTOM - %s",
|
||||
c_HelperWindow, WorkerW, (GetWindowLong(c_HelperWindow, GWL_EXSTYLE) & WS_EX_TOPMOST) ? L"TOPMOST" : L"NORMAL");
|
||||
c_HelperWindow, WorkerW, (GetWindowLongPtr(c_HelperWindow, GWL_EXSTYLE) & WS_EX_TOPMOST) ? L"TOPMOST" : L"NORMAL");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user