* Port the implementation of CMenuDeskBar to rshell (still disabled by default).
* Begin implementing missing features:
 - Notify the band of the icon size change from SetIconSize.

svn path=/branches/shell-experiments/; revision=62138
This commit is contained in:
David Quintana 2014-02-12 19:46:24 +00:00
parent edd5a38091
commit 3bb9ee7f77
3 changed files with 535 additions and 1 deletions

View file

@ -28,6 +28,7 @@ target_link_libraries(rshell
add_importlibs(rshell
shlwapi
shell32
gdi32
ole32
user32
msvcrt

View file

@ -19,12 +19,21 @@
*/
#include "precomp.h"
#include "wraplog.h"
#include <atlwin.h>
WINE_DEFAULT_DEBUG_CHANNEL(CMenuDeskBar);
#define WRAP_LOG 1
typedef CWinTraits<
WS_POPUP | WS_DLGFRAME | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_PALETTEWINDOW
> CMenuWinTraits;
class CMenuDeskBar :
#if !WRAP_LOG
public CWindowImpl<CMenuDeskBar, CWindow, CMenuWinTraits>,
#endif
public CComCoClass<CMenuDeskBar>,
public CComObjectRootEx<CComMultiThreadModelNoCS>,
public IOleCommandTarget,
@ -54,6 +63,20 @@ private:
IBanneredBar * m_IBanneredBar;
IInitializeObject * m_IInitializeObject;
#else
CComPtr<IUnknown> m_Site;
CComPtr<IUnknown> m_Client;
HWND m_ClientWindow;
bool m_Vertical;
bool m_Visible;
int m_NeededSize; // width or height
DWORD m_IconSize;
HBITMAP m_Banner;
// used by resize tracking loop
bool m_Tracking;
POINT m_LastLocation;
#endif
public:
@ -99,10 +122,38 @@ public:
virtual HRESULT STDMETHODCALLTYPE GetClient(IUnknown **ppunkClient);
virtual HRESULT STDMETHODCALLTYPE OnPosRectChangeDB(LPRECT prc);
// message handlers
LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
LRESULT OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
LRESULT OnCancelMode(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
LRESULT OnCaptureChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
LRESULT OnWindowPosChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
DECLARE_NOT_AGGREGATABLE(CMenuDeskBar)
DECLARE_PROTECT_FINAL_CONSTRUCT()
#if !WRAP_LOG
DECLARE_WND_CLASS_EX(_T("BaseBar"), 0, COLOR_3DFACE)
#endif
BEGIN_MSG_MAP(CMenuDeskBar)
MESSAGE_HANDLER(WM_SIZE, OnSize)
MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
MESSAGE_HANDLER(WM_CANCELMODE, OnCancelMode)
MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged)
MESSAGE_HANDLER(WM_WINDOWPOSCHANGED, OnWindowPosChanged)
MESSAGE_HANDLER(WM_ACTIVATE, OnActivate)
/* MESSAGE_HANDLER(WM_PAINT, OnPaint) */
END_MSG_MAP()
BEGIN_COM_MAP(CMenuDeskBar)
COM_INTERFACE_ENTRY_IID(IID_IMenuPopup, IMenuPopup)
COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
@ -135,6 +186,7 @@ HRESULT CMenuDeskBar_Constructor(REFIID riid, LPVOID *ppv)
return hr;
}
#if WRAP_LOG
CMenuDeskBar::CMenuDeskBar()
{
HRESULT hr;
@ -392,3 +444,484 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::OnPosRectChangeDB(LPRECT prc)
WrapLogExit("CMenuDeskBar::OnPosRectChangeDB() = %08x\n", hr);
return hr;
}
#else
CMenuDeskBar::CMenuDeskBar() :
m_ClientWindow(NULL),
m_Vertical(true),
m_Visible(false),
m_NeededSize(200),
m_Tracking(false)
{
}
CMenuDeskBar::~CMenuDeskBar()
{
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::GetWindow(HWND *lphwnd)
{
if (lphwnd == NULL)
return E_POINTER;
*lphwnd = m_hWnd;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::ContextSensitiveHelp(BOOL fEnterMode)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::OnFocusChangeIS(IUnknown *punkObj, BOOL fSetFocus)
{
// forward to owner
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds,
OLECMD prgCmds[], OLECMDTEXT *pCmdText)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::Exec(const GUID *pguidCmdGroup, DWORD nCmdID,
DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
if (IsEqualIID(*pguidCmdGroup, CGID_Explorer))
{
}
else if (IsEqualIID(*pguidCmdGroup, IID_IDeskBarClient))
{
switch (nCmdID)
{
case 0:
// hide current band
break;
case 2:
break;
case 3:
break;
}
}
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
{
CComPtr<IServiceProvider> serviceProvider;
HRESULT hResult;
if (m_Site == NULL)
return E_FAIL;
hResult = m_Site->QueryInterface(IID_IServiceProvider, reinterpret_cast<void **>(&serviceProvider));
if (FAILED(hResult))
return hResult;
// called for SID_STopLevelBrowser, IID_IBrowserService to find top level browser
// called for SID_IWebBrowserApp, IID_IConnectionPointContainer
// connection point called for DIID_DWebBrowserEvents2 to establish connection
return serviceProvider->QueryService(guidService, riid, ppvObject);
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::UIActivateIO(BOOL fActivate, LPMSG lpMsg)
{
// forward to contained bar
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::HasFocusIO()
{
// forward to contained bar
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::TranslateAcceleratorIO(LPMSG lpMsg)
{
// forward to contained bar
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::SetClient(IUnknown *punkClient)
{
CComPtr<IDeskBarClient> pDeskBandClient;
HRESULT hResult;
if (m_hWnd == NULL)
{
HWND ownerWindow = NULL;
if (m_Site)
{
IOleWindow * oleWindow;
hResult = m_Site->QueryInterface(IID_IOleWindow, reinterpret_cast<void **>(&oleWindow));
if (SUCCEEDED(hResult))
hResult = oleWindow->GetWindow(&ownerWindow);
if (!::IsWindow(ownerWindow))
return E_FAIL;
}
Create(ownerWindow);
}
if (punkClient == NULL)
m_Client.Release();
else
{
hResult = punkClient->QueryInterface(IID_IUnknown, reinterpret_cast<void **>(&m_Client));
if (FAILED(hResult))
return hResult;
hResult = m_Client->QueryInterface(IID_IDeskBarClient, (VOID**) &pDeskBandClient);
if (FAILED(hResult))
return hResult;
hResult = pDeskBandClient->SetDeskBarSite(static_cast<IDeskBar*>(this));
if (FAILED(hResult))
return hResult;
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::GetClient(IUnknown **ppunkClient)
{
if (ppunkClient == NULL)
return E_POINTER;
*ppunkClient = m_Client;
if (m_Client.p != NULL)
m_Client.p->AddRef();
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::OnPosRectChangeDB(LPRECT prc)
{
if (prc == NULL)
return E_POINTER;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::SetSite(IUnknown *pUnkSite)
{
return S_OK;
CComPtr<IServiceProvider> serviceProvider;
CComPtr<IProfferService> profferService;
HRESULT hResult;
CComPtr<IOleWindow> oleWindow;
HWND ownerWindow;
m_Site.Release();
if (pUnkSite == NULL)
{
return S_OK;
}
if (m_hWnd == NULL)
{
// get window handle of parent
hResult = pUnkSite->QueryInterface(IID_ITrayPriv, reinterpret_cast<void **>(&m_Site));
if (FAILED(hResult))
return hResult;
hResult = pUnkSite->QueryInterface(IID_IOleWindow, reinterpret_cast<void **>(&oleWindow));
if (SUCCEEDED(hResult))
hResult = oleWindow->GetWindow(&ownerWindow);
if (!::IsWindow(ownerWindow))
return E_FAIL;
Create(ownerWindow);
}
else
{
//Set Owner ?
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::GetSite(REFIID riid, void **ppvSite)
{
if (ppvSite == NULL)
return E_POINTER;
*ppvSite = m_Site;
if (m_Site.p != NULL)
m_Site.p->AddRef();
return S_OK;
}
LRESULT CMenuDeskBar::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
HRESULT hr;
if (m_Client)
{
CComPtr<IOleWindow> pOw;
hr = m_Client->QueryInterface(IID_PPV_ARG(IOleWindow, &pOw));
if (FAILED(hr))
{
ERR("IUnknown_QueryInterface pBs failed: %x\n", hr);
return 0;
}
HWND clientWnd;
pOw->GetWindow(&clientWnd);
RECT rc;
GetClientRect(&rc);
if (m_Banner != NULL)
{
SIZE sz;
::GetBitmapDimensionEx(m_Banner, &sz);
rc.left += sz.cx;
}
::SetWindowPos(clientWnd, NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, 0);
}
return 0;
}
LRESULT CMenuDeskBar::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
CComPtr<IWinEventHandler> winEventHandler;
LRESULT result;
HRESULT hResult;
result = 0;
if (m_Client.p != NULL)
{
hResult = m_Client->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&winEventHandler));
if (SUCCEEDED(hResult) && winEventHandler.p != NULL)
hResult = winEventHandler->OnWinEvent(NULL, uMsg, wParam, lParam, &result);
}
return result;
}
LRESULT CMenuDeskBar::OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
SetCapture();
m_Tracking = true;
m_LastLocation.x = LOWORD(lParam);
m_LastLocation.y = HIWORD(lParam);
return 0;
}
LRESULT CMenuDeskBar::OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
ReleaseCapture();
m_Tracking = false;
return 0;
}
LRESULT CMenuDeskBar::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
POINT newLocation;
//int delta;
if (m_Tracking)
{
newLocation.x = (short) LOWORD(lParam);
newLocation.y = (short) HIWORD(lParam);
m_LastLocation = newLocation;
}
return 0;
}
LRESULT CMenuDeskBar::OnCancelMode(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
m_Tracking = false;
return 0;
}
LRESULT CMenuDeskBar::OnCaptureChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
m_Tracking = false;
return 0;
}
LRESULT CMenuDeskBar::OnWindowPosChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
return 0;
}
LRESULT CMenuDeskBar::OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
if (LOWORD(wParam) == WA_INACTIVE)
{
//DestroyWindow();
//ShowWindow(SW_HIDE);
}
return 0;
}
LRESULT CMenuDeskBar::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
TRACE("OnPaint\n");
if (m_Banner && !m_IconSize)
{
BITMAP bm;
PAINTSTRUCT ps;
HDC hdc = BeginPaint(&ps);
HDC hdcMem = ::CreateCompatibleDC(hdc);
HGDIOBJ hbmOld = ::SelectObject(hdcMem, m_Banner);
::GetObject(m_Banner, sizeof(bm), &bm);
TRACE("Painting banner: %d by %d\n", bm.bmWidth, bm.bmHeight);
if (!::BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY))
WARN("BitBlt failed\n");
::SelectObject(hdcMem, hbmOld);
::DeleteDC(hdcMem);
EndPaint(&ps);
}
return 0;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS dwFlags)
{
//ENTER >> CMenuDeskBar<03901CC0>::Popup(POINTL *ppt=00B3F428, RECTL *prcExclude=00B3F418, MP_POPUPFLAGS dwFlags=80000000)
// ENTER >> CMenuBand<00D2CCF8>::QueryService
// ENTER >> CMenuBand<00D2CCF8>::ShowDW(BOOL fShow=1)
// ENTER >> CMenuDeskBar<03901CC0>::GetSite(REFIID riid={4622AD10-FF23-11D0-8D34-00A0C90F2719}, PVOID *ppvSite=03901D4C)
// -- *ppvSite=00BDEA90
// EXIT <<< CMenuDeskBar::GetSite() = 00000000
// ENTER >> CMenuBand<00D2CCF8>::SetMenu(HMENU hmenu=593F0A07, HWND hwnd=00000000, DWORD dwFlags=20000000)
// EXIT <<< CMenuBand::SetMenu() = 00000000
// EXIT <<< CMenuBand::ShowDW() = 00000000
// ENTER >> CMenuBand<00D2CCF8>::GetBandInfo(DWORD dwBandID=0, DWORD dwViewMode=0, DESKBANDINFO *pdbi=00B3F0F0)
// EXIT <<< CMenuBand::GetBandInfo() = 00000000
// ENTER >> CMenuBand<00D2CCF8>::QueryService(REFGUID guidService={ED9CC020-08B9-11D1-9823-00C04FD91972}, REFIID riid={B722BCCB-4E68-101B-A2BC-00AA00404770}, void **ppvObject=00B3F304)
// -- SID is SID_SMenuBandChild. Using QueryInterface of self instead of wrapped object.
// -- *ppvObject=00D2CD08
// EXIT <<< CMenuBand::QueryService() = 00000000
// ENTER >> CMenuBand<00D2CCF8>::Exec(const GUID *pguidCmdGroup=76BAE1FC, DWORD nCmdID=19, DWORD nCmdexecopt=0, VARIANT *pvaIn=00000000, VARIANT *pvaOut=00000000)
// -- *pguidCmdGroup={5B4DAE26-B807-11D0-9815-00C04FD91972}
// EXIT <<< CMenuBand::Exec() = 00000001
// ENTER >> CMenuBand<00D2CCF8>::OnPosRectChangeDB(RECT *prc=00B3E630)
// -- *prc={L: 0, T: 0, R: 218, B: 305}
// EXIT <<< CMenuBand::OnPosRectChangeDB() = 00000000
// ENTER >> CMenuBand<00D2CCF8>::UIActivateIO(BOOL fActivate=1, LPMSG lpMsg=00000000)
// EXIT <<< CMenuBand::UIActivateIO() = 00000001
//EXIT <<< CMenuDeskBar::Popup() = 00000000
HRESULT hr;
IServiceProvider * sp;
IOleCommandTarget * oct;
IInputObject * io;
hr = m_Client->QueryInterface(IID_PPV_ARG(IServiceProvider, &sp));
if (FAILED(hr))
return hr;
hr = m_Client->QueryInterface(IID_PPV_ARG(IInputObject, &io));
if (FAILED(hr))
return hr;
hr = sp->QueryService(SID_SMenuBandChild, IID_PPV_ARG(IOleCommandTarget, &oct));
if (FAILED(hr))
{
sp->Release();
return hr;
}
// Unknown meaning
const int CMD = 19;
const int CMD_EXEC_OPT = 0;
hr = oct->Exec(&CLSID_MenuBand, CMD, CMD_EXEC_OPT, NULL, NULL);
oct->Release();
sp->Release();
return hr;
// FIXME: everything!
const int hackWidth = 200;
const int hackHeight = 400;
RECT r = { ppt->x, ppt->y - hackHeight, ppt->x + hackWidth, ppt->y };
if (this->m_hWnd == NULL)
{
this->Create(NULL, &r);
}
this->SetWindowPos(NULL, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_SHOWWINDOW);
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::SetIconSize(THIS_ DWORD iIcon)
{
HRESULT hr;
IServiceProvider * sp;
IOleCommandTarget * oct;
m_IconSize = iIcon;
hr = m_Client->QueryInterface(IID_PPV_ARG(IServiceProvider, &sp));
if (FAILED(hr))
return hr;
hr = sp->QueryService(SID_SMenuBandChild, IID_PPV_ARG(IOleCommandTarget, &oct));
if (FAILED(hr))
{
sp->Release();
return hr;
}
// Unknown meaning
const int CMD = 16;
const int CMD_EXEC_OPT = 2;
hr = oct->Exec(&CLSID_MenuBand, CMD, CMD_EXEC_OPT, NULL, NULL);
oct->Release();
sp->Release();
return hr;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::GetIconSize(THIS_ DWORD* piIcon)
{
if (piIcon)
*piIcon = m_IconSize;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::SetBitmap(THIS_ HBITMAP hBitmap)
{
m_Banner = hBitmap;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::GetBitmap(THIS_ HBITMAP* phBitmap)
{
if (phBitmap)
*phBitmap = m_Banner;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::OnSelect(
DWORD dwSelectType)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::SetSubMenu(
IMenuPopup *pmp,
BOOL fSet)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::Initialize(THIS)
{
return S_OK;
}
#endif

View file

@ -1451,7 +1451,7 @@ HRESULT WINAPI CDesktopFolder::Drop(IDataObject *pDataObject,
else
{
InitFormatEtc (formatetc, CF_HDROP, TYMED_HGLOBAL);
if SUCCEEDED(pDataObject->QueryGetData(&formatetc));
if (SUCCEEDED(pDataObject->QueryGetData(&formatetc)))
{
passthroughtofs = TRUE;
}