[BROWSEUI]

* Load and use rshell for the menubar.
* Properly forward WM_NOTIFY and WM_COMMAND messages to the toolbars.

[RSHELL]
* Improve behaviour of horizontal menubands.
* Clicking on submenu items does not work yet.

CORE-7586

svn path=/branches/shell-experiments/; revision=62448
This commit is contained in:
David Quintana 2014-03-07 22:28:55 +00:00
parent a8919a7a3b
commit 2ca6b95aeb
11 changed files with 288 additions and 77 deletions

View file

@ -49,3 +49,9 @@ add_custom_command(TARGET rshell POST_BUILD
"$<TARGET_FILE:rshell>" "$<TARGET_FILE:rshell>"
"$<TARGET_FILE_DIR:explorer_new>/$<TARGET_FILE_NAME:rshell>" "$<TARGET_FILE_DIR:explorer_new>/$<TARGET_FILE_NAME:rshell>"
COMMENT "Copying to output directory") COMMENT "Copying to output directory")
add_custom_command(TARGET rshell POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:rshell>"
"$<TARGET_FILE_DIR:filebrowser>/$<TARGET_FILE_NAME:rshell>"
COMMENT "Copying to output directory")

View file

@ -52,7 +52,10 @@ CMenuBand::CMenuBand() :
m_site(NULL), m_site(NULL),
m_psmc(NULL), m_psmc(NULL),
m_subMenuChild(NULL), m_subMenuChild(NULL),
m_hmenu(NULL),
m_menuOwner(NULL),
m_useBigIcons(FALSE), m_useBigIcons(FALSE),
m_topLevelWindow(NULL),
m_hotBar(NULL), m_hotBar(NULL),
m_hotItem(-1) m_hotItem(-1)
{ {
@ -123,7 +126,7 @@ HRESULT STDMETHODCALLTYPE CMenuBand::SetMenu(
m_staticToolbar = new CMenuStaticToolbar(this); m_staticToolbar = new CMenuStaticToolbar(this);
} }
m_hmenu = hmenu; m_hmenu = hmenu;
m_menuOwner; m_menuOwner = hwnd;
HRESULT hr = m_staticToolbar->SetMenu(hmenu, hwnd, dwFlags); HRESULT hr = m_staticToolbar->SetMenu(hmenu, hwnd, dwFlags);
if (FAILED_UNEXPECTEDLY(hr)) if (FAILED_UNEXPECTEDLY(hr))
@ -203,7 +206,7 @@ HRESULT STDMETHODCALLTYPE CMenuBand::SetSite(IUnknown *pUnkSite)
} }
hr = IUnknown_QueryService(m_site, SID_SMenuPopup, IID_PPV_ARG(IMenuPopup, &m_subMenuParent)); hr = IUnknown_QueryService(m_site, SID_SMenuPopup, IID_PPV_ARG(IMenuPopup, &m_subMenuParent));
if (FAILED_UNEXPECTEDLY(hr)) if (FAILED(hr) && hr != E_NOINTERFACE)
return hr; return hr;
CComPtr<IOleWindow> pTopLevelWindow; CComPtr<IOleWindow> pTopLevelWindow;
@ -326,10 +329,13 @@ HRESULT STDMETHODCALLTYPE CMenuBand::ShowDW(BOOL fShow)
return hr; return hr;
} }
if (fShow) if (m_dwFlags & SMINIT_VERTICAL)
hr = m_focusManager->PushMenu(this); {
else if (fShow)
hr = m_focusManager->PopMenu(this); hr = m_focusManager->PushMenu(this);
else
hr = m_focusManager->PopMenu(this);
}
return S_OK; return S_OK;
} }
@ -401,6 +407,8 @@ HRESULT STDMETHODCALLTYPE CMenuBand::Exec(const GUID *pguidCmdGroup, DWORD nCmdI
{ {
return S_FALSE; return S_FALSE;
} }
return S_FALSE;
} }
UNIMPLEMENTED; UNIMPLEMENTED;
@ -610,9 +618,24 @@ HRESULT CMenuBand::_CallCB(UINT uMsg, WPARAM wParam, LPARAM lParam, UINT id, LPI
return hr; return hr;
} }
HRESULT CMenuBand::_TrackSubMenuUsingTrackPopupMenu(HMENU popup, INT x, INT y) HRESULT CMenuBand::_TrackSubMenuUsingTrackPopupMenu(HMENU popup, INT x, INT y, RECT& rcExclude)
{ {
::TrackPopupMenu(popup, 0, x, y, 0, m_menuOwner, NULL); HWND sendTo = m_menuOwner;
// FIXME: use?
//TPMPARAMS params = { sizeof(TPMPARAMS), rcExclude };
if (sendTo)
{
::TrackPopupMenuEx(popup, 0, x, y, sendTo, NULL); // &params);
}
else
{
GetWindow(&sendTo);
::TrackPopupMenuEx(popup, TPM_RETURNCMD, x, y, sendTo, NULL); // &params);
// TODO: use the result somehow
}
return S_OK; return S_OK;
} }

