Commit 821aae4f authored by Andrey Turkin's avatar Andrey Turkin Committed by Alexandre Julliard

atl: Implement AtlAxCreateControl and AtlAxCreateControlEx.

parent b7ec4de7
...@@ -4,7 +4,7 @@ SRCDIR = @srcdir@ ...@@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
MODULE = atl.dll MODULE = atl.dll
IMPORTLIB = libatl.$(IMPLIBEXT) IMPORTLIB = libatl.$(IMPLIBEXT)
IMPORTS = ole32 shlwapi user32 gdi32 advapi32 kernel32 IMPORTS = ole32 oleaut32 shlwapi user32 gdi32 advapi32 kernel32
EXTRALIBS = -luuid EXTRALIBS = -luuid
C_SRCS = \ C_SRCS = \
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
37 stub AtlAxCreateDialogW 37 stub AtlAxCreateDialogW
38 stub AtlAxCreateDialogA 38 stub AtlAxCreateDialogA
39 stdcall AtlAxCreateControl(ptr ptr ptr ptr) 39 stdcall AtlAxCreateControl(ptr ptr ptr ptr)
40 stub AtlAxCreateControlEx 40 stdcall AtlAxCreateControlEx(ptr ptr ptr ptr ptr ptr ptr)
41 stub AtlAxAttachControl 41 stub AtlAxAttachControl
42 stdcall AtlAxWinInit() 42 stdcall AtlAxWinInit()
43 stdcall AtlModuleAddCreateWndData(ptr ptr ptr) 43 stdcall AtlModuleAddCreateWndData(ptr ptr ptr)
......
...@@ -53,7 +53,7 @@ LRESULT static CALLBACK AtlAxWin_wndproc( HWND hWnd, UINT wMsg, WPARAM wParam, L ...@@ -53,7 +53,7 @@ LRESULT static CALLBACK AtlAxWin_wndproc( HWND hWnd, UINT wMsg, WPARAM wParam, L
if (!ptr) if (!ptr)
return 1; return 1;
GetWindowTextW( hWnd, ptr, len ); GetWindowTextW( hWnd, ptr, len );
AtlAxCreateControl( ptr, hWnd, NULL, NULL ); AtlAxCreateControlEx( ptr, hWnd, NULL, NULL, NULL, NULL, NULL );
HeapFree( GetProcessHeap(), 0, ptr ); HeapFree( GetProcessHeap(), 0, ptr );
return 0; return 0;
} }
...@@ -97,3 +97,127 @@ BOOL WINAPI AtlAxWinInit(void) ...@@ -97,3 +97,127 @@ BOOL WINAPI AtlAxWinInit(void)
return TRUE; 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;
}
...@@ -347,16 +347,6 @@ HRESULT WINAPI AtlModuleUnregisterServer(_ATL_MODULEW *pm, const CLSID *clsid) ...@@ -347,16 +347,6 @@ HRESULT WINAPI AtlModuleUnregisterServer(_ATL_MODULEW *pm, const CLSID *clsid)
} }
/*********************************************************************** /***********************************************************************
* 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.@] * AtlModuleRegisterWndClassInfoW [ATL.@]
* *
* PARAMS * PARAMS
......
...@@ -142,7 +142,9 @@ struct _ATL_REGMAP_ENTRY ...@@ -142,7 +142,9 @@ struct _ATL_REGMAP_ENTRY
}; };
HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID * iid, LPDWORD dpw); 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 AtlAxCreateControl(LPCOLESTR,HWND,IStream*,IUnknown**);
HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR,HWND,IStream*,IUnknown**,IUnknown**,REFIID,IUnknown*);
HRESULT WINAPI AtlFreeMarshalStream(IStream *pStream); HRESULT WINAPI AtlFreeMarshalStream(IStream *pStream);
HRESULT WINAPI AtlInternalQueryInterface(LPVOID pThis, const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, LPVOID* ppvObject); HRESULT WINAPI AtlInternalQueryInterface(LPVOID pThis, const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, LPVOID* ppvObject);
HRESULT WINAPI AtlMarshalPtrInProc(IUnknown *pUnk, const IID *iid, IStream **ppStream); HRESULT WINAPI AtlMarshalPtrInProc(IUnknown *pUnk, const IID *iid, IStream **ppStream);
......
...@@ -71,4 +71,5 @@ interface IRegistrar : IUnknown ...@@ -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("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 AtlAxCreateControl(LPCOLESTR,HWND,IStream*,IUnknown**);")
cpp_quote("HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR,HWND,IStream*,IUnknown**,IUnknown**,REFIID,IUnknown*);")
cpp_quote("BOOL WINAPI AtlAxWinInit(void);") cpp_quote("BOOL WINAPI AtlAxWinInit(void);")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment