Andrey Turkin : atl: Implement AtlAxCreateControl and
AtlAxCreateControlEx.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Nov 2 15:48:00 CST 2006
Module: wine
Branch: master
Commit: 821aae4f9f182b79532d4fe16974acef0aed4649
URL: http://source.winehq.org/git/wine.git/?a=commit;h=821aae4f9f182b79532d4fe16974acef0aed4649
Author: Andrey Turkin <pancha at mail.nnov.ru>
Date: Mon Oct 30 21:20:26 2006 +0300
atl: Implement AtlAxCreateControl and AtlAxCreateControlEx.
---
dlls/atl/Makefile.in | 2 +-
dlls/atl/atl.spec | 2 +-
dlls/atl/atl_ax.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++++-
dlls/atl/atl_main.c | 10 ----
dlls/atl/atlbase.h | 2 +
dlls/atl/atliface.idl | 1 +
6 files changed, 130 insertions(+), 13 deletions(-)
diff --git a/dlls/atl/Makefile.in b/dlls/atl/Makefile.in
index 24a8d88..4331990 100644
--- a/dlls/atl/Makefile.in
+++ b/dlls/atl/Makefile.in
@@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = atl.dll
IMPORTLIB = libatl.$(IMPLIBEXT)
-IMPORTS = ole32 shlwapi user32 gdi32 advapi32 kernel32
+IMPORTS = ole32 oleaut32 shlwapi user32 gdi32 advapi32 kernel32
EXTRALIBS = -luuid
C_SRCS = \
diff --git a/dlls/atl/atl.spec b/dlls/atl/atl.spec
index a91cc84..db9ca9a 100644
--- a/dlls/atl/atl.spec
+++ b/dlls/atl/atl.spec
@@ -31,7 +31,7 @@
37 stub AtlAxCreateDialogW
38 stub AtlAxCreateDialogA
39 stdcall AtlAxCreateControl(ptr ptr ptr ptr)
-40 stub AtlAxCreateControlEx
+40 stdcall AtlAxCreateControlEx(ptr ptr ptr ptr ptr ptr ptr)
41 stub AtlAxAttachControl
42 stdcall AtlAxWinInit()
43 stdcall AtlModuleAddCreateWndData(ptr ptr ptr)
diff --git a/dlls/atl/atl_ax.c b/dlls/atl/atl_ax.c
index 660e001..1170cb8 100644
--- a/dlls/atl/atl_ax.c
+++ b/dlls/atl/atl_ax.c
@@ -53,7 +53,7 @@ LRESULT static CALLBACK AtlAxWin_wndproc
if (!ptr)
return 1;
GetWindowTextW( hWnd, ptr, len );
- AtlAxCreateControl( ptr, hWnd, NULL, NULL );
+ AtlAxCreateControlEx( ptr, hWnd, NULL, NULL, NULL, NULL, NULL );
HeapFree( GetProcessHeap(), 0, ptr );
return 0;
}
@@ -97,3 +97,127 @@ BOOL WINAPI AtlAxWinInit(void)
return TRUE;
}
+
+/***********************************************************************
+ * AtlAxCreateControl [ATL.@]
+ */
+HRESULT WINAPI AtlAxCreateControl(LPCOLESTR lpszName, HWND hWnd,
+ IStream *pStream, IUnknown **ppUnkContainer)
+{
+ return AtlAxCreateControlEx( lpszName, hWnd, pStream, ppUnkContainer,
+ NULL, NULL, NULL );
+}
+
+/***********************************************************************
+ * AtlAxCreateControlEx [ATL.@]
+ *
+ * REMARKS
+ * See http://www.codeproject.com/com/cwebpage.asp for some background
+ *
+ */
+HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR lpszName, HWND hWnd,
+ IStream *pStream, IUnknown **ppUnkContainer, IUnknown **ppUnkControl,
+ REFIID iidSink, IUnknown *punkSink)
+{
+ CLSID controlId;
+ HRESULT hRes;
+ IOleObject *pControl;
+ IUnknown *pUnkControl;
+ IPersistStreamInit *pPSInit;
+ IUnknown *pContainer;
+ enum {IsGUID=0,IsHTML=1,IsURL=2} content;
+
+ TRACE("(%s %p %p %p %p %p %p)\n", debugstr_w(lpszName), hWnd, pStream,
+ ppUnkContainer, ppUnkControl, iidSink, punkSink);
+
+ hRes = CLSIDFromString( (LPOLESTR) lpszName, &controlId );
+ if ( FAILED(hRes) )
+ hRes = CLSIDFromProgID( lpszName, &controlId );
+ if ( SUCCEEDED( hRes ) )
+ content = IsGUID;
+ else {
+ /* FIXME - check for MSHTML: prefix! */
+ content = IsURL;
+ memcpy( &controlId, &CLSID_WebBrowser, sizeof(controlId) );
+ }
+
+ hRes = CoCreateInstance( &controlId, 0, CLSCTX_ALL, &IID_IOleObject,
+ (void**) &pControl );
+ if ( FAILED( hRes ) )
+ {
+ WARN( "cannot create ActiveX control %s instance - error 0x%08x\n",
+ debugstr_guid( &controlId ), hRes );
+ return hRes;
+ }
+
+ hRes = IOleObject_QueryInterface( pControl, &IID_IPersistStreamInit, (void**) &pPSInit );
+ if ( SUCCEEDED( hRes ) )
+ {
+ if (!pStream)
+ IPersistStreamInit_InitNew( pPSInit );
+ else
+ IPersistStreamInit_Load( pPSInit, pStream );
+ IPersistStreamInit_Release( pPSInit );
+ } else
+ WARN("cannot get IID_IPersistStreamInit out of control\n");
+
+ IOleObject_QueryInterface( pControl, &IID_IUnknown, (void**) &pUnkControl );
+ IOleObject_Release( pControl );
+
+
+ hRes = AtlAxAttachControl( pUnkControl, hWnd, &pContainer );
+ if ( FAILED( hRes ) )
+ WARN("cannot attach control to window\n");
+
+ if ( content == IsURL )
+ {
+ IWebBrowser2 *browser;
+
+ hRes = IOleObject_QueryInterface( pControl, &IID_IWebBrowser2, (void**) &browser );
+ if ( !browser )
+ WARN( "Cannot query IWebBrowser2 interface: %08x\n", hRes );
+ else {
+ VARIANT url;
+
+ IWebBrowser2_put_Visible( browser, VARIANT_TRUE ); /* it seems that native does this on URL (but do not on MSHTML:! why? */
+
+ V_VT(&url) = VT_BSTR;
+ V_BSTR(&url) = SysAllocString( lpszName );
+
+ hRes = IWebBrowser2_Navigate2( browser, &url, NULL, NULL, NULL, NULL );
+ if ( FAILED( hRes ) )
+ WARN( "IWebBrowser2::Navigate2 failed: %08x\n", hRes );
+ SysFreeString( V_BSTR(&url) );
+
+ IWebBrowser2_Release( browser );
+ }
+ }
+
+ if (ppUnkContainer)
+ {
+ *ppUnkContainer = pContainer;
+ if ( pContainer )
+ IUnknown_AddRef( pContainer );
+ }
+ if (ppUnkControl)
+ {
+ *ppUnkControl = pUnkControl;
+ if ( pUnkControl )
+ IUnknown_AddRef( pUnkControl );
+ }
+
+ IUnknown_Release( pUnkControl );
+ if ( pContainer )
+ IUnknown_Release( pContainer );
+
+ return S_OK;
+}
+
+/***********************************************************************
+ * AtlAxAttachControl [ATL.@]
+ */
+HRESULT WINAPI AtlAxAttachControl(IUnknown* pControl, HWND hWnd, IUnknown** ppUnkContainer)
+{
+ FIXME( "(%p %p %p) - stub\n", pControl, hWnd, ppUnkContainer );
+ return E_NOTIMPL;
+}
diff --git a/dlls/atl/atl_main.c b/dlls/atl/atl_main.c
index 0d2c67e..547a5cf 100644
--- a/dlls/atl/atl_main.c
+++ b/dlls/atl/atl_main.c
@@ -347,16 +347,6 @@ HRESULT WINAPI AtlModuleUnregisterServer
}
/***********************************************************************
- * AtlAxCreateControl [ATL.@]
- */
-HRESULT WINAPI AtlAxCreateControl(LPCOLESTR lpszName, HWND hWnd,
- IStream *pStream, IUnknown **ppUnkContainer)
-{
- FIXME("%s %p %p %p)\n", debugstr_w(lpszName), hWnd, pStream, ppUnkContainer);
- return E_NOTIMPL;
-}
-
-/***********************************************************************
* AtlModuleRegisterWndClassInfoW [ATL.@]
*
* PARAMS
diff --git a/dlls/atl/atlbase.h b/dlls/atl/atlbase.h
index 218db5e..c0a556f 100644
--- a/dlls/atl/atlbase.h
+++ b/dlls/atl/atlbase.h
@@ -142,7 +142,9 @@ struct _ATL_REGMAP_ENTRY
};
HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID * iid, LPDWORD dpw);
+HRESULT WINAPI AtlAxAttachControl(IUnknown*,HWND,IUnknown**);
HRESULT WINAPI AtlAxCreateControl(LPCOLESTR,HWND,IStream*,IUnknown**);
+HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR,HWND,IStream*,IUnknown**,IUnknown**,REFIID,IUnknown*);
HRESULT WINAPI AtlFreeMarshalStream(IStream *pStream);
HRESULT WINAPI AtlInternalQueryInterface(LPVOID pThis, const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, LPVOID* ppvObject);
HRESULT WINAPI AtlMarshalPtrInProc(IUnknown *pUnk, const IID *iid, IStream **ppStream);
diff --git a/dlls/atl/atliface.idl b/dlls/atl/atliface.idl
index af01ee0..884d187 100644
--- a/dlls/atl/atliface.idl
+++ b/dlls/atl/atliface.idl
@@ -71,4 +71,5 @@ interface IRegistrar : IUnknown
cpp_quote("DEFINE_GUID(CLSID_ATLRegistrar,0x44ec053a,0x400f,0x11d0,0x9d,0xcd,0x00,0xa0,0xc9,0x03,0x91,0xd3);")
cpp_quote("HRESULT WINAPI AtlAxCreateControl(LPCOLESTR,HWND,IStream*,IUnknown**);")
+cpp_quote("HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR,HWND,IStream*,IUnknown**,IUnknown**,REFIID,IUnknown*);")
cpp_quote("BOOL WINAPI AtlAxWinInit(void);")
More information about the wine-cvs
mailing list