X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=reactos%2Fdll%2Fwin32%2Fshell32%2Fshellmenu%2FCMenuFocusManager.cpp;h=4301f90f2bea965373271fb1d0805437f847c67f;hp=73b7721d25ec258abdd3e2887036acc92bbb5c16;hb=4436c96a25b739d487f1f75ff0f08b2dd4c79b58;hpb=ed56601be6f70918e2c3467fd3f77641dece5bba diff --git a/reactos/dll/win32/shell32/shellmenu/CMenuFocusManager.cpp b/reactos/dll/win32/shell32/shellmenu/CMenuFocusManager.cpp index 73b7721d25e..4301f90f2be 100644 --- a/reactos/dll/win32/shell32/shellmenu/CMenuFocusManager.cpp +++ b/reactos/dll/win32/shell32/shellmenu/CMenuFocusManager.cpp @@ -814,14 +814,22 @@ HRESULT CMenuFocusManager::UpdateFocus() CComPtr bandSite; CComPtr deskBar; hr = topMenu->mb->GetSite(IID_PPV_ARG(IServiceProvider, &bandSite)); + if (FAILED(hr)) + goto NoCapture; hr = bandSite->QueryService(SID_SMenuPopup, IID_PPV_ARG(IOleWindow, &deskBar)); + if (FAILED(hr)) + goto NoCapture; CComPtr deskBarSite; hr = IUnknown_GetSite(deskBar, IID_PPV_ARG(IOleWindow, &deskBarSite)); + if (FAILED(hr)) + goto NoCapture; // FIXME: Find the correct place for this HWND hWndOwner; - deskBarSite->GetWindow(&hWndOwner); + hr = deskBarSite->GetWindow(&hWndOwner); + if (FAILED(hr)) + goto NoCapture; m_PreviousForeground = ::GetForegroundWindow(); if (m_PreviousForeground != hWndOwner) @@ -832,9 +840,11 @@ HRESULT CMenuFocusManager::UpdateFocus() // Get the HWND of the top-level window HWND hWndSite; hr = deskBar->GetWindow(&hWndSite); + if (FAILED(hr)) + goto NoCapture; SetMenuCapture(hWndSite); - } +NoCapture: if (!m_parent || m_parent->type == MenuBarEntry) {