Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/Shell/Explorer/Tray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
66 changes: 66 additions & 0 deletions src/Shell/Explorer/TrayNot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Shell/Explorer/TrayNot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 16 additions & 2 deletions src/Shell/Inc/ShUndoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ typedef struct _TRAYAPPBARDATA
{
APPBARDATA3264 abd;
DWORD dwMessage;
DWORD hSharedABD;
ULONG_PTR hSharedABD;
DWORD dwProcId;
} TRAYAPPBARDATA, * PTRAYAPPBARDATA;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down