From a105edf7ab76055c988cb61526aac43e741429d2 Mon Sep 17 00:00:00 2001 From: Sand216 <164842290+Sand216@users.noreply.github.com> Date: Wed, 8 Jul 2026 14:12:53 -0700 Subject: [PATCH] mod: Fix certain applications unable to find taskbar position --- src/Shell/Explorer/Tray.cpp | 13 +++++-- src/Shell/Explorer/TrayNot.cpp | 66 ++++++++++++++++++++++++++++++++++ src/Shell/Explorer/TrayNot.h | 2 ++ src/Shell/Inc/ShUndoc.h | 18 ++++++++-- 4 files changed, 94 insertions(+), 5 deletions(-) diff --git a/src/Shell/Explorer/Tray.cpp b/src/Shell/Explorer/Tray.cpp index bfd703b..545215b 100644 --- a/src/Shell/Explorer/Tray.cpp +++ b/src/Shell/Explorer/Tray.cpp @@ -4244,7 +4244,7 @@ void CTray::_AppBarGetTaskBarPos(PTRAYAPPBARDATA ptabd) { APPBARDATA3264* pabd; - pabd = (APPBARDATA3264*)SHLockShared(UlongToPtr(ptabd->hSharedABD), ptabd->dwProcId); + pabd = (APPBARDATA3264*)SHLockShared((HANDLE)ptabd->hSharedABD, ptabd->dwProcId); if (pabd) { pabd->rc = _arStuckRects[_uStuckPlace]; @@ -4401,7 +4401,7 @@ void CTray::_AppBarQueryPos(PTRAYAPPBARDATA ptabd) { APPBARDATA3264* pabd; - pabd = (APPBARDATA3264*)SHLockShared(UlongToPtr(ptabd->hSharedABD), ptabd->dwProcId); + pabd = (APPBARDATA3264*)SHLockShared((HANDLE)ptabd->hSharedABD, ptabd->dwProcId); if (pabd) { HMONITOR hmon; @@ -4475,7 +4475,7 @@ void CTray::_AppBarSetPos(PTRAYAPPBARDATA ptabd) _AppBarQueryPos(ptabd); - pabd = (APPBARDATA3264*)SHLockShared(UlongToPtr(ptabd->hSharedABD), ptabd->dwProcId); + pabd = (APPBARDATA3264*)SHLockShared((HANDLE)ptabd->hSharedABD, ptabd->dwProcId); if (pabd) { if (!EqualRect(&pab->rc, &pabd->rc)) { @@ -6137,6 +6137,9 @@ LRESULT CTray::v_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case TCDM_LOADINPROC: return (UINT)_LoadInProc((PCOPYDATASTRUCT)lParam); + + case TCMD_NOTIFYINFO: + return _trayNotify.TrayNotifyInfo(_hwndNotify, (HWND)wParam, (PCOPYDATASTRUCT)lParam); } } return FALSE; @@ -7488,6 +7491,10 @@ LRESULT CTray::v_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return _LoadInProc((COPYDATASTRUCT*)lParam); } + case 3: + { + return _trayNotify.TrayNotifyInfo(_hwndNotify, (HWND)wParam, (COPYDATASTRUCT*)lParam); + } } return 0; } diff --git a/src/Shell/Explorer/TrayNot.cpp b/src/Shell/Explorer/TrayNot.cpp index e892e80..110d379 100644 --- a/src/Shell/Explorer/TrayNot.cpp +++ b/src/Shell/Explorer/TrayNot.cpp @@ -5148,6 +5148,47 @@ BOOL CTrayNotify::_TrayNotifyIcon(PTRAYNOTIFYDATA pnid, BOOL *pbRefresh) return bRet; } +LRESULT CTrayNotify::_TrayNotifyInfo(PTRAYNOTIFYINFO pni) +{ + PNOTIFYICONINFO32 pNII = &pni->nii; + if (pNII->cbSize < sizeof(NOTIFYICONINFO32)) + { + return 0; + } + + LRESULT lRet = 0; + + INT_PTR nIcon = m_TrayItemManager.FindItemAssociatedWithHwndUid(GetHWnd(pNII), pNII->uID); + if (nIcon == -1) nIcon = m_TrayItemManager.FindItemAssociatedWithGuid(pNII->guidItem); + if (nIcon >= 0) + { + CTrayItem* pti = m_TrayItemManager.GetItemData(nIcon, TRUE, _hwndToolbar); + + if (pti) + { + RECT rcItem = { 0 }; + + if (!IsWindow(_hwndToolbar) && !IsWindowVisible(_hwndToolbar)) + { + if (pni->dwMessage == 2) + return -1; + return lRet; + } + + if (SendMessage(_hwndToolbar, TB_GETITEMRECT, (WPARAM)nIcon, (LPARAM)&rcItem)) + { + MapWindowPoints(_hwndToolbar, nullptr, (LPPOINT)&rcItem, 2); + + if (pni->dwMessage == 1) + lRet = MAKELRESULT(rcItem.left, rcItem.top); + if (pni->dwMessage == 2) + lRet = MAKELRESULT((rcItem.right - rcItem.left), (rcItem.bottom + rcItem.top)); + } + } + } + + return lRet; +} // Public LRESULT CTrayNotify::TrayNotify(HWND hwndNotify, HWND hwndFrom, PCOPYDATASTRUCT pcds, BOOL *pbRefresh) @@ -5174,6 +5215,31 @@ LRESULT CTrayNotify::TrayNotify(HWND hwndNotify, HWND hwndFrom, PCOPYDATASTRUCT return _TrayNotifyIcon(pnid, pbRefresh); } +// Public +LRESULT CTrayNotify::TrayNotifyInfo(HWND hwndNotify, HWND hwndFrom, PCOPYDATASTRUCT pcds) +{ + PTRAYNOTIFYINFO pnii; + + if (!hwndNotify || !pcds) + { + return FALSE; + } + + if (pcds->cbData < sizeof(TRAYNOTIFYINFO)) + { + return FALSE; + } + + // We'll add a signature just in case + pnii = (PTRAYNOTIFYINFO)pcds->lpData; + if (pnii->dwSignature != NI_SIGNATURE) + { + return FALSE; + } + + return _TrayNotifyInfo(pnii); +} + // Public HWND CTrayNotify::TrayNotifyCreate(HWND hwndParent, UINT uID, HINSTANCE hInst) { diff --git a/src/Shell/Explorer/TrayNot.h b/src/Shell/Explorer/TrayNot.h index dbf4595..ddaeab9 100644 --- a/src/Shell/Explorer/TrayNot.h +++ b/src/Shell/Explorer/TrayNot.h @@ -158,6 +158,7 @@ class CTrayNotify // *** Other *** HWND TrayNotifyCreate(HWND hwndParent, UINT uID, HINSTANCE hInst); LRESULT TrayNotify(HWND hwndTray, HWND hwndFrom, PCOPYDATASTRUCT pcds, BOOL *pbRefresh); + LRESULT TrayNotifyInfo(HWND hwndTray, HWND hwndFrom, PCOPYDATASTRUCT pcds); protected: static BOOL GetTrayItemCB(INT_PTR nIndex, void *pCallbackData, TRAYCBARG trayCallbackArg, @@ -266,6 +267,7 @@ class CTrayNotify void _OnSysChange(UINT uMsg, WPARAM wParam, LPARAM lParam); void _OnCommand(const HWND hWnd, WPARAM wParam, LPARAM lParam); BOOL _TrayNotifyIcon(PTRAYNOTIFYDATA pnid, BOOL *pbRefresh); + LRESULT _TrayNotifyInfo(PTRAYNOTIFYINFO pnii); // User Event Timer functions HRESULT _SetItemTimer(CTrayItem *pti); diff --git a/src/Shell/Inc/ShUndoc.h b/src/Shell/Inc/ShUndoc.h index 3c8b47c..6dcba23 100644 --- a/src/Shell/Inc/ShUndoc.h +++ b/src/Shell/Inc/ShUndoc.h @@ -230,7 +230,7 @@ typedef struct _TRAYAPPBARDATA { APPBARDATA3264 abd; DWORD dwMessage; - DWORD hSharedABD; + ULONG_PTR hSharedABD; DWORD dwProcId; } TRAYAPPBARDATA, * PTRAYAPPBARDATA; @@ -323,6 +323,20 @@ typedef struct _TRAYNOTIFYDATAW { typedef TRAYNOTIFYDATAW TRAYNOTIFYDATA; typedef PTRAYNOTIFYDATAW PTRAYNOTIFYDATA; +typedef struct _NOTIFYICONINFO32 { + DWORD cbSize; + UINT uFlags; + DWORD dwWnd; + UINT uID; + GUID guidItem; +} NOTIFYICONINFO32, * PNOTIFYICONINFO32; + +typedef struct _TRAYNOTIFYINFO { + DWORD dwSignature; + DWORD dwMessage; + NOTIFYICONINFO32 nii; +} TRAYNOTIFYINFO, * PTRAYNOTIFYINFO; + typedef struct tagSHCNF_INSTRUMENT { USHORT uOffset; USHORT uAlign; @@ -759,7 +773,7 @@ typedef LPNMVIEWFOLDERA LPNMVIEWFOLDER; #define TCDM_APPBAR 0x00000000 #define TCDM_NOTIFY 0x00000001 #define TCDM_LOADINPROC 0x00000002 - +#define TCMD_NOTIFYINFO 0x00000003 #define DCX_USESTYLE 0x00010000L