View file

@ -171,7 +171,7 @@ public:
HRESULT _CallCBWithItemId(UINT Id, UINT uMsg, WPARAM wParam, LPARAM lParam); HRESULT _CallCBWithItemId(UINT Id, UINT uMsg, WPARAM wParam, LPARAM lParam);
HRESULT _CallCBWithItemPidl(LPITEMIDLIST pidl, UINT uMsg, WPARAM wParam, LPARAM lParam); HRESULT _CallCBWithItemPidl(LPITEMIDLIST pidl, UINT uMsg, WPARAM wParam, LPARAM lParam);
HRESULT _TrackSubMenuUsingTrackPopupMenu(HMENU popup, INT x, INT y); HRESULT _TrackSubMenuUsingTrackPopupMenu(HMENU popup, INT x, INT y, RECT& rcExclude);
HRESULT _GetTopLevelWindow(HWND*topLevel); HRESULT _GetTopLevelWindow(HWND*topLevel);
HRESULT _OnHotItemChanged(CMenuToolbarBase * tb, INT id); HRESULT _OnHotItemChanged(CMenuToolbarBase * tb, INT id);
HRESULT _MenuItemHotTrack(DWORD changeType); HRESULT _MenuItemHotTrack(DWORD changeType);

View file

@ -417,7 +417,7 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::SetSubMenu(IMenuPopup *pmp, BOOL fSet)
{ {
if (m_SubMenuChild) if (m_SubMenuChild)
{ {
if (SHIsSameObject(pmp, m_SubMenuChild)) if (pmp == m_SubMenuChild)
{ {
m_SubMenuChild = NULL; m_SubMenuChild = NULL;
} }

View file

@ -67,6 +67,10 @@ HRESULT CMenuToolbarBase::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
hdr = reinterpret_cast<LPNMHDR>(lParam); hdr = reinterpret_cast<LPNMHDR>(lParam);
switch (hdr->code) switch (hdr->code)
{ {
case TTN_GETDISPINFOA:
case TTN_GETDISPINFOW:
return S_OK;
case PGN_CALCSIZE: case PGN_CALCSIZE:
csize = reinterpret_cast<LPNMPGCALCSIZE>(hdr); csize = reinterpret_cast<LPNMPGCALCSIZE>(hdr);
@ -99,7 +103,8 @@ HRESULT CMenuToolbarBase::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
switch (cdraw->nmcd.dwDrawStage) switch (cdraw->nmcd.dwDrawStage)
{ {
case CDDS_PREPAINT: case CDDS_PREPAINT:
*theResult = CDRF_NOTIFYITEMDRAW; if (m_toolbarFlags & SMINIT_VERTICAL)
*theResult = CDRF_NOTIFYITEMDRAW;
return S_OK; return S_OK;
case CDDS_ITEMPREPAINT: case CDDS_ITEMPREPAINT:
@ -160,6 +165,10 @@ HRESULT CMenuToolbarBase::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
return S_OK; return S_OK;
} }
return S_OK; return S_OK;
case RBN_CHILDSIZE:
return S_OK;
default:
DbgPrint("WM_NOTIFY unknown code %d, %d\n", hdr->code, hdr->idFrom);
} }
return S_OK; return S_OK;
} }
@ -214,6 +223,13 @@ HRESULT CMenuToolbarBase::ShowWindow(BOOL fShow)
HRESULT CMenuToolbarBase::UpdateImageLists() HRESULT CMenuToolbarBase::UpdateImageLists()
{ {
if ((m_toolbarFlags & (SMINIT_TOPLEVEL| SMINIT_VERTICAL)) == SMINIT_TOPLEVEL) // not vertical.
{
/* Hide the placeholders for the button images */
SendMessageW(m_hwnd, TB_SETIMAGELIST, 0, 0);
return S_OK;
}
int shiml; int shiml;
if (m_menuBand->UseBigIcons()) if (m_menuBand->UseBigIcons())
{ {
@ -266,6 +282,8 @@ HRESULT CMenuToolbarBase::CreateToolbar(HWND hwndParent, DWORD dwFlags)
#endif #endif
} }
m_toolbarFlags = dwFlags;
RECT rc; RECT rc;
if (!::GetClientRect(hwndParent, &rc) || (rc.left == rc.right) || (rc.top == rc.bottom)) if (!::GetClientRect(hwndParent, &rc) || (rc.left == rc.right) || (rc.top == rc.bottom))
@ -311,13 +329,6 @@ HRESULT CMenuToolbarBase::CreateToolbar(HWND hwndParent, DWORD dwFlags)
/* Identify the version of the used Common Controls DLL by sending the size of the TBBUTTON structure */ /* Identify the version of the used Common Controls DLL by sending the size of the TBBUTTON structure */
SendMessageW(hwndToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); SendMessageW(hwndToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
//if (dwFlags & SMINIT_TOPLEVEL)
//{
// /* Hide the placeholders for the button images */
// SendMessageW(m_hwnd, TB_SETIMAGELIST, 0, 0);
//}
//else
SetWindowLongPtr(hwndToolbar, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this)); SetWindowLongPtr(hwndToolbar, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
m_SubclassOld = (WNDPROC) SetWindowLongPtr(hwndToolbar, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(CMenuToolbarBase::s_SubclassProc)); m_SubclassOld = (WNDPROC) SetWindowLongPtr(hwndToolbar, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(CMenuToolbarBase::s_SubclassProc));
@ -349,8 +360,11 @@ HRESULT CMenuToolbarBase::SetPosSize(int x, int y, int cx, int cy)
SetWindowPos(m_hwndToolbar, NULL, x, y, cx, m_idealSize.cy, 0); SetWindowPos(m_hwndToolbar, NULL, x, y, cx, m_idealSize.cy, 0);
} }
SetWindowPos(m_hwnd, NULL, x, y, cx, cy, 0); SetWindowPos(m_hwnd, NULL, x, y, cx, cy, 0);
DWORD btnSize = SendMessage(m_hwndToolbar, TB_GETBUTTONSIZE, 0, 0); if (m_toolbarFlags & SMINIT_VERTICAL)
SendMessage(m_hwndToolbar, TB_SETBUTTONSIZE, 0, MAKELPARAM(cx, HIWORD(btnSize))); {
DWORD btnSize = SendMessage(m_hwndToolbar, TB_GETBUTTONSIZE, 0, 0);
SendMessage(m_hwndToolbar, TB_SETBUTTONSIZE, 0, MAKELPARAM(cx, HIWORD(btnSize)));
}
return S_OK; return S_OK;
} }
@ -372,8 +386,16 @@ LRESULT CALLBACK CMenuToolbarBase::s_SubclassProc(HWND hWnd, UINT uMsg, WPARAM w
LRESULT CMenuToolbarBase::SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) LRESULT CMenuToolbarBase::SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
LRESULT lr;
switch (uMsg) switch (uMsg)
{ {
case WM_COMMAND:
OnWinEvent(hWnd, uMsg, wParam, lParam, &lr);
break;
case WM_NOTIFY:
OnWinEvent(hWnd, uMsg, wParam, lParam, &lr);
break;
case WM_TIMER: case WM_TIMER:
if (wParam == TIMERID_HOTTRACK) if (wParam == TIMERID_HOTTRACK)
{ {
@ -402,9 +424,12 @@ HRESULT CMenuToolbarBase::OnHotItemChange(const NMTBHOTITEM * hot)
} }
else if (m_hotItem != hot->idNew) else if (m_hotItem != hot->idNew)
{ {
DWORD elapsed = 0; if (m_toolbarFlags & SMINIT_VERTICAL)
SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &elapsed, 0); {
SetTimer(m_hwndToolbar, TIMERID_HOTTRACK, elapsed, NULL); DWORD elapsed = 0;
SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &elapsed, 0);
SetTimer(m_hwndToolbar, TIMERID_HOTTRACK, elapsed, NULL);
}
m_hotItem = hot->idNew; m_hotItem = hot->idNew;
m_menuBand->_OnHotItemChanged(this, m_hotItem); m_menuBand->_OnHotItemChanged(this, m_hotItem);
@ -415,8 +440,18 @@ HRESULT CMenuToolbarBase::OnHotItemChange(const NMTBHOTITEM * hot)
HRESULT CMenuToolbarBase::OnHotItemChanged(CMenuToolbarBase * toolbar, INT item) HRESULT CMenuToolbarBase::OnHotItemChanged(CMenuToolbarBase * toolbar, INT item)
{ {
BOOL wasChecked = FALSE;
if (m_hotBar == this && !(m_toolbarFlags & SMINIT_VERTICAL))
{
wasChecked = SendMessage(m_hwndToolbar, TB_ISBUTTONCHECKED, m_hotItem, 0);
SendMessage(m_hwndToolbar, TB_CHECKBUTTON, m_hotItem, FALSE);
}
m_hotBar = toolbar; m_hotBar = toolbar;
m_hotItem = item; m_hotItem = item;
if (wasChecked && m_hotBar == this && !(m_toolbarFlags & SMINIT_VERTICAL))
{
SendMessage(m_hwndToolbar, TB_CHECKBUTTON, m_hotItem, TRUE);
}
InvalidateDraw(); InvalidateDraw();
return S_OK; return S_OK;
} }
@ -436,18 +471,25 @@ HRESULT CMenuToolbarBase::PopupSubMenu(UINT uItem, UINT index, IShellMenu* child
HRESULT hr = 0; HRESULT hr = 0;
RECT rc = { 0 }; RECT rc = { 0 };
RECT rcx = { 0 };
if (!SendMessage(m_hwndToolbar, TB_GETITEMRECT, index, reinterpret_cast<LPARAM>(&rc))) if (!SendMessage(m_hwndToolbar, TB_GETITEMRECT, index, reinterpret_cast<LPARAM>(&rc)))
return E_FAIL; return E_FAIL;
GetWindowRect(m_hwnd, &rcx);
POINT a = { rc.left, rc.top }; POINT a = { rc.left, rc.top };
POINT b = { rc.right, rc.bottom }; POINT b = { rc.right, rc.bottom };
POINT c = { rcx.left, rcx.top };
POINT d = { rcx.right, rcx.bottom };
ClientToScreen(m_hwndToolbar, &a); ClientToScreen(m_hwndToolbar, &a);
ClientToScreen(m_hwndToolbar, &b); ClientToScreen(m_hwndToolbar, &b);
ClientToScreen(m_hwnd, &c);
ClientToScreen(m_hwnd, &d);
POINTL pt = { b.x - 3, a.y - 3 }; POINTL pt = { b.x - 3, a.y - 3 };
RECTL rcl = { a.x, a.y, b.x, b.y }; // maybe-TODO: fetch client area of deskbar? RECTL rcl = { c.x, c.y, d.x, d.y };
#if USE_SYSTEM_MENUSITE #if USE_SYSTEM_MENUSITE
hr = CoCreateInstance(CLSID_MenuBandSite, hr = CoCreateInstance(CLSID_MenuBandSite,
@ -499,20 +541,40 @@ HRESULT CMenuToolbarBase::PopupSubMenu(UINT uItem, UINT index, IShellMenu* child
return S_OK; return S_OK;
} }
HRESULT CMenuToolbarBase::PopupSubMenu(UINT index, HMENU menu) HRESULT CMenuToolbarBase::PopupSubMenu(UINT uItem, UINT index, HMENU menu)
{ {
RECT rc = { 0 }; RECT rc = { 0 };
RECT rcx = { 0 };
if (!SendMessage(m_hwndToolbar, TB_GETITEMRECT, index, reinterpret_cast<LPARAM>(&rc))) if (!SendMessage(m_hwndToolbar, TB_GETITEMRECT, index, reinterpret_cast<LPARAM>(&rc)))
return E_FAIL; return E_FAIL;
POINT b = { rc.right, rc.bottom }; GetWindowRect(m_hwnd, &rcx);
POINT a = { rc.left, rc.top };
POINT b = { rc.right, rc.bottom };
POINT c = { rcx.left, rcx.top };
POINT d = { rcx.right, rcx.bottom };
ClientToScreen(m_hwndToolbar, &a);
ClientToScreen(m_hwndToolbar, &b); ClientToScreen(m_hwndToolbar, &b);
ClientToScreen(m_hwnd, &c);
ClientToScreen(m_hwnd, &d);
POINT pt = { a.x, b.y };
RECT rcl = { c.x, c.y, d.x, d.y };
if (m_toolbarFlags & SMINIT_VERTICAL)
{
pt.x = b.x;
pt.y = a.y;
}
HMENU popup = GetSubMenu(menu, index); HMENU popup = GetSubMenu(menu, index);
m_menuBand->_TrackSubMenuUsingTrackPopupMenu(popup, b.x, b.y); m_menuBand->_TrackSubMenuUsingTrackPopupMenu(popup, pt.x, pt.y, rcl);
SendMessage(m_hwndToolbar, TB_CHECKBUTTON, uItem, FALSE);
return S_OK; return S_OK;
} }
@ -653,22 +715,23 @@ HRESULT CMenuToolbarBase::AddButton(DWORD commandId, LPCWSTR caption, BOOL hasSu
tbb.fsState = TBSTATE_ENABLED; tbb.fsState = TBSTATE_ENABLED;
#ifndef TBSTYLE_EX_VERTICAL #ifndef TBSTYLE_EX_VERTICAL
if (!last) if (!last && (m_toolbarFlags & SMINIT_VERTICAL))
tbb.fsState |= TBSTATE_WRAP; tbb.fsState |= TBSTATE_WRAP;
#endif #endif
tbb.fsStyle = 0; tbb.fsStyle = 0;
if (hasSubMenu) if (hasSubMenu && (m_toolbarFlags & SMINIT_VERTICAL))
tbb.fsStyle |= BTNS_DROPDOWN; tbb.fsStyle |= BTNS_DROPDOWN;
if (!(m_toolbarFlags & SMINIT_VERTICAL))
tbb.fsStyle |= BTNS_AUTOSIZE | BTNS_CHECKGROUP;
tbb.iString = (INT_PTR) caption; tbb.iString = (INT_PTR) caption;
tbb.idCommand = commandId; tbb.idCommand = commandId;
tbb.iBitmap = iconId; tbb.iBitmap = iconId;
tbb.dwData = buttonData; tbb.dwData = buttonData;
DbgPrint("Trying to add a new button with id %d and caption '%S'...\n", commandId, caption);
if (!SendMessageW(m_hwndToolbar, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb))) if (!SendMessageW(m_hwndToolbar, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb)))
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
@ -681,14 +744,12 @@ HRESULT CMenuToolbarBase::AddSeparator(BOOL last)
tbb.fsState = TBSTATE_ENABLED; tbb.fsState = TBSTATE_ENABLED;
#ifndef TBSTYLE_EX_VERTICAL #ifndef TBSTYLE_EX_VERTICAL
if (!last) if (!last && (m_toolbarFlags & SMINIT_VERTICAL))
tbb.fsState |= TBSTATE_WRAP; tbb.fsState |= TBSTATE_WRAP;
#endif #endif
tbb.fsStyle = BTNS_SEP; tbb.fsStyle = BTNS_SEP;
tbb.iBitmap = 0; tbb.iBitmap = 0;
DbgPrint("Trying to add a new separator...\n");
if (!SendMessageW(m_hwndToolbar, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb))) if (!SendMessageW(m_hwndToolbar, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb)))
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
@ -705,8 +766,6 @@ HRESULT CMenuToolbarBase::AddPlaceholder()
tbb.iString = (INT_PTR) MenuString; tbb.iString = (INT_PTR) MenuString;
tbb.iBitmap = -1; tbb.iBitmap = -1;
DbgPrint("Trying to add a new placeholder...\n");
if (!SendMessageW(m_hwndToolbar, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb))) if (!SendMessageW(m_hwndToolbar, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb)))
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
@ -810,8 +869,6 @@ HRESULT CMenuStaticToolbar::FillToolbar()
count++; count++;
DbgPrint("Found item with fType=%x, cmdId=%d\n", info.fType, info.wID);
if (info.fType & MFT_SEPARATOR) if (info.fType & MFT_SEPARATOR)
{ {
AddSeparator(last); AddSeparator(last);
@ -839,8 +896,6 @@ HRESULT CMenuStaticToolbar::FillToolbar()
} }
} }
DbgPrint("Created toolbar with %d buttons.\n", count);
return S_OK; return S_OK;
} }
@ -876,7 +931,7 @@ HRESULT CMenuStaticToolbar::InternalPopupItem(INT uItem, INT index, DWORD_PTR dw
if (nfo->dwFlags&SMIF_TRACKPOPUP) if (nfo->dwFlags&SMIF_TRACKPOPUP)
{ {
return PopupSubMenu(index, m_hmenu); return PopupSubMenu(uItem, index, m_hmenu);
} }
else else
{ {
@ -951,13 +1006,9 @@ HRESULT CMenuSFToolbar::FillToolbar()
// If no items were added, show the "empty" placeholder // If no items were added, show the "empty" placeholder
if (i == 0) if (i == 0)
{ {
DbgPrint("The toolbar is empty, adding placeholder.\n");
return AddPlaceholder(); return AddPlaceholder();
} }
DbgPrint("Created toolbar with %d buttons.\n", i);
return hr; return hr;
} }

View file

@ -42,6 +42,8 @@ protected:
CMenuToolbarBase * m_popupBar; CMenuToolbarBase * m_popupBar;
INT m_popupItem; INT m_popupItem;
DWORD m_toolbarFlags;
private: private:
static LRESULT CALLBACK s_SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK s_SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
@ -61,7 +63,7 @@ public:
HRESULT OnPopupItemChanged(CMenuToolbarBase * toolbar, INT item); HRESULT OnPopupItemChanged(CMenuToolbarBase * toolbar, INT item);
HRESULT PopupSubMenu(UINT itemId, UINT index, IShellMenu* childShellMenu); HRESULT PopupSubMenu(UINT itemId, UINT index, IShellMenu* childShellMenu);
HRESULT PopupSubMenu(UINT index, HMENU menu); HRESULT PopupSubMenu(UINT itemId, UINT index, HMENU menu);
HRESULT DoContextMenu(IContextMenu* contextMenu); HRESULT DoContextMenu(IContextMenu* contextMenu);
HRESULT ChangeHotItem(DWORD changeType); HRESULT ChangeHotItem(DWORD changeType);

View file

@ -59,3 +59,9 @@ add_importlibs(browseui
add_pch(browseui precomp.h SOURCE) add_pch(browseui precomp.h SOURCE)
add_cd_file(TARGET browseui DESTINATION reactos/system32 FOR all) add_cd_file(TARGET browseui DESTINATION reactos/system32 FOR all)
add_custom_command(TARGET browseui POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:browseui>"
"$<TARGET_FILE_DIR:filebrowser>/$<TARGET_FILE_NAME:browseui>"
COMMENT "Copying to output directory")

View file

@ -67,6 +67,8 @@ extern HRESULT CreateBrandBand(REFIID riid, void **ppv);
extern HRESULT CreateBandProxy(REFIID riid, void **ppv); extern HRESULT CreateBandProxy(REFIID riid, void **ppv);
extern HRESULT CreateAddressBand(REFIID riid, void **ppv); extern HRESULT CreateAddressBand(REFIID riid, void **ppv);
typedef HRESULT(*PMENUBAND_CONSTRUCTOR)(REFIID riid, void **ppv);
class CInternetToolbar; class CInternetToolbar;
class CDockSite : class CDockSite :
@ -372,8 +374,23 @@ HRESULT STDMETHODCALLTYPE CMenuCallback::GetObject(LPSMDATA psmd, REFIID riid, v
favoritesHMenu = GetSubMenu(parentHMenu, 3); favoritesHMenu = GetSubMenu(parentHMenu, 3);
if (favoritesHMenu == NULL) if (favoritesHMenu == NULL)
return E_FAIL; return E_FAIL;
#if 1
HMODULE hrs = LoadLibrary(L"rshell.dll");
PMENUBAND_CONSTRUCTOR func = (PMENUBAND_CONSTRUCTOR) GetProcAddress(hrs, "CMenuBand_Constructor");
if (func)
{
hResult = func(IID_PPV_ARG(IShellMenu, &newMenu));
}
else
{
hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
IID_IShellMenu, reinterpret_cast<void **>(&newMenu));
}
#else
hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER, hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
IID_IShellMenu, reinterpret_cast<void **>(&newMenu)); IID_IShellMenu, reinterpret_cast<void **>(&newMenu));
#endif
if (FAILED(hResult)) if (FAILED(hResult))
return hResult; return hResult;
hResult = newMenu->Initialize(this, FCIDM_MENU_FAVORITES, -1, SMINIT_VERTICAL | SMINIT_CACHED); hResult = newMenu->Initialize(this, FCIDM_MENU_FAVORITES, -1, SMINIT_VERTICAL | SMINIT_CACHED);
@ -536,8 +553,35 @@ HRESULT CInternetToolbar::CreateMenuBar(IShellMenu **menuBar)
HWND ownerWindow; HWND ownerWindow;
HRESULT hResult; HRESULT hResult;
#if 1
HMODULE hrs = LoadLibraryW(L"rshell.dll");
if (!hrs)
{
DbgPrint("Failed: %d\n", GetLastError());
return E_FAIL;
}
PMENUBAND_CONSTRUCTOR func = (PMENUBAND_CONSTRUCTOR) GetProcAddress(hrs, "CMenuBand_Constructor");
if (func)
{
hResult = func(IID_PPV_ARG(IShellMenu, menuBar));
}
else
{
DbgPrint("Failed: %d\n", GetLastError());
hResult = E_FAIL;
}
if (FAILED(hResult))
{
hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
IID_IShellMenu, reinterpret_cast<void **>(menuBar));
}
#else
hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER, hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
IID_IShellMenu, reinterpret_cast<void **>(menuBar)); IID_IShellMenu, reinterpret_cast<void **>(menuBar));
#endif
if (FAILED(hResult)) if (FAILED(hResult))
return hResult; return hResult;
hResult = fMenuCallback.QueryInterface(IID_IShellMenuCallback, reinterpret_cast<void **>(&callback)); hResult = fMenuCallback.QueryInterface(IID_IShellMenuCallback, reinterpret_cast<void **>(&callback));
@ -1137,12 +1181,16 @@ HRESULT STDMETHODCALLTYPE CInternetToolbar::OnWinEvent(
CComPtr<IWinEventHandler> menuWinEventHandler; CComPtr<IWinEventHandler> menuWinEventHandler;
HRESULT hResult; HRESULT hResult;
if (fMenuBar.p != NULL) if (fMenuBar)
{ {
hResult = fMenuBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler)); hResult = fMenuBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
return menuWinEventHandler->OnWinEvent(fMenuBandWindow, uMsg, wParam, lParam, theResult); if (menuWinEventHandler->IsWindowOwner(hWnd))
{
return menuWinEventHandler->OnWinEvent(fMenuBandWindow, uMsg, wParam, lParam, theResult);
}
} }
return E_FAIL;
return S_FALSE;
} }
HRESULT STDMETHODCALLTYPE CInternetToolbar::IsWindowOwner(HWND hWnd) HRESULT STDMETHODCALLTYPE CInternetToolbar::IsWindowOwner(HWND hWnd)
@ -1410,20 +1458,6 @@ LRESULT CInternetToolbar::OnQueryDelete(UINT idControl, NMHDR *pNMHDR, BOOL &bHa
return 1; return 1;
} }
LRESULT CInternetToolbar::OnNavigateCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
CComPtr<IWinEventHandler> winEventHandler;
LRESULT theResult;
HRESULT hResult;
hResult = fNavigationBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&winEventHandler));
hResult = winEventHandler->OnWinEvent(m_hWnd, uMsg, wParam, lParam, &theResult);
if (SUCCEEDED(hResult))
return theResult;
bHandled = FALSE;
return 0;
}
LRESULT CInternetToolbar::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) LRESULT CInternetToolbar::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{ {
HMENU contextMenuBar; HMENU contextMenuBar;
@ -1553,27 +1587,78 @@ LRESULT CInternetToolbar::OnTipText(UINT idControl, NMHDR *pNMHDR, BOOL &bHandle
return 0; return 0;
} }
LRESULT CInternetToolbar::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
LRESULT theResult;
HRESULT hResult;
HWND target = (HWND) lParam;
if (fMenuBar)
{
CComPtr<IWinEventHandler> menuWinEventHandler;
hResult = fMenuBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
if (SUCCEEDED(hResult))
{
if (menuWinEventHandler->IsWindowOwner(target) == S_OK)
{
hResult = menuWinEventHandler->OnWinEvent(target, uMsg, wParam, lParam, &theResult);
return FAILED(hResult) ? 0 : theResult;
}
}
}
if (fNavigationBar)
{
CComPtr<IWinEventHandler> menuWinEventHandler;
hResult = fNavigationBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
if (SUCCEEDED(hResult))
{
if (menuWinEventHandler->IsWindowOwner(target) == S_OK)
{
hResult = menuWinEventHandler->OnWinEvent(target, uMsg, wParam, lParam, &theResult);
return FAILED(hResult) ? 0 : theResult;
}
}
}
return 0;
}
LRESULT CInternetToolbar::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) LRESULT CInternetToolbar::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{ {
NMHDR *notifyHeader; NMHDR *notifyHeader;
CComPtr<IWinEventHandler> menuWinEventHandler; LRESULT theResult;
LRESULT theResult; HRESULT hResult;
HRESULT hResult;
notifyHeader = (NMHDR *)lParam; notifyHeader = (NMHDR *) lParam;
if (fMenuBar.p != NULL && notifyHeader->hwndFrom == fMenuBandWindow)
if (fMenuBar)
{ {
CComPtr<IWinEventHandler> menuWinEventHandler;
hResult = fMenuBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler)); hResult = fMenuBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
hResult = menuWinEventHandler->OnWinEvent(fMenuBandWindow, uMsg, wParam, lParam, &theResult); if (SUCCEEDED(hResult))
return theResult; {
if (menuWinEventHandler->IsWindowOwner(notifyHeader->hwndFrom) == S_OK)
{
hResult = menuWinEventHandler->OnWinEvent(notifyHeader->hwndFrom, uMsg, wParam, lParam, &theResult);
return FAILED(hResult) ? 0 : theResult;
}
}
} }
if (fNavigationBar.p != NULL && notifyHeader->hwndFrom == fNavigationWindow)
if (fNavigationBar)
{ {
hResult = fNavigationBar->QueryInterface( CComPtr<IWinEventHandler> menuWinEventHandler;
IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler)); hResult = fNavigationBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
hResult = menuWinEventHandler->OnWinEvent(m_hWnd, uMsg, wParam, lParam, &theResult); if (SUCCEEDED(hResult))
return theResult; {
if (menuWinEventHandler->IsWindowOwner(notifyHeader->hwndFrom) == S_OK)
{
hResult = menuWinEventHandler->OnWinEvent(notifyHeader->hwndFrom, uMsg, wParam, lParam, &theResult);
return FAILED(hResult) ? 0 : theResult;
}
}
} }
return 0; return 0;
} }

