23#include <commoncontrols.h>
29#define WM_APP_TRAYDESTROY (WM_APP + 0x100)
31#define TIMER_ID_AUTOHIDE 1
32#define TIMER_ID_MOUSETRACK 2
33#define MOUSETRACK_INTERVAL 100
34#define AUTOHIDE_DELAY_HIDE 2000
35#define AUTOHIDE_DELAY_SHOW 50
36#define AUTOHIDE_INTERVAL_ANIMATING 10
38#define AUTOHIDE_SPEED_SHOW 10
39#define AUTOHIDE_SPEED_HIDE 1
41#define AUTOHIDE_HIDDEN 0
42#define AUTOHIDE_SHOWING 1
43#define AUTOHIDE_SHOWN 2
44#define AUTOHIDE_HIDING 3
47#define IDHK_MINIMIZE_ALL 0x1f5
48#define IDHK_RESTORE_ALL 0x1f6
49#define IDHK_HELP 0x1f7
50#define IDHK_EXPLORE 0x1f8
51#define IDHK_FIND 0x1f9
52#define IDHK_FIND_COMPUTER 0x1fa
53#define IDHK_NEXT_TASK 0x1fb
54#define IDHK_PREV_TASK 0x1fc
55#define IDHK_SYS_PROPERTIES 0x1fd
56#define IDHK_DESKTOP 0x1fe
57#define IDHK_PAGER 0x1ff
151 RECT rcWindow, rcMonitor, rcIntersect;
152 rcMonitor =
info.rcMonitor;
192const GUID IID_IShellDesktopTray = { 0x213e2df9, 0x9a14, 0x4328, { 0x99, 0xb1, 0x69, 0x61, 0xf9, 0x14, 0x3c, 0xe9 } };
243 NONCLIENTMETRICS ncm = {
sizeof(ncm)};
250 ncm.lfCaptionFont.lfWeight =
FW_BOLD;
278 WCHAR szStartCaption[32];
284 wcscpy(szStartCaption,
L"Start");
325 public CWindowImpl < CTrayWindow, CWindow, CControlWinTraits >,
327 public IShellDesktopTray,
445 WCHAR szCommand[256];
446 WCHAR *pszParameters;
456 pszParameters =
wcschr(szCommand,
L'>');
518 CStringW strDefaultDir, strHomePath;
521 strDefaultDir += strHomePath;
534 return This->RunFileDlgThread();
543 if (hRunDlg !=
NULL &&
587 return This->TrayPropertiesThread();
597 if (hTrayProp !=
NULL &&
730 TRACE(
"ITrayWindow::ExecContextMenuCmd(%u): Unhandled Command ID!\n", uiCmd);
888 if (hwndExclude !=
NULL)
935 fuFlags |= (TrackUp ? TPM_VERNEGANIMATION : TPM_VERPOSANIMATION);
975 TRACE(
"Before Query\n");
976 hr = contextMenu->QueryContextMenu(popup, 0, 0,
UINT_MAX, CMF_NORMAL);
979 TRACE(
"Query failed\n");
984 TRACE(
"Before Tracking\n");
1002 TRACE(
"Before InvokeCommand\n");
1004 cmi.
cbSize =
sizeof(cmi);
1007 hr = contextMenu->InvokeCommand(&cmi);
1011 TRACE(
"TrackPopupMenu failed. Code=%d, LastError=%d\n", uCommand,
GetLastError());
1035 NONCLIENTMETRICS ncm = {
sizeof(ncm)};
1038 ERR(
"SPI_GETNONCLIENTMETRICS failed\n");
1049 ERR(
"CreateFontIndirect failed\n");
1100 pt.x = pRect->left + ((pRect->right - pRect->left) / 2);
1101 pt.y = pRect->top + ((pRect->bottom - pRect->top) / 2);
1116 if (hMonitor !=
NULL)
1130 goto GetPrimaryRect;
1178 IN const SIZE *pTraySize,
1184 pRect->right = pRect->left + pTraySize->cx;
1188 pRect->bottom = pRect->top + pTraySize->cy;
1192 pRect->left = pRect->right - pTraySize->cx;
1197 pRect->top = pRect->bottom - pTraySize->cy;
1207 if (pTraySize ==
NULL)
1239 szWnd.
cx = pRect->right - pRect->left;
1240 szWnd.
cy = pRect->bottom - pRect->top;
1245 MONITOR_DEFAULTTONEAREST);
1251 if (szWnd.
cx > szMax.
cx)
1252 szWnd.
cx = szMax.
cx;
1253 if (szWnd.
cy > szMax.
cy)
1254 szWnd.
cy = szMax.
cy;
1268 GetMinimumWindowSize(
1292 SIZE DeltaPt, ScreenOffset;
1308 goto GetPrimaryScreenRect;
1323GetPrimaryScreenRect:
1324 ScreenOffset.
cx = 0;
1325 ScreenOffset.
cy = 0;
1331 if (
pt.x < rcScreen.
right / 2)
1363 if (hMon != hMonNew)
1396 pt.x = pRect->left + ((pRect->right - pRect->left) / 2);
1397 pt.y = pRect->top + ((pRect->bottom - pRect->top) / 2);
1411 rcTray.
left = pwp->x;
1412 rcTray.
top = pwp->y;
1446 rcTray.
left = pwp->x;
1447 rcTray.
top = pwp->y;
1492 pwp->x = rcTray.
left;
1493 pwp->y = rcTray.
top;
1501 RECT rcClip, rcWindow;
1539 RECT rcTray, rcWorkArea;
1614 SIZE WndSize, EdgeSize, DlgFrameSize;
1654 WndSize.
cx = 2 * (EdgeSize.
cx + DlgFrameSize.
cx);
1655 WndSize.
cy = StartBtnSize.
cy + (2 * (EdgeSize.
cy + DlgFrameSize.
cy));
1659 WndSize.
cx = StartBtnSize.
cx;
1660 WndSize.
cy = StartBtnSize.
cy - EdgeSize.
cy;
1691 SIZE TraySize, StartSize;
1692 POINT ptTrayNotify = { 0, 0 };
1697 if (prcClient !=
NULL)
1699 rcClient = *prcClient;
1723 if (StartSize.
cx > rcClient.
right)
1724 StartSize.
cx = rcClient.
right;
1727 if (hwndTaskToolbar)
1747 ERR(
"DeferWindowPos for start button failed. lastErr=%d\n",
GetLastError());
1772 ptTrayNotify.
x = rcClient.
right - TraySize.
cx;
1774 ptTrayNotify.
y = rcClient.
bottom - TraySize.
cy;
1786 ERR(
"DeferWindowPos for notification area failed. lastErr=%d\n",
GetLastError());
1794 POINT ptRebar = { 0, 0 };
1802 szRebar.
cx = ptTrayNotify.
x - ptRebar.
x;
1809 szRebar.
cy = ptTrayNotify.
y - ptRebar.
y;
1835 RECT rebarRect, taskbarRect, clientRect;
1852 pRect->
bottom = pRect->
top + rebarRect.bottom - rebarRect.top +
margins.cy;
1855 rebarRect.top = rebarRect.bottom - (pRect->
bottom - pRect->
top -
margins.cy);
1857 pRect->
top = pRect->
bottom - (rebarRect.bottom - rebarRect.top +
margins.cy);
1860 rebarRect.right = rebarRect.left + (pRect->
right - pRect->
left -
margins.cx);
1862 pRect->
right = pRect->
left + (rebarRect.right - rebarRect.left +
margins.cx);
1865 rebarRect.left = rebarRect.right - (pRect->
right - pRect->
left -
margins.cx);
1867 pRect->
left = pRect->
right - (rebarRect.right - rebarRect.left +
margins.cx);
1888 pt.y = rcExclude.
top;
1898 pt.y = rcExclude.
top;
1903 pt.y = rcExclude.
top;
1935 TRACE(
"AutoHide cancelling hide.\n");
1941 TRACE(
"AutoHide starting show.\n");
1950 TRACE(
"AutoHide cancelling show.\n");
1956 TRACE(
"AutoHide starting hide.\n");
2239 RECT rcGripper = {0};
2330 ((ITrayWindow*)
this)->
AddRef();
2410#define TIMER_ID_IGNOREPULSERESET 888
2411#define TIMER_IGNOREPULSERESET_TIMEOUT 200
2448 if (
wParam == SPI_SETNONCLIENTMETRICS)
2467 FIXME(
"Use UpdateStartMenu\n");
2504 switch (pCopyData->
dwData)
2592 if (
pt.x < rcClient.
left)
2597 if (
pt.y < rcClient.
top)
2665 rcClient.
left = rcClient.
top = 0;
2709 static const UINT uidDisableItem [] = {
2723 if (hSysMenu !=
NULL)
2764 if (!ppt || !prcStartBtn || !pwi)
2772 if (ppt->
x > prcStartBtn->
right || ppt->
y > prcStartBtn->
bottom)
2778 if (ppt->
x < prcStartBtn->
left || ppt->
y > prcStartBtn->
bottom)
2782 ppt->
x > prcStartBtn->
right)
2790 if (ppt->
x > prcStartBtn->
right || ppt->
y < prcStartBtn->
top)
2807 if (!ppt || !prcShowDesktopBtn)
2814 return !(ppt->
x > prcShowDesktopBtn->
right || ppt->
y < prcShowDesktopBtn->
top);
2816 return !(ppt->
x < prcShowDesktopBtn->
left || ppt->
y > prcShowDesktopBtn->
bottom);
2818 return !(ppt->
x < prcShowDesktopBtn->
left || ppt->
y < prcShowDesktopBtn->
top);
2820 return !(ppt->
x < prcShowDesktopBtn->
left || ppt->
y < prcShowDesktopBtn->
top);
2876 if (
pt.x != -1 ||
pt.y != -1)
2898 POINT ptClient = *ppt;
2904 if (hWndAtPt !=
NULL &&
2913 goto HandleTrayContextMenu;
2919 goto HandleTrayContextMenu;
2923HandleTrayContextMenu:
3060 ::SetForegroundWindow(hwndActive);
3093 return wcscmp(szClass,
L"#32770") == 0;
3102 if (!
info->bShowDesktop)
3117 info->pMinimizedAll->Add(mwp);
3134 info.bShowDesktop = bShowDesktop;
3238 rc = &prms->
rgrc[0];
3304 szWindow.
cx - szTarget.
cx,
3305 szWindow.
cy - szTarget.
cx,
3311 szWindow.
cx = szActual.
cx + borders.
cx;
3314 szWindow.
cy = szActual.
cy + borders.
cy;
3317 szWindow.
cx = szActual.
cx + borders.
cx;
3321 szWindow.
cy = szActual.
cy + borders.
cy;
3471 if (!Ret || Ret == -1)
3496 TRACE(
"IShellDesktopTray::GetState() unimplemented!\n");
3502 TRACE(
"IShellDesktopTray::GetTrayWindow(0x%p)\n", phWndTray);
3509 TRACE(
"IShellDesktopTray::RegisterDesktopWindow(0x%p)\n", hWndDesktop);
3517 TRACE(
"IShellDesktopTray::Unknown(%u,%u) unimplemented!\n", dwUnknown1, dwUnknown2);
3570 this->hWndOwner = hWndOwner;
3571 this->m_idCmdCmFirst = 0;
3612 m_idCmdCmFirst = idCmdNext - idCmdFirst;
3616 if (TrayWnd->m_TrayBandSite !=
NULL)
3619 if (
FAILED(TrayWnd->m_TrayBandSite->AddContextMenus(
3627 WARN(
"AddContextMenus failed.\n");
3641 if (uiCmdId >= m_idCmdCmFirst)
3648 cmici.
cbSize =
sizeof(cmici);
3649 cmici.
hwnd = hWndOwner;
3653 pcm->InvokeCommand(&cmici);
3658 TrayWnd->ExecContextMenuCmd(uiCmdId);
3705 *ppTray = (ITrayWindow *) Tray;
HINSTANCE hExplorerInstance
VOID DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar)
#define TWM_OPENSTARTMENU
HRESULT UpdateStartMenu(IN OUT IMenuPopup *pMenuPopup, IN HBITMAP hbmBanner OPTIONAL, IN BOOL bSmallIcons, IN BOOL bRefresh)
#define TSWM_UPDATETASKBARPOS
#define TNWM_GETMINIMUMSIZE
HRESULT CStartMenuBtnCtxMenu_CreateInstance(ITrayWindow *TrayWnd, IN HWND hWndOwner, IContextMenu **ppCtxMenu)
HMENU LoadPopupMenu(IN HINSTANCE hInstance, IN LPCWSTR lpMenuName)
#define TWM_GETTASKSWITCH
IMenuPopup * CreateStartMenu(IN ITrayWindow *Tray, OUT IMenuBand **ppMenuBand, IN HBITMAP hbmBanner OPTIONAL, IN BOOL bSmallIcons)
TaskbarSettings g_TaskbarSettings
HRESULT CTrayNotifyWnd_CreateInstance(HWND hwndParent, REFIID riid, void **ppv)
HRESULT CTrayBandSite_CreateInstance(IN ITrayWindow *tray, IN IDeskBand *pTaskBand, OUT ITrayBandSite **pBandSite)
#define TWM_SETTINGSCHANGED
#define TNWM_GETSHOWDESKTOPBUTTON
HRESULT InitShellServices(HDPA *phdpa)
HRESULT CTaskBand_CreateInstance(IN ITrayWindow *Tray, HWND hWndStartButton, REFIID riid, void **ppv)
HRESULT ShutdownShellServices(HDPA hdpa)
#define ID_SHELL_CMD_OPEN_TASKMGR
#define ID_SHELL_CMD_CUST_NOTIF
#define ID_SHELL_CMD_UNDO_ACTION
#define ID_SHELL_CMD_PROPERTIES
#define ID_SHELL_CMD_TILE_WND_H
#define IDS_TRAYWND_UNDO_TILE
#define ID_SHELL_CMD_CASCADE_WND
#define ID_SHELL_CMD_RESTORE_ALL
#define ID_SHELL_CMD_TILE_WND_V
#define ID_SHELL_CMD_SHOW_DESKTOP
#define IDS_TRAYWND_UNDO_CASCADE
#define ID_SHELL_CMD_EXPLORE_ALL_USERS
#define ID_SHELL_CMD_ADJUST_DAT
#define ID_SHELL_CMD_OPEN_ALL_USERS
#define STDMETHODCALLTYPE
BOOL GetEnvironmentVariable(_In_z_ PCXSTR pszVar)
HWND GetLastActivePopup() const
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
HDWP DeferWindowPos(HDWP hWinPosInfo, HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT uFlags)
BOOL GetWindowRect(LPRECT lpRect) const
CWindow GetParent() const
BOOL IsWindowVisible() const
BOOL IsWindowEnabled() const
BOOL PostMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
LRESULT OnHotkey(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnEnterSizeMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
VOID OpenTaskManager(IN HWND hWndOwner)
LRESULT OnSettingChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnSysColorChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnExitSizeMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnThemeChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnTaskbarSettingsChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
DWORD GetDraggingRectFromPt(IN POINT pt, OUT RECT *pRect, OUT HMONITOR *phMonitor)
LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
CStartButton m_StartButton
LRESULT OnDoExitWindows(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
HWND STDMETHODCALLTYPE GetHWND()
void FitToRebar(PRECT pRect)
LRESULT HandleCommand(UINT uCommand)
LRESULT OnCtlColorBtn(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
CComPtr< ITrayBandSite > m_TrayBandSite
int DrawSizerWithTheme(IN HRGN hRgn)
HMONITOR GetScreenRectFromRect(IN OUT RECT *pRect, IN DWORD dwFlags)
BOOL STDMETHODCALLTYPE IsHorizontal()
TRACKMOUSEEVENT m_MouseTrackingInfo
CComPtr< IDeskBand > m_TaskBand
HMONITOR m_PreviousMonitor
LRESULT OnInitMenuPopup(INT code, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
DWORD WINAPI TrayPropertiesThread()
LRESULT OnNcCalcSize(INT code, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
void RestoreMinimizedNonTaskWnds(BOOL bDestroyed, HWND hwndActive)
virtual HRESULT STDMETHODCALLTYPE RegisterDesktopWindow(IN HWND hWndDesktop)
HMONITOR GetScreenRect(IN HMONITOR hMonitor, IN OUT RECT *pRect)
LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
static DWORD WINAPI s_RunFileDlgThread(IN OUT PVOID pParam)
LRESULT OnNcRButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
VOID TrayProcessMessages()
HMONITOR m_DraggingMonitor
HRESULT STDMETHODCALLTYPE GetCommandString(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax)
LRESULT OnEndSession(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
virtual HRESULT STDMETHODCALLTYPE Unknown(IN DWORD dwUnknown1, IN DWORD dwUnknown2)
BOOL STDMETHODCALLTYPE IsTaskWnd(HWND hWnd)
BOOL IsPointWithinShowDesktopButton(LPPOINT ppt, LPRECT prcShowDesktopBtn, PWINDOWINFO pwi)
LRESULT EraseBackgroundWithTheme(HDC hdc)
CComPtr< IMenuPopup > m_StartMenuPopup
HWND STDMETHODCALLTYPE DisplayProperties()
VOID AdjustSizerRect(RECT *rc, DWORD pos)
HMONITOR CalculateValidSize(IN DWORD Position, IN OUT RECT *pRect)
void ProcessMouseTracking()
LRESULT OnNcLButtonDblClick(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnNcLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
BOOL STDMETHODCALLTYPE Lock(IN BOOL bLock)
VOID ApplyClipping(IN BOOL Clip)
LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
static BOOL CALLBACK MinimizeWindowsProc(HWND hwnd, LPARAM lParam)
HRESULT STDMETHODCALLTYPE Open()
LRESULT OnGetTaskSwitch(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
HRESULT WINAPI ContextSensitiveHelp(BOOL fEnterMode)
LRESULT OnSysChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
HRESULT ExecResourceCmd(int id)
static DWORD WINAPI s_TrayPropertiesThread(IN OUT PVOID pParam)
VOID OpenCommonStartMenuDirectory(IN HWND hWndOwner, IN LPCTSTR lpOperation)
static BOOL IsDialog(HWND hwnd)
HRESULT STDMETHODCALLTYPE Close()
VOID CheckTrayWndPosition()
LRESULT OnNcLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
CComPtr< IUnknown > m_TrayNotifyInstance
LRESULT OnMoving(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT HandleHotKey(DWORD id)
LRESULT OnSizing(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
CTrayShowDesktopButton * m_pShowDesktopButton
VOID AlignControls(IN PRECT prcClient OPTIONAL)