shell32: Standardize the COM usage in ebrowser.c.

This commit is contained in:
David Hedberg 2010-12-22 02:20:47 +01:00 committed by Alexandre Julliard
parent 3e10d4e90d
commit 239a88e1e4
1 changed files with 44 additions and 38 deletions

View File

@ -53,11 +53,11 @@ typedef struct _travellog_entry {
} travellog_entry; } travellog_entry;
typedef struct _ExplorerBrowserImpl { typedef struct _ExplorerBrowserImpl {
const IExplorerBrowserVtbl *lpVtbl; IExplorerBrowser IExplorerBrowser_iface;
const IShellBrowserVtbl *lpsbVtbl; IShellBrowser IShellBrowser_iface;
const ICommDlgBrowser3Vtbl *lpcdb3Vtbl; ICommDlgBrowser3 ICommDlgBrowser3_iface;
const IObjectWithSiteVtbl *lpowsVtbl; IObjectWithSite IObjectWithSite_iface;
const INameSpaceTreeControlEventsVtbl *lpnstceVtbl; INameSpaceTreeControlEvents INameSpaceTreeControlEvents_iface;
LONG ref; LONG ref;
BOOL destroyed; BOOL destroyed;
@ -357,7 +357,7 @@ static HRESULT change_viewmode(ExplorerBrowserImpl *This, UINT viewmode)
static HRESULT create_new_shellview(ExplorerBrowserImpl *This, IShellItem *psi) static HRESULT create_new_shellview(ExplorerBrowserImpl *This, IShellItem *psi)
{ {
IShellBrowser *psb = (IShellBrowser*)&This->lpsbVtbl; IShellBrowser *psb = &This->IShellBrowser_iface;
IShellFolder *psf; IShellFolder *psf;
IShellView *psv; IShellView *psv;
HWND hwnd_new; HWND hwnd_new;
@ -597,7 +597,7 @@ static LRESULT navpane_on_wm_create(HWND hwnd, CREATESTRUCTW *crs)
else else
ERR("QueryInterface(IOleWindow) failed (0x%08x)\n", hr); ERR("QueryInterface(IOleWindow) failed (0x%08x)\n", hr);
pnstce = (INameSpaceTreeControlEvents *)&This->lpnstceVtbl; pnstce = &This->INameSpaceTreeControlEvents_iface;
hr = INameSpaceTreeControl2_TreeAdvise(pnstc2, (IUnknown*)pnstce, &cookie); hr = INameSpaceTreeControl2_TreeAdvise(pnstc2, (IUnknown*)pnstce, &cookie);
if(FAILED(hr)) if(FAILED(hr))
ERR("TreeAdvise failed. (0x%08x).\n", hr); ERR("TreeAdvise failed. (0x%08x).\n", hr);
@ -758,10 +758,16 @@ static LRESULT CALLBACK main_wndproc(HWND hWnd, UINT uMessage, WPARAM wParam, LP
/************************************************************************** /**************************************************************************
* IExplorerBrowser Implementation * IExplorerBrowser Implementation
*/ */
static inline ExplorerBrowserImpl *impl_from_IExplorerBrowser(IExplorerBrowser *iface)
{
return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IExplorerBrowser_iface);
}
static HRESULT WINAPI IExplorerBrowser_fnQueryInterface(IExplorerBrowser *iface, static HRESULT WINAPI IExplorerBrowser_fnQueryInterface(IExplorerBrowser *iface,
REFIID riid, void **ppvObject) REFIID riid, void **ppvObject)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvObject); TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvObject);
*ppvObject = NULL; *ppvObject = NULL;
@ -772,17 +778,17 @@ static HRESULT WINAPI IExplorerBrowser_fnQueryInterface(IExplorerBrowser *iface,
} }
else if(IsEqualIID(riid, &IID_IShellBrowser)) else if(IsEqualIID(riid, &IID_IShellBrowser))
{ {
*ppvObject = &This->lpsbVtbl; *ppvObject = &This->IShellBrowser_iface;
} }
else if(IsEqualIID(riid, &IID_ICommDlgBrowser) || else if(IsEqualIID(riid, &IID_ICommDlgBrowser) ||
IsEqualIID(riid, &IID_ICommDlgBrowser2) || IsEqualIID(riid, &IID_ICommDlgBrowser2) ||
IsEqualIID(riid, &IID_ICommDlgBrowser3)) IsEqualIID(riid, &IID_ICommDlgBrowser3))
{ {
*ppvObject = &This->lpcdb3Vtbl; *ppvObject = &This->ICommDlgBrowser3_iface;
} }
else if(IsEqualIID(riid, &IID_IObjectWithSite)) else if(IsEqualIID(riid, &IID_IObjectWithSite))
{ {
*ppvObject = &This->lpowsVtbl; *ppvObject = &This->IObjectWithSite_iface;
} }
if(*ppvObject) if(*ppvObject)
@ -796,7 +802,7 @@ static HRESULT WINAPI IExplorerBrowser_fnQueryInterface(IExplorerBrowser *iface,
static ULONG WINAPI IExplorerBrowser_fnAddRef(IExplorerBrowser *iface) static ULONG WINAPI IExplorerBrowser_fnAddRef(IExplorerBrowser *iface)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
LONG ref = InterlockedIncrement(&This->ref); LONG ref = InterlockedIncrement(&This->ref);
TRACE("%p - ref %d\n", This, ref); TRACE("%p - ref %d\n", This, ref);
@ -805,7 +811,7 @@ static ULONG WINAPI IExplorerBrowser_fnAddRef(IExplorerBrowser *iface)
static ULONG WINAPI IExplorerBrowser_fnRelease(IExplorerBrowser *iface) static ULONG WINAPI IExplorerBrowser_fnRelease(IExplorerBrowser *iface)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
LONG ref = InterlockedDecrement(&This->ref); LONG ref = InterlockedDecrement(&This->ref);
TRACE("%p - ref %d\n", This, ref); TRACE("%p - ref %d\n", This, ref);
@ -816,7 +822,7 @@ static ULONG WINAPI IExplorerBrowser_fnRelease(IExplorerBrowser *iface)
if(!This->destroyed) if(!This->destroyed)
IExplorerBrowser_Destroy(iface); IExplorerBrowser_Destroy(iface);
IObjectWithSite_SetSite((IObjectWithSite*)&This->lpowsVtbl, NULL); IObjectWithSite_SetSite(&This->IObjectWithSite_iface, NULL);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
return 0; return 0;
@ -829,7 +835,7 @@ static HRESULT WINAPI IExplorerBrowser_fnInitialize(IExplorerBrowser *iface,
HWND hwndParent, const RECT *prc, HWND hwndParent, const RECT *prc,
const FOLDERSETTINGS *pfs) const FOLDERSETTINGS *pfs)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
WNDCLASSW wc; WNDCLASSW wc;
LONG style; LONG style;
static const WCHAR EB_CLASS_NAME[] = static const WCHAR EB_CLASS_NAME[] =
@ -879,7 +885,7 @@ static HRESULT WINAPI IExplorerBrowser_fnInitialize(IExplorerBrowser *iface,
static HRESULT WINAPI IExplorerBrowser_fnDestroy(IExplorerBrowser *iface) static HRESULT WINAPI IExplorerBrowser_fnDestroy(IExplorerBrowser *iface)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
TRACE("%p\n", This); TRACE("%p\n", This);
if(This->psv) if(This->psv)
@ -905,7 +911,7 @@ static HRESULT WINAPI IExplorerBrowser_fnDestroy(IExplorerBrowser *iface)
static HRESULT WINAPI IExplorerBrowser_fnSetRect(IExplorerBrowser *iface, static HRESULT WINAPI IExplorerBrowser_fnSetRect(IExplorerBrowser *iface,
HDWP *phdwp, RECT rcBrowser) HDWP *phdwp, RECT rcBrowser)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
TRACE("%p (%p, %s)\n", This, phdwp, wine_dbgstr_rect(&rcBrowser)); TRACE("%p (%p, %s)\n", This, phdwp, wine_dbgstr_rect(&rcBrowser));
if(phdwp && *phdwp) if(phdwp && *phdwp)
@ -928,7 +934,7 @@ static HRESULT WINAPI IExplorerBrowser_fnSetRect(IExplorerBrowser *iface,
static HRESULT WINAPI IExplorerBrowser_fnSetPropertyBag(IExplorerBrowser *iface, static HRESULT WINAPI IExplorerBrowser_fnSetPropertyBag(IExplorerBrowser *iface,
LPCWSTR pszPropertyBag) LPCWSTR pszPropertyBag)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
FIXME("stub, %p (%s)\n", This, debugstr_w(pszPropertyBag)); FIXME("stub, %p (%s)\n", This, debugstr_w(pszPropertyBag));
if(!pszPropertyBag) if(!pszPropertyBag)
@ -945,7 +951,7 @@ static HRESULT WINAPI IExplorerBrowser_fnSetPropertyBag(IExplorerBrowser *iface,
static HRESULT WINAPI IExplorerBrowser_fnSetEmptyText(IExplorerBrowser *iface, static HRESULT WINAPI IExplorerBrowser_fnSetEmptyText(IExplorerBrowser *iface,
LPCWSTR pszEmptyText) LPCWSTR pszEmptyText)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
FIXME("stub, %p (%s)\n", This, debugstr_w(pszEmptyText)); FIXME("stub, %p (%s)\n", This, debugstr_w(pszEmptyText));
return E_NOTIMPL; return E_NOTIMPL;
@ -954,7 +960,7 @@ static HRESULT WINAPI IExplorerBrowser_fnSetEmptyText(IExplorerBrowser *iface,
static HRESULT WINAPI IExplorerBrowser_fnSetFolderSettings(IExplorerBrowser *iface, static HRESULT WINAPI IExplorerBrowser_fnSetFolderSettings(IExplorerBrowser *iface,
const FOLDERSETTINGS *pfs) const FOLDERSETTINGS *pfs)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
TRACE("%p (%p)\n", This, pfs); TRACE("%p (%p)\n", This, pfs);
if(!pfs) if(!pfs)
@ -971,7 +977,7 @@ static HRESULT WINAPI IExplorerBrowser_fnAdvise(IExplorerBrowser *iface,
IExplorerBrowserEvents *psbe, IExplorerBrowserEvents *psbe,
DWORD *pdwCookie) DWORD *pdwCookie)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
event_client *client; event_client *client;
TRACE("%p (%p, %p)\n", This, psbe, pdwCookie); TRACE("%p (%p, %p)\n", This, psbe, pdwCookie);
@ -990,7 +996,7 @@ static HRESULT WINAPI IExplorerBrowser_fnAdvise(IExplorerBrowser *iface,
static HRESULT WINAPI IExplorerBrowser_fnUnadvise(IExplorerBrowser *iface, static HRESULT WINAPI IExplorerBrowser_fnUnadvise(IExplorerBrowser *iface,
DWORD dwCookie) DWORD dwCookie)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
event_client *client; event_client *client;
TRACE("%p (0x%x)\n", This, dwCookie); TRACE("%p (0x%x)\n", This, dwCookie);
@ -1011,7 +1017,7 @@ static HRESULT WINAPI IExplorerBrowser_fnUnadvise(IExplorerBrowser *iface,
static HRESULT WINAPI IExplorerBrowser_fnSetOptions(IExplorerBrowser *iface, static HRESULT WINAPI IExplorerBrowser_fnSetOptions(IExplorerBrowser *iface,
EXPLORER_BROWSER_OPTIONS dwFlag) EXPLORER_BROWSER_OPTIONS dwFlag)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
static const EXPLORER_BROWSER_OPTIONS unsupported_options = static const EXPLORER_BROWSER_OPTIONS unsupported_options =
EBO_ALWAYSNAVIGATE | EBO_NOWRAPPERWINDOW | EBO_HTMLSHAREPOINTVIEW; EBO_ALWAYSNAVIGATE | EBO_NOWRAPPERWINDOW | EBO_HTMLSHAREPOINTVIEW;
@ -1028,7 +1034,7 @@ static HRESULT WINAPI IExplorerBrowser_fnSetOptions(IExplorerBrowser *iface,
static HRESULT WINAPI IExplorerBrowser_fnGetOptions(IExplorerBrowser *iface, static HRESULT WINAPI IExplorerBrowser_fnGetOptions(IExplorerBrowser *iface,
EXPLORER_BROWSER_OPTIONS *pdwFlag) EXPLORER_BROWSER_OPTIONS *pdwFlag)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
TRACE("%p (%p)\n", This, pdwFlag); TRACE("%p (%p)\n", This, pdwFlag);
*pdwFlag = This->eb_options; *pdwFlag = This->eb_options;
@ -1040,7 +1046,7 @@ static HRESULT WINAPI IExplorerBrowser_fnBrowseToIDList(IExplorerBrowser *iface,
PCUIDLIST_RELATIVE pidl, PCUIDLIST_RELATIVE pidl,
UINT uFlags) UINT uFlags)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
LPITEMIDLIST absolute_pidl = NULL; LPITEMIDLIST absolute_pidl = NULL;
HRESULT hr; HRESULT hr;
static const UINT unsupported_browse_flags = static const UINT unsupported_browse_flags =
@ -1190,7 +1196,7 @@ static HRESULT WINAPI IExplorerBrowser_fnBrowseToIDList(IExplorerBrowser *iface,
static HRESULT WINAPI IExplorerBrowser_fnBrowseToObject(IExplorerBrowser *iface, static HRESULT WINAPI IExplorerBrowser_fnBrowseToObject(IExplorerBrowser *iface,
IUnknown *punk, UINT uFlags) IUnknown *punk, UINT uFlags)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
LPITEMIDLIST pidl; LPITEMIDLIST pidl;
HRESULT hr; HRESULT hr;
TRACE("%p (%p, 0x%x)\n", This, punk, uFlags); TRACE("%p (%p, 0x%x)\n", This, punk, uFlags);
@ -1212,7 +1218,7 @@ static HRESULT WINAPI IExplorerBrowser_fnFillFromObject(IExplorerBrowser *iface,
IUnknown *punk, IUnknown *punk,
EXPLORER_BROWSER_FILL_FLAGS dwFlags) EXPLORER_BROWSER_FILL_FLAGS dwFlags)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
FIXME("stub, %p (%p, 0x%x)\n", This, punk, dwFlags); FIXME("stub, %p (%p, 0x%x)\n", This, punk, dwFlags);
return E_NOTIMPL; return E_NOTIMPL;
@ -1220,7 +1226,7 @@ static HRESULT WINAPI IExplorerBrowser_fnFillFromObject(IExplorerBrowser *iface,
static HRESULT WINAPI IExplorerBrowser_fnRemoveAll(IExplorerBrowser *iface) static HRESULT WINAPI IExplorerBrowser_fnRemoveAll(IExplorerBrowser *iface)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
FIXME("stub, %p\n", This); FIXME("stub, %p\n", This);
return E_NOTIMPL; return E_NOTIMPL;
@ -1229,7 +1235,7 @@ static HRESULT WINAPI IExplorerBrowser_fnRemoveAll(IExplorerBrowser *iface)
static HRESULT WINAPI IExplorerBrowser_fnGetCurrentView(IExplorerBrowser *iface, static HRESULT WINAPI IExplorerBrowser_fnGetCurrentView(IExplorerBrowser *iface,
REFIID riid, void **ppv) REFIID riid, void **ppv)
{ {
ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface; ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppv); TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppv);
if(!This->psv) if(!This->psv)
@ -1266,7 +1272,7 @@ static const IExplorerBrowserVtbl vt_IExplorerBrowser =
static inline ExplorerBrowserImpl *impl_from_IShellBrowser(IShellBrowser *iface) static inline ExplorerBrowserImpl *impl_from_IShellBrowser(IShellBrowser *iface)
{ {
return (ExplorerBrowserImpl *)((char*)iface - FIELD_OFFSET(ExplorerBrowserImpl, lpsbVtbl)); return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IShellBrowser_iface);
} }
static HRESULT WINAPI IShellBrowser_fnQueryInterface(IShellBrowser *iface, static HRESULT WINAPI IShellBrowser_fnQueryInterface(IShellBrowser *iface,
@ -1474,7 +1480,7 @@ static const IShellBrowserVtbl vt_IShellBrowser = {
static inline ExplorerBrowserImpl *impl_from_ICommDlgBrowser3(ICommDlgBrowser3 *iface) static inline ExplorerBrowserImpl *impl_from_ICommDlgBrowser3(ICommDlgBrowser3 *iface)
{ {
return (ExplorerBrowserImpl *)((char*)iface - FIELD_OFFSET(ExplorerBrowserImpl, lpcdb3Vtbl)); return CONTAINING_RECORD(iface, ExplorerBrowserImpl, ICommDlgBrowser3_iface);
} }
static HRESULT WINAPI ICommDlgBrowser3_fnQueryInterface(ICommDlgBrowser3 *iface, static HRESULT WINAPI ICommDlgBrowser3_fnQueryInterface(ICommDlgBrowser3 *iface,
@ -1669,7 +1675,7 @@ static const ICommDlgBrowser3Vtbl vt_ICommDlgBrowser3 = {
static inline ExplorerBrowserImpl *impl_from_IObjectWithSite(IObjectWithSite *iface) static inline ExplorerBrowserImpl *impl_from_IObjectWithSite(IObjectWithSite *iface)
{ {
return (ExplorerBrowserImpl *)((char*)iface - FIELD_OFFSET(ExplorerBrowserImpl, lpowsVtbl)); return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IObjectWithSite_iface);
} }
static HRESULT WINAPI IObjectWithSite_fnQueryInterface(IObjectWithSite *iface, static HRESULT WINAPI IObjectWithSite_fnQueryInterface(IObjectWithSite *iface,
@ -1738,7 +1744,7 @@ static const IObjectWithSiteVtbl vt_IObjectWithSite = {
*/ */
static inline ExplorerBrowserImpl *impl_from_INameSpaceTreeControlEvents(INameSpaceTreeControlEvents *iface) static inline ExplorerBrowserImpl *impl_from_INameSpaceTreeControlEvents(INameSpaceTreeControlEvents *iface)
{ {
return (ExplorerBrowserImpl *)((char*)iface - FIELD_OFFSET(ExplorerBrowserImpl, lpnstceVtbl)); return CONTAINING_RECORD(iface, ExplorerBrowserImpl, INameSpaceTreeControlEvents_iface);
} }
static HRESULT WINAPI NSTCEvents_fnQueryInterface(INameSpaceTreeControlEvents *iface, static HRESULT WINAPI NSTCEvents_fnQueryInterface(INameSpaceTreeControlEvents *iface,
@ -1979,11 +1985,11 @@ HRESULT WINAPI ExplorerBrowser_Constructor(IUnknown *pUnkOuter, REFIID riid, voi
eb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ExplorerBrowserImpl)); eb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ExplorerBrowserImpl));
eb->ref = 1; eb->ref = 1;
eb->lpVtbl = &vt_IExplorerBrowser; eb->IExplorerBrowser_iface.lpVtbl = &vt_IExplorerBrowser;
eb->lpsbVtbl = &vt_IShellBrowser; eb->IShellBrowser_iface.lpVtbl = &vt_IShellBrowser;
eb->lpcdb3Vtbl = &vt_ICommDlgBrowser3; eb->ICommDlgBrowser3_iface.lpVtbl = &vt_ICommDlgBrowser3;
eb->lpowsVtbl = &vt_IObjectWithSite; eb->IObjectWithSite_iface.lpVtbl = &vt_IObjectWithSite;
eb->lpnstceVtbl = &vt_INameSpaceTreeControlEvents; eb->INameSpaceTreeControlEvents_iface.lpVtbl = &vt_INameSpaceTreeControlEvents;
/* Default settings */ /* Default settings */
eb->navpane.width = 150; eb->navpane.width = 150;