atl: Improved content type handling of AtlAxCreateControlEx.

This commit is contained in:
Qian Hong 2015-01-16 16:09:36 +08:00 committed by Alexandre Julliard
parent 189ffc2e73
commit ec52a1f557
7 changed files with 65 additions and 22 deletions

View file

@ -1,6 +1,6 @@
MODULE = atl.dll MODULE = atl.dll
IMPORTLIB = atl IMPORTLIB = atl
IMPORTS = uuid oleaut32 ole32 user32 gdi32 advapi32 IMPORTS = uuid oleaut32 ole32 user32 gdi32 advapi32 shlwapi
EXTRADEFS = -D_ATL_VER=_ATL_VER_30 EXTRADEFS = -D_ATL_VER=_ATL_VER_30
C_SRCS = \ C_SRCS = \

View file

@ -35,6 +35,7 @@
#include "atlbase.h" #include "atlbase.h"
#include "atliface.h" #include "atliface.h"
#include "atlwin.h" #include "atlwin.h"
#include "shlwapi.h"
#include "wine/unicode.h" #include "wine/unicode.h"
@ -991,6 +992,48 @@ HRESULT WINAPI AtlAxCreateControl(LPCOLESTR lpszName, HWND hWnd,
NULL, NULL, NULL ); NULL, NULL, NULL );
} }
enum content
{
IsEmpty = 0,
IsGUID = 1,
IsHTML = 2,
IsURL = 3,
IsUnknown = 4
};
static enum content get_content_type(LPCOLESTR name, CLSID *control_id)
{
WCHAR new_urlW[MAX_PATH];
DWORD size = MAX_PATH;
WCHAR mshtml_prefixW[] = {'m','s','h','t','m','l',':','\0'};
if (!name || !name[0])
{
WARN("name %s\n", wine_dbgstr_w(name));
return IsEmpty;
}
if (CLSIDFromString(name, control_id) == S_OK ||
CLSIDFromProgID(name, control_id) == S_OK)
return IsGUID;
if (PathIsURLW (name) ||
UrlApplySchemeW(name, new_urlW, &size, URL_APPLY_GUESSSCHEME|URL_APPLY_GUESSFILE) == S_OK)
{
*control_id = CLSID_WebBrowser;
return IsURL;
}
if (!strncmpiW(name, mshtml_prefixW, 7))
{
FIXME("mshtml prefix not implemented\n");
*control_id = CLSID_WebBrowser;
return IsHTML;
}
return IsUnknown;
}
/*********************************************************************** /***********************************************************************
* AtlAxCreateControlEx [atl100.@] * AtlAxCreateControlEx [atl100.@]
* *
@ -1005,24 +1048,24 @@ HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR lpszName, HWND hWnd,
CLSID controlId; CLSID controlId;
HRESULT hRes; HRESULT hRes;
IOleObject *pControl; IOleObject *pControl;
IUnknown *pUnkControl; IUnknown *pUnkControl = NULL;
IPersistStreamInit *pPSInit; IPersistStreamInit *pPSInit;
IUnknown *pContainer; IUnknown *pContainer = NULL;
enum {IsGUID=0,IsHTML=1,IsURL=2} content; enum content content;
TRACE("(%s %p %p %p %p %p %p)\n", debugstr_w(lpszName), hWnd, pStream, TRACE("(%s %p %p %p %p %p %p)\n", debugstr_w(lpszName), hWnd, pStream,
ppUnkContainer, ppUnkControl, iidSink, punkSink); ppUnkContainer, ppUnkControl, iidSink, punkSink);
hRes = CLSIDFromString( lpszName, &controlId ); if (ppUnkContainer) *ppUnkContainer = NULL;
if ( FAILED(hRes) ) if (ppUnkControl) *ppUnkControl = NULL;
hRes = CLSIDFromProgID( lpszName, &controlId );
if ( SUCCEEDED( hRes ) ) content = get_content_type(lpszName, &controlId);
content = IsGUID;
else { if (content == IsEmpty)
/* FIXME - check for MSHTML: prefix! */ return S_OK;
content = IsURL;
controlId = CLSID_WebBrowser; if (content == IsUnknown)
} return CO_E_CLASSSTRING;
hRes = CoCreateInstance( &controlId, 0, CLSCTX_ALL, &IID_IOleObject, hRes = CoCreateInstance( &controlId, 0, CLSCTX_ALL, &IID_IOleObject,
(void**) &pControl ); (void**) &pControl );

