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
136 RECT rcWindow, rcMonitor, rcIntersect;
137 rcMonitor =
info.rcMonitor;
164 WCHAR szClass[64], szText[64];
184const GUID IID_IShellDesktopTray = { 0x213e2df9, 0x9a14, 0x4328, { 0x99, 0xb1, 0x69, 0x61, 0xf9, 0x14, 0x3c, 0xe9 } };
235 NONCLIENTMETRICS ncm = {
sizeof(ncm)};
242 ncm.lfCaptionFont.lfWeight =
FW_BOLD;
270 WCHAR szStartCaption[32];
276 wcscpy(szStartCaption,
L"Start");
319 public CWindowImpl<CTrayShowDesktopButton, CWindow, CControlWinTraits>
334#define SHOW_DESKTOP_MINIMUM_WIDTH 3
356 if (nTime1 - nTime0 >= 600)
364#define TSDB_CLICK (WM_USER + 100)
413 return ::PtInRect(&rc,
pt);
416#define SHOW_DESKTOP_TIMER_ID 999
417#define SHOW_DESKTOP_TIMER_INTERVAL 200
513 public CWindowImpl < CTrayWindow, CWindow, CControlWinTraits >,
515 public IShellDesktopTray,
633 WCHAR szCommand[256];
634 WCHAR *pszParameters;
644 pszParameters =
wcschr(szCommand,
L'>');
696 CStringW strDefaultDir, strHomePath;
699 strDefaultDir += strHomePath;
712 return This->RunFileDlgThread();
721 if (hRunDlg !=
NULL &&
765 return This->TrayPropertiesThread();
775 if (hTrayProp !=
NULL &&
911 TRACE(
"ITrayWindow::ExecContextMenuCmd(%u): Unhandled Command ID!\n", uiCmd);
1067 if (hwndExclude !=
NULL)
1107 tmp.
cbSize =
sizeof(tmp);
1114 fuFlags |= (TrackUp ? TPM_VERNEGANIMATION : TPM_VERPOSANIMATION);
1154 TRACE(
"Before Query\n");
1155 hr = contextMenu->QueryContextMenu(popup, 0, 0,
UINT_MAX, CMF_NORMAL);
1158 TRACE(
"Query failed\n");
1163 TRACE(
"Before Tracking\n");
1181 TRACE(
"Before InvokeCommand\n");
1183 cmi.
cbSize =
sizeof(cmi);
1186 hr = contextMenu->InvokeCommand(&cmi);
1190 TRACE(
"TrackPopupMenu failed. Code=%d, LastError=%d\n", uCommand,
GetLastError());
1214 NONCLIENTMETRICS ncm = {
sizeof(ncm)};
1217 ERR(
"SPI_GETNONCLIENTMETRICS failed\n");
1228 ERR(
"CreateFontIndirect failed\n");
1279 pt.x = pRect->left + ((pRect->right - pRect->left) / 2);
1280 pt.y = pRect->top + ((pRect->bottom - pRect->top) / 2);
1295 if (hMonitor !=
NULL)
1309 goto GetPrimaryRect;
1357 IN const SIZE *pTraySize,
1363 pRect->right = pRect->left + pTraySize->cx;
1367 pRect->bottom = pRect->top + pTraySize->cy;
1371 pRect->left = pRect->right - pTraySize->cx;
1376 pRect->top = pRect->bottom - pTraySize->cy;
1386 if (pTraySize ==
NULL)
1418 szWnd.
cx = pRect->right - pRect->left;
1419 szWnd.
cy = pRect->bottom - pRect->top;
1424 MONITOR_DEFAULTTONEAREST);
1430 if (szWnd.
cx > szMax.
cx)
1431 szWnd.
cx = szMax.
cx;
1432 if (szWnd.
cy > szMax.
cy)
1433 szWnd.
cy = szMax.
cy;
1447 GetMinimumWindowSize(
1471 SIZE DeltaPt, ScreenOffset;
1487 goto GetPrimaryScreenRect;
1502GetPrimaryScreenRect:
1503 ScreenOffset.
cx = 0;
1504 ScreenOffset.
cy = 0;
1510 if (
pt.x < rcScreen.
right / 2)
1542 if (hMon != hMonNew)
1575 pt.x = pRect->left + ((pRect->right - pRect->left) / 2);
1576 pt.y = pRect->top + ((pRect->bottom - pRect->top) / 2);
1590 rcTray.
left = pwp->x;
1591 rcTray.
top = pwp->y;
1623 rcTray.
left = pwp->x;
1624 rcTray.
top = pwp->y;
1669 pwp->x = rcTray.
left;
1670 pwp->y = rcTray.
top;
1678 RECT rcClip, rcWindow;
1716 RECT rcTray, rcWorkArea;
1790 SIZE WndSize, EdgeSize, DlgFrameSize;
1830 WndSize.
cx = 2 * (EdgeSize.
cx + DlgFrameSize.
cx);
1831 WndSize.
cy = StartBtnSize.
cy + (2 * (EdgeSize.
cy + DlgFrameSize.
cy));
1835 WndSize.
cx = StartBtnSize.
cx;
1836 WndSize.
cy = StartBtnSize.
cy - EdgeSize.
cy;
1867 SIZE TraySize, StartSize;
1868 POINT ptTrayNotify = { 0, 0 };
1873 if (prcClient !=
NULL)
1875 rcClient = *prcClient;
1899 if (StartSize.
cx > rcClient.
right)
1900 StartSize.
cx = rcClient.
right;
1903 if (hwndTaskToolbar)
1923 ERR(
"DeferWindowPos for start button failed. lastErr=%d\n",
GetLastError());
1977 ptTrayNotify.
x = rcClient.
right - TraySize.
cx;
1979 ptTrayNotify.
y = rcClient.
bottom - TraySize.
cy;
1991 ERR(
"DeferWindowPos for notification area failed. lastErr=%d\n",
GetLastError());
1999 POINT ptRebar = { 0, 0 };
2007 szRebar.
cx = ptTrayNotify.
x - ptRebar.
x;
2014 szRebar.
cy = ptTrayNotify.
y - ptRebar.
y;
2040 RECT rebarRect, taskbarRect, clientRect;
2057 pRect->
bottom = pRect->
top + rebarRect.bottom - rebarRect.top +
margins.cy;
2060 rebarRect.top = rebarRect.bottom - (pRect->
bottom - pRect->
top -
margins.cy);
2062 pRect->
top = pRect->
bottom - (rebarRect.bottom - rebarRect.top +
margins.cy);
2065 rebarRect.right = rebarRect.left + (pRect->
right - pRect->
left -
margins.cx);
2067 pRect->
right = pRect->
left + (rebarRect.right - rebarRect.left +
margins.cx);
2070 rebarRect.left = rebarRect.right - (pRect->
right - pRect->
left -
margins.cx);
2072 pRect->
left = pRect->
right - (rebarRect.right - rebarRect.left +
margins.cx);
2093 pt.y = rcExclude.
top;
2103 pt.y = rcExclude.
top;
2108 pt.y = rcExclude.
top;
2140 TRACE(
"AutoHide cancelling hide.\n");
2146 TRACE(
"AutoHide starting show.\n");
2155 TRACE(
"AutoHide cancelling show.\n");
2161 TRACE(
"AutoHide starting hide.\n");
2444 RECT rcGripper = {0};
2530 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
2544 ((ITrayWindow*)
this)->
AddRef();
2623#define TIMER_ID_IGNOREPULSERESET 888
2624#define TIMER_IGNOREPULSERESET_TIMEOUT 200
2654 if (
wParam == SPI_SETNONCLIENTMETRICS)
2693 switch (pCopyData->
dwData)
2710 RECT rcButton, rcWnd;
2781 if (
pt.x < rcClient.
left)
2786 if (
pt.y < rcClient.
top)
2854 rcClient.
left = rcClient.
top = 0;
2898 static const UINT uidDisableItem [] = {
2912 if (hSysMenu !=
NULL)
3030 if (
pt.x != -1 ||
pt.y != -1)
3052 POINT ptClient = *ppt;
3058 if (hWndAtPt !=
NULL &&
3067 goto HandleTrayContextMenu;
3073 goto HandleTrayContextMenu;
3077HandleTrayContextMenu:
3247 return wcscmp(szClass,
L"#32770") == 0;
3256 if (!
info->bShowDesktop)
3272 info->pMinimizedAll->Add(mwp);
3290 info.bShowDesktop = bShowDesktop;
3399 rc = &prms->
rgrc[0];
3465 szWindow.
cx - szTarget.
cx,
3466 szWindow.
cy - szTarget.
cx,
3472 szWindow.
cx = szActual.
cx + borders.
cx;
3475 szWindow.
cy = szActual.
cy + borders.
cy;
3478 szWindow.
cx = szActual.
cx + borders.
cx;
3482 szWindow.
cy = szActual.
cy + borders.
cy;
3626 if (!Ret || Ret == -1)
3651 TRACE(
"IShellDesktopTray::GetState() unimplemented!\n");
3657 TRACE(
"IShellDesktopTray::GetTrayWindow(0x%p)\n", phWndTray);
3664 TRACE(
"IShellDesktopTray::RegisterDesktopWindow(0x%p)\n", hWndDesktop);
3672 TRACE(
"IShellDesktopTray::Unknown(%u,%u) unimplemented!\n", dwUnknown1, dwUnknown2);
3725 this->hWndOwner = hWndOwner;
3726 this->m_idCmdCmFirst = 0;
3768 m_idCmdCmFirst = idCmdNext - idCmdFirst;
3772 if (TrayWnd->m_TrayBandSite !=
NULL)
3775 if (
FAILED(TrayWnd->m_TrayBandSite->AddContextMenus(
3783 WARN(
"AddContextMenus failed.\n");
3797 if (uiCmdId >= m_idCmdCmFirst)
3804 cmici.
cbSize =
sizeof(cmici);
3805 cmici.
hwnd = hWndOwner;
3809 pcm->InvokeCommand(&cmici);
3814 TrayWnd->ExecContextMenuCmd(uiCmdId);
3861 *ppTray = (ITrayWindow *) Tray;
HINSTANCE hExplorerInstance
VOID DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar)
#define TWM_OPENSTARTMENU
#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
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)