diff --git a/base/shell/rshell/CMenuBand.cpp b/base/shell/rshell/CMenuBand.cpp index 49c3c67d129..ffa10829bb0 100644 --- a/base/shell/rshell/CMenuBand.cpp +++ b/base/shell/rshell/CMenuBand.cpp @@ -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; diff --git a/base/shell/rshell/CMenuDeskBar.cpp b/base/shell/rshell/CMenuDeskBar.cpp index 6c5c1657edb..d00dc90f02d 100644 --- a/base/shell/rshell/CMenuDeskBar.cpp +++ b/base/shell/rshell/CMenuDeskBar.cpp @@ -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 oleWindow; - - hr = m_Site->QueryInterface(IID_IOleWindow, reinterpret_cast(&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(&m_Client)); @@ -623,30 +592,9 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::OnPosRectChangeDB(LPRECT prc) HRESULT STDMETHODCALLTYPE CMenuDeskBar::SetSite(IUnknown *pUnkSite) { - HRESULT hr; - CComPtr 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.