- CMenuBand: Fix the size of the separators by setting iBitmap to 0 (which acts as the width of the separator).
- CMenuDeskBar: 
Create the window only in CMenuDeskBar::SetClient and not in SetSite. 
Greatly simplify SetSite. 
Make sure that WS_EX_TOPMOST isn't removed when we call SetWindowPos
Do not forward requests for the SID_SMenuPopup service to the taskbar as this causes the menu band to capture the mouse for the taskbar and not the desk bar

svn path=/branches/shell-experiments/; revision=62223
This commit is contained in:
Giannis Adamopoulos 2014-02-16 21:53:21 +00:00
parent 9a1d783d54
commit dc404583fd
2 changed files with 22 additions and 74 deletions

View file

@ -940,14 +940,14 @@ HRESULT CMenuStaticToolbar::SetMenu(
HRESULT CMenuStaticToolbar::FillToolbar()
{
int i;
PWSTR MenuString;
int ic = GetMenuItemCount(m_hmenu);
for (i = 0; i < ic; i++)
{
MENUITEMINFOW info;
TBBUTTON tbb = { 0 };
PWSTR MenuString = NULL;
tbb.fsState = TBSTATE_ENABLED;
tbb.fsStyle = 0;
@ -961,24 +961,24 @@ HRESULT CMenuStaticToolbar::FillToolbar()
if (!AllocAndGetMenuString(m_hmenu, i, &MenuString))
return E_OUTOFMEMORY;
tbb.fsStyle |= BTNS_DROPDOWN;
tbb.iString = (INT_PTR) MenuString;
tbb.idCommand = info.wID;
SMINFO sminfo;
if (info.wID >= 0 && SUCCEEDED(m_menuBand->CallCBWithId(info.wID, SMC_GETINFO, 0, (LPARAM) &sminfo)))
{
tbb.iBitmap = sminfo.iIcon;
}
}
else
{
MenuString = L"";
tbb.fsStyle |= BTNS_SEP;
}
tbb.idCommand = info.wID;
tbb.iString = (INT_PTR) MenuString;
SMINFO sminfo;
if (info.wID >= 0 && SUCCEEDED(m_menuBand->CallCBWithId(info.wID, SMC_GETINFO, 0, (LPARAM) &sminfo)))
{
tbb.iBitmap = sminfo.iIcon;
}
SendMessageW(m_hwnd, TB_ADDBUTTONS, 1, (LPARAM) (LPTBBUTTON) &tbb);
HeapFree(GetProcessHeap(), 0, MenuString);
if (MenuString)
HeapFree(GetProcessHeap(), 0, MenuString);
}
return S_OK;

View file

@ -160,8 +160,6 @@ public:
COM_INTERFACE_ENTRY_IID(IID_IBanneredBar, IBanneredBar)
COM_INTERFACE_ENTRY_IID(IID_IInitializeObject, IInitializeObject)
END_COM_MAP()
HRESULT _CreateDeskBarWindow();
};
extern "C"
@ -456,40 +454,6 @@ CMenuDeskBar::~CMenuDeskBar()
{
}
HRESULT CMenuDeskBar::_CreateDeskBarWindow()
{
HRESULT hr;
HWND ownerWindow = NULL;
if (m_Site)
{
CComPtr<IOleWindow> oleWindow;
hr = m_Site->QueryInterface(IID_IOleWindow, reinterpret_cast<void **>(&oleWindow));
if (FAILED(hr))
return hr;
hr = oleWindow->GetWindow(&ownerWindow);
if (FAILED(hr))
return hr;
if (!::IsWindow(ownerWindow))
return E_FAIL;
}
// FIXME
if (m_hWnd)
{
SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, (LONG_PTR)ownerWindow);
}
else
{
Create(ownerWindow);
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::GetWindow(HWND *lphwnd)
{
if (lphwnd == NULL)
@ -547,6 +511,11 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::QueryService(REFGUID guidService, REFIID
if (m_Site == NULL)
return E_FAIL;
if (IsEqualGUID(guidService,SID_SMenuPopup))
{
return this->QueryInterface(riid, ppvObject);
}
return IUnknown_QueryService(m_Site, guidService, riid, ppvObject);
}
@ -589,7 +558,7 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::SetClient(IUnknown *punkClient)
if (m_hWnd == NULL)
{
_CreateDeskBarWindow();
Create(NULL);
}
hResult = punkClient->QueryInterface(IID_IUnknown, reinterpret_cast<void **>(&m_Client));
@ -623,30 +592,9 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::OnPosRectChangeDB(LPRECT prc)
HRESULT STDMETHODCALLTYPE CMenuDeskBar::SetSite(IUnknown *pUnkSite)
{
HRESULT hr;
CComPtr<IOleWindow> oleWindow;
HWND ownerWindow = NULL;
m_Site = pUnkSite;
if (m_Site)
{
if (m_hWnd != NULL)
{
DestroyWindow();
}
m_Site.Release();
}
if (pUnkSite == NULL)
{
return S_OK;
}
// get window handle of parent
hr = pUnkSite->QueryInterface(IID_PPV_ARG(IUnknown, &m_Site));
if (FAILED(hr))
return hr;
return _CreateDeskBarWindow();
return S_OK;
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::GetSite(REFIID riid, void **ppvSite)
@ -822,7 +770,7 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::Popup(POINTL *ppt, RECTL *prcExclude, MP
int cx = rc.right;
int cy = rc.bottom;
this->SetWindowPos(NULL, x, y, cx, cy, SWP_SHOWWINDOW);
this->SetWindowPos(HWND_TOPMOST, x, y, cx, cy, SWP_SHOWWINDOW);
// HACK: The bar needs to be notified of the size AFTER it is shown.
// Quick & dirty way of getting it done.