View file

@ -1,6 +1,6 @@
MODULE = atl100.dll MODULE = atl100.dll
IMPORTLIB = atl100 IMPORTLIB = atl100
IMPORTS = uuid ole32 oleaut32 user32 gdi32 advapi32 IMPORTS = uuid ole32 oleaut32 user32 gdi32 advapi32 shlwapi
EXTRADEFS = -D_ATL_VER=_ATL_VER_100 EXTRADEFS = -D_ATL_VER=_ATL_VER_100
PARENTSRC = ../atl PARENTSRC = ../atl

View file

@ -643,8 +643,8 @@ static void test_ax_win(void)
ok(hwnd != NULL, "CreateWindow failed!\n"); ok(hwnd != NULL, "CreateWindow failed!\n");
control = (IUnknown *)0xdeadbeef; control = (IUnknown *)0xdeadbeef;
res = AtlAxGetControl(hwnd, &control); res = AtlAxGetControl(hwnd, &control);
todo_wine ok(res == E_FAIL, "Expected E_FAIL, returned %08x\n", res); ok(res == E_FAIL, "Expected E_FAIL, returned %08x\n", res);
todo_wine ok(!control, "returned %p\n", control); ok(!control, "returned %p\n", control);
if (control) IUnknown_Release(control); if (control) IUnknown_Release(control);
DestroyWindow(hwnd); DestroyWindow(hwnd);
@ -652,8 +652,8 @@ static void test_ax_win(void)
ok(hwnd != NULL, "CreateWindow failed!\n"); ok(hwnd != NULL, "CreateWindow failed!\n");
control = (IUnknown *)0xdeadbeef; control = (IUnknown *)0xdeadbeef;
res = AtlAxGetControl(hwnd, &control); res = AtlAxGetControl(hwnd, &control);
todo_wine ok(res == E_FAIL, "Expected E_FAIL, returned %08x\n", res); ok(res == E_FAIL, "Expected E_FAIL, returned %08x\n", res);
todo_wine ok(!control, "returned %p\n", control); ok(!control, "returned %p\n", control);
if (control) IUnknown_Release(control); if (control) IUnknown_Release(control);
DestroyWindow(hwnd); DestroyWindow(hwnd);

View file

@ -1,5 +1,5 @@
MODULE = atl110.dll MODULE = atl110.dll
IMPORTS = oleaut32 ole32 user32 gdi32 advapi32 uuid IMPORTS = oleaut32 ole32 user32 gdi32 advapi32 uuid shlwapi
EXTRADEFS = -D_ATL_VER=_ATL_VER_110 EXTRADEFS = -D_ATL_VER=_ATL_VER_110
PARENTSRC = ../atl PARENTSRC = ../atl

View file

@ -1,6 +1,6 @@
MODULE = atl80.dll MODULE = atl80.dll
IMPORTLIB = atl80 IMPORTLIB = atl80
IMPORTS = oleaut32 user32 ole32 gdi32 advapi32 uuid IMPORTS = oleaut32 user32 ole32 gdi32 advapi32 uuid shlwapi
EXTRADEFS = -D_ATL_VER=_ATL_VER_80 EXTRADEFS = -D_ATL_VER=_ATL_VER_80
PARENTSRC = ../atl PARENTSRC = ../atl

View file

@ -1,5 +1,5 @@
MODULE = atl90.dll MODULE = atl90.dll
IMPORTS = oleaut32 user32 ole32 gdi32 advapi32 uuid IMPORTS = oleaut32 user32 ole32 gdi32 advapi32 uuid shlwapi
EXTRADEFS = -D_ATL_VER=_ATL_VER_90 EXTRADEFS = -D_ATL_VER=_ATL_VER_90
PARENTSRC = ../atl PARENTSRC = ../atl