public CWindowImpl < CTrayWindow, CWindow, CControlWinTraits >,
public ITrayWindow,
public IShellDesktopTray,
- public IOleWindow
+ public IOleWindow,
+ public IContextMenu
{
CStartButton m_StartButton;
CComPtr<IMenuPopup> m_StartMenuPopup;
CComPtr<IDeskBand> m_TaskBand;
+ CComPtr<IContextMenu> m_ContextMenu;
HTHEME m_Theme;
HFONT m_Font;
Horizontal = IsPosHorizontal();
+ IUnknown_Exec(m_TrayBandSite,
+ IID_IDeskBand,
+ DBID_BANDINFOCHANGED,
+ 0,
+ NULL,
+ NULL);
+
/* We're about to resize/move the start button, the rebar control and
the tray notification control */
dwp = BeginDeferWindowPos(3);
if (StartSize.cx > rcClient.right)
StartSize.cx = rcClient.right;
+ if (!m_Theme)
+ {
+ HWND hwndTaskToolbar = ::GetWindow(m_TaskSwitch, GW_CHILD);
+ if (hwndTaskToolbar)
+ {
+ DWORD size = SendMessageW(hwndTaskToolbar, TB_GETBUTTONSIZE, 0, 0);
+ StartSize.cy = HIWORD(size);
+ }
+ }
+
if (m_StartButton.m_hWnd != NULL)
{
/* Resize and reposition the button */
void FitToRebar(PRECT pRect)
{
/* Get the rect of the rebar */
- RECT rebarRect, taskbarRect;
+ RECT rebarRect, taskbarRect, clientRect;
::GetWindowRect(m_Rebar, &rebarRect);
::GetWindowRect(m_hWnd, &taskbarRect);
+ ::GetClientRect(m_hWnd, &clientRect);
OffsetRect(&rebarRect, -taskbarRect.left, -taskbarRect.top);
/* Calculate the difference of size of the taskbar and the rebar */
SIZE margins;
- margins.cx = taskbarRect.right - taskbarRect.left - rebarRect.right + rebarRect.left;
- margins.cy = taskbarRect.bottom - taskbarRect.top - rebarRect.bottom + rebarRect.top;
+ margins.cx = taskbarRect.right - taskbarRect.left - clientRect.right + clientRect.left;
+ margins.cy = taskbarRect.bottom - taskbarRect.top - clientRect.bottom + clientRect.top;
/* Calculate the new size of the rebar and make it resize, then change the new taskbar size */
switch (m_Position)
pRect->top = pRect->bottom - (rebarRect.bottom - rebarRect.top + margins.cy);
break;
case ABE_LEFT:
+ rebarRect.right = rebarRect.left + (pRect->right - pRect->left - margins.cx);
+ ::SendMessageW(m_Rebar, RB_SIZETORECT, RBSTR_CHANGERECT, (LPARAM)&rebarRect);
+ pRect->right = pRect->left + (rebarRect.right - rebarRect.left + margins.cx);
+ break;
case ABE_RIGHT:
- /* FIXME: what to do here? */
+ rebarRect.left = rebarRect.right - (pRect->right - pRect->left - margins.cx);
+ ::SendMessageW(m_Rebar, RB_SIZETORECT, RBSTR_CHANGERECT, (LPARAM)&rebarRect);
+ pRect->left = pRect->right - (rebarRect.right - rebarRect.left + margins.cx);
break;
}
}
+ /*
+ * IContextMenu
+ */
+ HRESULT STDMETHODCALLTYPE QueryContextMenu(HMENU hPopup,
+ UINT indexMenu,
+ UINT idCmdFirst,
+ UINT idCmdLast,
+ UINT uFlags)
+ {
+ if (!m_ContextMenu)
+ {
+ HRESULT hr = TrayWindowCtxMenuCreator(this, m_hWnd, &m_ContextMenu);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+ }
+ return m_ContextMenu->QueryContextMenu(hPopup, indexMenu, idCmdFirst, idCmdLast, uFlags);
+ }
+ HRESULT STDMETHODCALLTYPE InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
+ {
+ if (!m_ContextMenu)
+ return E_INVALIDARG;
+
+ return m_ContextMenu->InvokeCommand(lpici);
+ }
+
+ HRESULT STDMETHODCALLTYPE GetCommandString(UINT_PTR idCmd,
+ UINT uType,
+ UINT *pwReserved,
+ LPSTR pszName,
+ UINT cchMax)
+ {
+ if (!m_ContextMenu)
+ return E_INVALIDARG;
+
+ return m_ContextMenu->GetCommandString(idCmd, uType, pwReserved, pszName, cchMax);
+ }
/**********************************************************
{
HandleTrayContextMenu:
/* Tray the default tray window context menu */
- CComPtr<IContextMenu> ctxMenu;
- TrayWindowCtxMenuCreator(this, m_hWnd, &ctxMenu);
- TrackCtxMenu(ctxMenu, ppt, NULL, FALSE, this);
+ TrackCtxMenu(this, ppt, NULL, FALSE, this);
}
}
return Ret;
/*COM_INTERFACE_ENTRY_IID(IID_ITrayWindow, ITrayWindow)*/
COM_INTERFACE_ENTRY_IID(IID_IShellDesktopTray, IShellDesktopTray)
COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IOleWindow)
+ COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu)
END_COM_MAP()
};
HWND hWndOwner;
CComPtr<CTrayWindow> TrayWnd;
CComPtr<IContextMenu> pcm;
+ UINT m_idCmdCmFirst;
public:
HRESULT Initialize(ITrayWindow * pTrayWnd, IN HWND hWndOwner)
{
this->TrayWnd = (CTrayWindow *) pTrayWnd;
this->hWndOwner = hWndOwner;
+ this->m_idCmdCmFirst = 0;
return S_OK;
}
UINT uFlags)
{
HMENU menubase = LoadPopupMenu(hExplorerInstance, MAKEINTRESOURCEW(IDM_TRAYWND));
-
if (!menubase)
return HRESULT_FROM_WIN32(GetLastError());
- int count = ::GetMenuItemCount(menubase);
-
- for (int i = 0; i < count; i++)
- {
- WCHAR label[128];
-
- MENUITEMINFOW mii = { 0 };
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_STATE | MIIM_ID | MIIM_SUBMENU | MIIM_CHECKMARKS
- | MIIM_DATA | MIIM_STRING | MIIM_BITMAP | MIIM_FTYPE;
- mii.dwTypeData = label;
- mii.cch = _countof(label);
- ::GetMenuItemInfoW(menubase, i, TRUE, &mii);
-
- TRACE("Adding item %d label %S type %d\n", mii.wID, mii.dwTypeData, mii.fType);
-
- ::InsertMenuItemW(hPopup, i + 1, TRUE, &mii);
- }
-
- ::DestroyMenu(menubase);
-
if (SHRestricted(REST_CLASSICSHELL) != 0)
{
DeleteMenu(hPopup,
ID_LOCKTASKBAR,
MF_BYCOMMAND | (TrayWnd->Locked ? MF_CHECKED : MF_UNCHECKED));
+ UINT idCmdNext;
+ idCmdNext = Shell_MergeMenus(hPopup, menubase, indexMenu, idCmdFirst, idCmdLast, MM_SUBMENUSHAVEIDS | MM_ADDSEPARATOR);
+ m_idCmdCmFirst = idCmdNext - idCmdFirst;
+
+ ::DestroyMenu(menubase);
+
if (TrayWnd->m_TrayBandSite != NULL)
{
if (FAILED(TrayWnd->m_TrayBandSite->AddContextMenus(
hPopup,
- 0,
- ID_SHELL_CMD_FIRST,
- ID_SHELL_CMD_LAST,
+ indexMenu,
+ idCmdNext,
+ idCmdLast,
CMF_NORMAL,
&pcm)))
{
UINT uiCmdId = (UINT) lpici->lpVerb;
if (uiCmdId != 0)
{
- if (uiCmdId >= ID_SHELL_CMD_FIRST && uiCmdId <= ID_SHELL_CMD_LAST)
+ if (uiCmdId >= m_idCmdCmFirst)
{
CMINVOKECOMMANDINFO cmici = { 0 };
/* Setup and invoke the shell command */
cmici.cbSize = sizeof(cmici);
cmici.hwnd = hWndOwner;
- cmici.lpVerb = (LPCSTR) MAKEINTRESOURCEW(uiCmdId - ID_SHELL_CMD_FIRST);
+ cmici.lpVerb = (LPCSTR) MAKEINTRESOURCEW(uiCmdId - m_idCmdCmFirst);
cmici.nShow = SW_NORMAL;
pcm->InvokeCommand(&cmici);