Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenbandproxy.cpp
Go to the documentation of this file.
00001 /* 00002 * ReactOS Explorer 00003 * 00004 * Copyright 2009 Andrew Hill <ash77 at domain reactos.org> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 00021 /* 00022 Used by the address band to dispatch navigation changes to the main browser object. 00023 00024 TODO: 00025 00026 */ 00027 #include "precomp.h" 00028 00029 CBandProxy::CBandProxy() 00030 { 00031 } 00032 00033 CBandProxy::~CBandProxy() 00034 { 00035 } 00036 00037 HRESULT CBandProxy::FindBrowserWindow(IUnknown **browser) 00038 { 00039 CComPtr<IServiceProvider> serviceProvider; 00040 CComPtr<IWebBrowser2> webBrowser; 00041 HRESULT hResult; 00042 00043 if (browser == NULL) 00044 return E_POINTER; 00045 hResult = fSite->QueryInterface(IID_IServiceProvider, (void **)&serviceProvider); 00046 if (FAILED (hResult)) 00047 return hResult; 00048 hResult = serviceProvider->QueryService(SID_IWebBrowserApp, IID_IWebBrowser2, (void **)&webBrowser); 00049 if (FAILED (hResult)) 00050 return hResult; 00051 *browser = webBrowser.Detach(); 00052 return S_OK; 00053 } 00054 00055 HRESULT STDMETHODCALLTYPE CBandProxy::SetSite(IUnknown *paramC) 00056 { 00057 fSite = paramC; 00058 return S_OK; 00059 } 00060 00061 HRESULT STDMETHODCALLTYPE CBandProxy::CreateNewWindow(long paramC) 00062 { 00063 return E_NOTIMPL; 00064 } 00065 00066 HRESULT STDMETHODCALLTYPE CBandProxy::GetBrowserWindow(IUnknown **paramC) 00067 { 00068 if (paramC == NULL) 00069 return E_POINTER; 00070 return FindBrowserWindow(paramC); 00071 } 00072 00073 HRESULT STDMETHODCALLTYPE CBandProxy::IsConnected() 00074 { 00075 CComPtr<IUnknown> webBrowser; 00076 HRESULT hResult; 00077 00078 hResult = FindBrowserWindow(&webBrowser); 00079 if (FAILED (hResult) || webBrowser.p == NULL) 00080 return S_FALSE; 00081 return S_OK; 00082 } 00083 00084 HRESULT STDMETHODCALLTYPE CBandProxy::NavigateToPIDL(LPCITEMIDLIST pidl) 00085 { 00086 CComPtr<IOleWindow> oleWindow; 00087 CComPtr<IServiceProvider> serviceProvider; 00088 CComPtr<IUnknown> webBrowserUnknown; 00089 CComPtr<IWebBrowser2> webBrowser; 00090 HWND browserWindow; 00091 CComVariant args; 00092 CComVariant emptyVariant; 00093 unsigned int arraySize; 00094 HRESULT hResult; 00095 00096 hResult = FindBrowserWindow(&webBrowserUnknown); 00097 if (FAILED (hResult)) 00098 return hResult; 00099 hResult = webBrowserUnknown->QueryInterface(IID_IWebBrowserApp, (void **)&webBrowser); 00100 if (FAILED (hResult)) 00101 return hResult; 00102 hResult = webBrowser->put_Visible(TRUE); 00103 hResult = webBrowser->QueryInterface(IID_IServiceProvider, (void **)&serviceProvider); 00104 if (SUCCEEDED (hResult)) 00105 { 00106 hResult = serviceProvider->QueryService(SID_STopLevelBrowser, IID_IOleWindow, (void **)&oleWindow); 00107 if (SUCCEEDED (hResult)) 00108 { 00109 hResult = oleWindow->GetWindow(&browserWindow); 00110 if (IsIconic(browserWindow)) 00111 ShowWindow(browserWindow, SW_RESTORE); 00112 } 00113 } 00114 arraySize = ILGetSize(pidl); 00115 V_VT(&args) = VT_ARRAY | VT_UI1; 00116 V_ARRAY(&args) = SafeArrayCreateVector(VT_UI1, 0, arraySize); 00117 if (V_ARRAY(&args) == NULL) 00118 return E_OUTOFMEMORY; 00119 memcpy(V_ARRAY(&args)->pvData, pidl, arraySize); 00120 hResult = webBrowser->Navigate2(&args, &emptyVariant, &emptyVariant, &emptyVariant, &emptyVariant); 00121 if (FAILED (hResult)) 00122 return hResult; 00123 return S_OK; 00124 } 00125 00126 HRESULT STDMETHODCALLTYPE CBandProxy::NavigateToURL(long paramC, long param10) 00127 { 00128 return E_NOTIMPL; 00129 } 00130 00131 HRESULT CreateBandProxy(REFIID riid, void **ppv) 00132 { 00133 CComObject<CBandProxy> *theBandProxy; 00134 HRESULT hResult; 00135 00136 if (ppv == NULL) 00137 return E_POINTER; 00138 *ppv = NULL; 00139 ATLTRY (theBandProxy = new CComObject<CBandProxy>); 00140 if (theBandProxy == NULL) 00141 return E_OUTOFMEMORY; 00142 hResult = theBandProxy->QueryInterface (riid, (void **)ppv); 00143 if (FAILED (hResult)) 00144 { 00145 delete theBandProxy; 00146 return hResult; 00147 } 00148 return S_OK; 00149 } Generated on Sun May 27 2012 04:22:53 for ReactOS by
1.7.6.1
|