progman: Add close button and sysmenu to dialogs.
[wine/gsoc_dplay.git] / dlls / shdocvw / factory.c
blobb42c7d64832d7ec4ffc49b08f43593f0390e9a56
1 /*
2 * Implementation of class factory for IE Web Browser
4 * Copyright 2001 John R. Sheets (for CodeWeavers)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <string.h>
22 #include "wine/debug.h"
23 #include "shdocvw.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
27 /**********************************************************************
28 * Implement the WebBrowser class factory
30 * (Based on implementation in ddraw/main.c)
33 #define FACTORY(x) ((IClassFactory*) &(x)->lpClassFactoryVtbl)
35 typedef struct
37 /* IUnknown fields */
38 const IClassFactoryVtbl *lpClassFactoryVtbl;
39 HRESULT (*cf)(LPUNKNOWN, REFIID, LPVOID *);
40 LONG ref;
41 } IClassFactoryImpl;
44 /**********************************************************************
45 * WBCF_QueryInterface (IUnknown)
47 static HRESULT WINAPI WBCF_QueryInterface(LPCLASSFACTORY iface,
48 REFIID riid, LPVOID *ppobj)
50 TRACE("(%s %p)\n", debugstr_guid(riid), ppobj);
52 if (!ppobj)
53 return E_POINTER;
55 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
56 *ppobj = iface;
57 return S_OK;
60 WARN("Not supported interface %s\n", debugstr_guid(riid));
62 *ppobj = NULL;
63 return E_NOINTERFACE;
66 /************************************************************************
67 * WBCF_AddRef (IUnknown)
69 static ULONG WINAPI WBCF_AddRef(LPCLASSFACTORY iface)
71 SHDOCVW_LockModule();
73 return 2; /* non-heap based object */
76 /************************************************************************
77 * WBCF_Release (IUnknown)
79 static ULONG WINAPI WBCF_Release(LPCLASSFACTORY iface)
81 SHDOCVW_UnlockModule();
83 return 1; /* non-heap based object */
86 /************************************************************************
87 * WBCF_CreateInstance (IClassFactory)
89 static HRESULT WINAPI WBCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
90 REFIID riid, LPVOID *ppobj)
92 IClassFactoryImpl *This = (IClassFactoryImpl *) iface;
93 return This->cf(pOuter, riid, ppobj);
96 /************************************************************************
97 * WBCF_LockServer (IClassFactory)
99 static HRESULT WINAPI WBCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
101 TRACE("(%d)\n", dolock);
103 if (dolock)
104 SHDOCVW_LockModule();
105 else
106 SHDOCVW_UnlockModule();
108 return S_OK;
111 static const IClassFactoryVtbl WBCF_Vtbl =
113 WBCF_QueryInterface,
114 WBCF_AddRef,
115 WBCF_Release,
116 WBCF_CreateInstance,
117 WBCF_LockServer
120 /*************************************************************************
121 * DllGetClassObject (SHDOCVW.@)
123 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)
125 HRESULT hres;
127 static IClassFactoryImpl WBClassFactory = {&WBCF_Vtbl, WebBrowser_Create};
129 TRACE("\n");
131 if(IsEqualGUID(&CLSID_WebBrowser, rclsid)) {
132 hres = create_mozctl(riid, ppv);
133 if(SUCCEEDED(hres))
134 return hres;
135 return IClassFactory_QueryInterface(FACTORY(&WBClassFactory), riid, ppv);
138 /* As a last resort, figure if the CLSID belongs to a 'Shell Instance Object' */
139 return SHDOCVW_GetShellInstanceObjectClassObject(rclsid, riid, ppv);
142 HRESULT register_class_object(BOOL do_reg)
144 HRESULT hres;
146 static DWORD cookie;
147 static IClassFactoryImpl IEClassFactory = {&WBCF_Vtbl, InternetExplorer_Create};
149 if(do_reg) {
150 hres = CoRegisterClassObject(&CLSID_InternetExplorer, (IUnknown*)FACTORY(&IEClassFactory),
151 CLSCTX_SERVER, REGCLS_MULTIPLEUSE|REGCLS_SUSPENDED, &cookie);
152 if (FAILED(hres)) {
153 ERR("failed to register object %08lx\n", hres);
154 return hres;
157 hres = CoResumeClassObjects();
158 if(SUCCEEDED(hres))
159 return hres;
161 ERR("failed to resume object %08lx\n", hres);
164 return CoRevokeClassObject(cookie);