View file

@ -196,6 +196,7 @@ public:
LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
LRESULT OnSetCursor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); LRESULT OnSetCursor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
LRESULT OnTipText(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled); LRESULT OnTipText(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled);
LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
BEGIN_MSG_MAP(CInternetToolbar) BEGIN_MSG_MAP(CInternetToolbar)
@ -208,7 +209,7 @@ public:
NOTIFY_HANDLER(0, TBN_DROPDOWN, OnMenuDropDown) NOTIFY_HANDLER(0, TBN_DROPDOWN, OnMenuDropDown)
NOTIFY_HANDLER(0, TBN_QUERYINSERT, OnQueryInsert) NOTIFY_HANDLER(0, TBN_QUERYINSERT, OnQueryInsert)
NOTIFY_HANDLER(0, TBN_QUERYDELETE, OnQueryDelete) NOTIFY_HANDLER(0, TBN_QUERYDELETE, OnQueryDelete)
MESSAGE_HANDLER(WM_COMMAND, OnNavigateCommand) MESSAGE_HANDLER(WM_COMMAND, OnCommand)
MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu) MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
MESSAGE_HANDLER(WM_SIZE, OnSize) MESSAGE_HANDLER(WM_SIZE, OnSize)
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)

View file

@ -38,6 +38,43 @@
#include "commonbrowser.h" #include "commonbrowser.h"
#include "globalfoldersettings.h" #include "globalfoldersettings.h"
#include "regtreeoptions.h" #include "regtreeoptions.h"
#include <stdio.h>
static __inline ULONG
Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
{
char szMsg[512];
char *szMsgStart;
const char *fname;
va_list vl;
ULONG uRet;
fname = strrchr(filename, '\\');
if (fname == NULL)
{
fname = strrchr(filename, '/');
if (fname != NULL)
fname++;
}
else
fname++;
if (fname == NULL)
fname = filename;
szMsgStart = szMsg + sprintf(szMsg, "%s:%d: ", fname, line);
va_start(vl, lpFormat);
uRet = (ULONG) vsprintf(szMsgStart, lpFormat, vl);
va_end(vl);
OutputDebugStringA(szMsg);
return uRet;
}
#define DbgPrint(fmt, ...) \
Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
WINE_DEFAULT_DEBUG_CHANNEL(browseui); WINE_DEFAULT_DEBUG_CHANNEL(browseui);

Binary file not shown.