Sync to Wine-0_9_3:
Jacek Caban <jacek@codeweavers.com>
- Return S_OK in [On|Can]InPlaceActivate.
  Handle IOleDocumentSite in QueryInterface.
- Added IOleDocumentSite implementation.
- Sync the WebBrowser's window size with document's window.
- Sync window sizes.
- Use sink in navigate_complete instead of ClientSite's IDispatch.
- Added implementation of OLEIVERB_SHOW in DoVerb.
- Activate document object.
- Added IOleInPlaceActiveObject stub implementation.
- Added GetOverrideKeyPath and GetOptionKeyPath implementation.
- Added SetObjectRects implementation.
- Better windows handling.
- shdocvw: Added get_Document implementation.
- Added implementation of IConnectionPoint::Advise and Unadvise.
- Don't crash when parameters of Navigate2 are NULL.
- Added implementation of GetWindowContext.
  Added stub implementation of IOleInPlaceFrame interface.
Modified: trunk/reactos/include/wine/objidl.h
Modified: trunk/reactos/lib/shdocvw/client.c
Modified: trunk/reactos/lib/shdocvw/dochost.c
Modified: trunk/reactos/lib/shdocvw/events.c
Added: trunk/reactos/lib/shdocvw/frame.c
Modified: trunk/reactos/lib/shdocvw/oleobject.c
Modified: trunk/reactos/lib/shdocvw/shdocvw.h
Modified: trunk/reactos/lib/shdocvw/shdocvw.xml
Modified: trunk/reactos/lib/shdocvw/webbrowser.c
Modified: trunk/reactos/lib/uuid/uuid.c
Modified: trunk/reactos/w32api/include/exdispid.h
Added: trunk/reactos/w32api/include/hlink.h
Modified: trunk/reactos/w32api/include/objidl.h
Modified: trunk/reactos/w32api/include/oleidl.h

Modified: trunk/reactos/include/wine/objidl.h
--- trunk/reactos/include/wine/objidl.h	2005-12-14 19:41:46 UTC (rev 20169)
+++ trunk/reactos/include/wine/objidl.h	2005-12-14 19:42:38 UTC (rev 20170)
@@ -94,10 +94,6 @@
 	unsigned long cbData;
 	BYTE data[1];
 } RemSTGMEDIUM;
-typedef struct tagHLITEM {
-	ULONG uHLID;
-	LPWSTR pwzFriendlyName;
-} HLITEM;
 typedef struct tagSTATDATA {
 	FORMATETC formatetc;
 	DWORD grfAdvf;
@@ -430,7 +426,6 @@
 EXTERN_C const FMTID FMTID_UserDefinedProperties;
 
 DECLARE_ENUMERATOR(FORMATETC);
-DECLARE_ENUMERATOR(HLITEM);
 DECLARE_ENUMERATOR(STATDATA);
 DECLARE_ENUMERATOR(STATPROPSETSTG);
 DECLARE_ENUMERATOR(STATPROPSTG);

Modified: trunk/reactos/lib/shdocvw/client.c
--- trunk/reactos/lib/shdocvw/client.c	2005-12-14 19:41:46 UTC (rev 20169)
+++ trunk/reactos/lib/shdocvw/client.c	2005-12-14 19:42:38 UTC (rev 20170)
@@ -47,6 +47,9 @@
     }else if(IsEqualGUID(&IID_IDocHostUIHandler2, riid)) {
         TRACE("(%p)->(IID_IDocHostUIHandler2 %p)\n", This, ppv);
         *ppv = DOCHOSTUI2(This);
+    }else if(IsEqualGUID(&IID_IOleDocumentSite, riid)) {
+        TRACE("(%p)->(IID_IOleDocumentSite %p)\n", This, ppv);
+        *ppv = DOCSITE(This);
     }
 
     if(*ppv) {
@@ -168,15 +171,21 @@
 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
 {
     WebBrowser *This = INPLACESITE_THIS(iface);
-    FIXME("(%p)\n", This);
-    return E_NOTIMPL;
+
+    TRACE("(%p)\n", This);
+
+    /* Nothing to do here */
+    return S_OK;
 }
 
 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
 {
     WebBrowser *This = INPLACESITE_THIS(iface);
-    FIXME("(%p)\n", This);
-    return E_NOTIMPL;
+
+    TRACE("(%p)\n", This);
+
+    /* Nothing to do here */
+    return S_OK;
 }
 
 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
@@ -191,9 +200,23 @@
         LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
 {
     WebBrowser *This = INPLACESITE_THIS(iface);
-    FIXME("(%p)->(%p %p %p %p %p)\n", This, ppFrame, ppDoc, lprcPosRect,
+
+    TRACE("(%p)->(%p %p %p %p %p)\n", This, ppFrame, ppDoc, lprcPosRect,
           lprcClipRect, lpFrameInfo);
-    return E_NOTIMPL;
+
+    *ppFrame = INPLACEFRAME(This);
+    *ppDoc = NULL;
+
+    GetClientRect(This->doc_view_hwnd, lprcPosRect);
+    memcpy(lprcClipRect, lprcPosRect, sizeof(RECT));
+
+    lpFrameInfo->cb = sizeof(*lpFrameInfo);
+    lpFrameInfo->fMDIApp = FALSE;
+    lpFrameInfo->hwndFrame = This->shell_embedding_hwnd;
+    lpFrameInfo->haccel = NULL;
+    lpFrameInfo->cAccelEntries = 0; /* FIXME: should be 5 */
+
+    return S_OK;
 }
 
 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtent)
@@ -259,8 +282,72 @@
     InPlaceSite_OnPosRectChange
 };
 
+#define DOCSITE_THIS(iface) DEFINE_THIS(WebBrowser, OleDocumentSite, iface)
+
+static HRESULT WINAPI OleDocumentSite_QueryInterface(IOleDocumentSite *iface,
+                                                     REFIID riid, void **ppv)
+{
+    WebBrowser *This = DOCSITE_THIS(iface);
+    return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
+}
+
+static ULONG WINAPI OleDocumentSite_AddRef(IOleDocumentSite *iface)
+{
+    WebBrowser *This = DOCSITE_THIS(iface);
+    return IOleClientSite_AddRef(CLIENTSITE(This));
+}
+
+static ULONG WINAPI OleDocumentSite_Release(IOleDocumentSite *iface)
+{
+    WebBrowser *This = DOCSITE_THIS(iface);
+    return IOleClientSite_Release(CLIENTSITE(This));
+}
+
+static HRESULT WINAPI OleDocumentSite_ActivateMe(IOleDocumentSite *iface,
+                                                 IOleDocumentView *pViewToActivate)
+{
+    WebBrowser *This = DOCSITE_THIS(iface);
+    IOleDocument *oledoc;
+    RECT rect;
+    HRESULT hres;
+
+    TRACE("(%p)->(%p)\n", This, pViewToActivate);
+
+    hres = IUnknown_QueryInterface(This->document, &IID_IOleDocument, (void**)&oledoc);
+    if(FAILED(hres))
+        return hres;
+
+    IOleDocument_CreateView(oledoc, INPLACESITE(This), NULL, 0, &This->view);
+    IOleDocument_Release(oledoc);
+
+    GetClientRect(This->doc_view_hwnd, &rect);
+    IOleDocumentView_SetRect(This->view, &rect);
+
+    hres = IOleDocumentView_Show(This->view, TRUE);
+
+    return hres;
+}
+
+#undef DOCSITE_THIS
+
+static const IOleDocumentSiteVtbl OleDocumentSiteVtbl = {
+    OleDocumentSite_QueryInterface,
+    OleDocumentSite_AddRef,
+    OleDocumentSite_Release,
+    OleDocumentSite_ActivateMe
+};
+
 void WebBrowser_ClientSite_Init(WebBrowser *This)
 {
     This->lpOleClientSiteVtbl   = &OleClientSiteVtbl;
     This->lpOleInPlaceSiteVtbl  = &OleInPlaceSiteVtbl;
+    This->lpOleDocumentSiteVtbl = &OleDocumentSiteVtbl;
+
+    This->view = NULL;
 }
+
+void WebBrowser_ClientSite_Destroy(WebBrowser *This)
+{
+    if(This->view)
+        IOleDocumentView_Release(This->view);
+}

Modified: trunk/reactos/lib/shdocvw/dochost.c
--- trunk/reactos/lib/shdocvw/dochost.c	2005-12-14 19:41:46 UTC (rev 20169)
+++ trunk/reactos/lib/shdocvw/dochost.c	2005-12-14 19:42:38 UTC (rev 20170)
@@ -18,9 +18,142 @@
 
 #include "wine/debug.h"
 #include "shdocvw.h"
+#include "hlink.h"
+#include "exdispid.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
 
+static ATOM doc_view_atom = 0;
+
+static void navigate_complete(WebBrowser *This)
+{
+    IDispatch *disp = NULL;
+    DISPPARAMS dispparams;
+    VARIANTARG params[2];
+    VARIANT url;
+    HRESULT hres;
+
+    hres = IUnknown_QueryInterface(This->document, &IID_IDispatch, (void**)&disp);
+    if(FAILED(hres))
+        FIXME("Could not get IDispatch interface\n");
+
+    dispparams.cArgs = 2;
+    dispparams.cNamedArgs = 0;
+    dispparams.rgdispidNamedArgs = NULL;
+    dispparams.rgvarg = params;
+
+    V_VT(params) = (VT_BYREF|VT_VARIANT);
+    V_BYREF(params) = &url;
+
+    V_VT(params+1) = VT_DISPATCH;
+    V_DISPATCH(params+1) = disp;
+
+    V_VT(&url) = VT_BSTR;
+    V_BSTR(&url) = This->url;
+
+    call_sink(This->cp_wbe2, DISPID_NAVIGATECOMPLETE2, &dispparams);
+    call_sink(This->cp_wbe2, DISPID_DOCUMENTCOMPLETE, &dispparams);
+
+    if(disp)
+        IDispatch_Release(disp);
+}
+
+static LRESULT navigate2(WebBrowser *This)
+{
+    IHlinkTarget *hlink;
+    HRESULT hres;
+
+    TRACE("(%p)\n", This);
+
+    if(!This->document) {
+        WARN("document == NULL\n");
+        return 0;
+    }
+
+    hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink);
+    if(FAILED(hres)) {
+        FIXME("Could not get IHlinkTarget interface\n");
+        return 0;
+    }
+
+    hres = IHlinkTarget_Navigate(hlink, 0, NULL);
+    IHlinkTarget_Release(hlink);
+    if(FAILED(hres)) {
+        FIXME("Navigate failed\n");
+        return 0;
+    }
+
+    navigate_complete(This);
+
+    return 0;
+}
+
+static LRESULT resize_document(WebBrowser *This, LONG width, LONG height)
+{
+    RECT rect = {0, 0, width, height};
+
+    TRACE("(%p)->(%ld %ld)\n", This, width, height);
+
+    if(This->view)
+        IOleDocumentView_SetRect(This->view, &rect);
+
+    return 0;
+}
+
+static LRESULT WINAPI doc_view_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    WebBrowser *This;
+
+    static const WCHAR wszTHIS[] = {'T','H','I','S',0};
+
+    if(msg == WM_CREATE) {
+        This = *(WebBrowser**)lParam;
+        SetPropW(hwnd, wszTHIS, This);
+    }else {
+        This = GetPropW(hwnd, wszTHIS);
+    }
+
+    switch(msg) {
+    case WM_SIZE:
+        return resize_document(This, LOWORD(lParam), HIWORD(lParam));
+    case WB_WM_NAVIGATE2:
+        return navigate2(This);
+    }
+
+    return DefWindowProcA(hwnd, msg, wParam, lParam);
+}
+
+void create_doc_view_hwnd(WebBrowser *This)
+{
+    RECT rect;
+
+    static const WCHAR wszShell_DocObject_View[] =
+        {'S','h','e','l','l',' ','D','o','c','O','b','j','e','c','t',' ','V','i','e','w',0};
+
+    if(!doc_view_atom) {
+        static WNDCLASSEXW wndclass = {
+            sizeof(wndclass),
+            CS_PARENTDC,
+            doc_view_proc,
+            0, 0 /* native uses 4*/, NULL, NULL, NULL,
+            (HBRUSH)COLOR_WINDOWFRAME, NULL,
+            wszShell_DocObject_View,
+            NULL
+        };
+
+        wndclass.hInstance = shdocvw_hinstance;
+
+        doc_view_atom = RegisterClassExW(&wndclass);
+    }
+
+    GetWindowRect(This->shell_embedding_hwnd, &rect);
+    This->doc_view_hwnd = CreateWindowExW(0, wszShell_DocObject_View,
+         wszShell_DocObject_View,
+         WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | WS_MAXIMIZEBOX,
+         rect.left, rect.top, rect.right, rect.bottom, This->shell_embedding_hwnd,
+         NULL, shdocvw_hinstance, This);
+}
+
 #define DOCHOSTUI_THIS(iface) DEFINE_THIS(WebBrowser, DocHostUIHandler, iface)
 
 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface,
@@ -143,8 +276,23 @@
         LPOLESTR *pchKey, DWORD dw)
 {
     WebBrowser *This = DOCHOSTUI_THIS(iface);
-    FIXME("(%p)->(%p %ld)\n", This, pchKey, dw);
-    return E_NOTIMPL;
+    IDocHostUIHandler *handler;
+    HRESULT hres;
+
+    TRACE("(%p)->(%p %ld)\n", This, pchKey, dw);
+
+    if(!This->client)
+        return S_OK;
+
+    hres = IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler,
+                                         (void**)&handler);
+    if(SUCCEEDED(hres)) {
+        hres = IDocHostUIHandler_GetOptionKeyPath(handler, pchKey, dw);
+        IDocHostUIHandler_Release(handler);
+        return hres;
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
@@ -183,8 +331,23 @@
         LPOLESTR *pchKey, DWORD dw)
 {
     WebBrowser *This = DOCHOSTUI_THIS(iface);
-    FIXME("(%p)->(%p %ld)\n", This, pchKey, dw);
-    return E_NOTIMPL;
+    IDocHostUIHandler2 *handler;
+    HRESULT hres;
+
+    TRACE("(%p)->(%p %ld)\n", This, pchKey, dw);
+
+    if(!This->client)
+        return S_OK;
+
+    hres = IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler2,
+                                         (void**)&handler);
+    if(SUCCEEDED(hres)) {
+        hres = IDocHostUIHandler2_GetOverrideKeyPath(handler, pchKey, dw);
+        IDocHostUIHandler2_Release(handler);
+        return hres;
+    }
+
+    return S_OK;
 }
 
 #undef DOCHOSTUI_THIS
@@ -214,4 +377,6 @@
 void WebBrowser_DocHost_Init(WebBrowser *This)
 {
     This->lpDocHostUIHandlerVtbl = &DocHostUIHandler2Vtbl;
+
+    This->doc_view_hwnd = NULL;
 }

Modified: trunk/reactos/lib/shdocvw/events.c
--- trunk/reactos/lib/shdocvw/events.c	2005-12-14 19:41:46 UTC (rev 20169)
+++ trunk/reactos/lib/shdocvw/events.c	2005-12-14 19:42:38 UTC (rev 20170)
@@ -27,13 +27,16 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
 
-typedef struct {
+struct ConnectionPoint {
     const IConnectionPointVtbl *lpConnectionPointVtbl;
 
     WebBrowser *webbrowser;
 
+    IDispatch **sinks;
+    DWORD sinks_size;
+
     IID iid;
-} ConnectionPoint;
+};
 
 #define CONPOINT(x)  ((IConnectionPoint*) &(x)->lpConnectionPointVtbl)
 
@@ -84,13 +87,13 @@
 
     if(IsEqualGUID(&DIID_DWebBrowserEvents2, riid)) {
         TRACE("(%p)->(DIID_DWebBrowserEvents2 %p)\n", This, ppCP);
-        *ppCP = This->cp_wbe2;
+        *ppCP = CONPOINT(This->cp_wbe2);
     }else if(IsEqualGUID(&DIID_DWebBrowserEvents, riid)) {
         TRACE("(%p)->(DIID_DWebBrowserEvents %p)\n", This, ppCP);
-        *ppCP = This->cp_wbe;
+        *ppCP = CONPOINT(This->cp_wbe);
     }else if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
         TRACE("(%p)->(IID_IPropertyNotifySink %p)\n", This, ppCP);
-        *ppCP = This->cp_pns;
+        *ppCP = CONPOINT(This->cp_pns);
     }
 
     if(*ppCP) {
@@ -181,15 +184,53 @@
                                              DWORD *pdwCookie)
 {
     ConnectionPoint *This = CONPOINT_THIS(iface);
-    FIXME("(%p)->(%p %p)\n", This, pUnkSink, pdwCookie);
-    return E_NOTIMPL;
+    IDispatch *disp;
+    DWORD i;
+    HRESULT hres;
+
+    TRACE("(%p)->(%p %p)\n", This, pUnkSink, pdwCookie);
+
+    hres = IUnknown_QueryInterface(pUnkSink, &This->iid, (void**)&disp);
+    if(FAILED(hres)) {
+        hres = IUnknown_QueryInterface(pUnkSink, &IID_IDispatch, (void**)&disp);
+        if(FAILED(hres))
+            return CONNECT_E_CANNOTCONNECT;
+    }
+
+    if(This->sinks) {
+        for(i=0; i<This->sinks_size; i++) {
+            if(!This->sinks[i])
+                break;
+        }
+
+        if(i == This->sinks_size)
+            This->sinks = HeapReAlloc(GetProcessHeap(), 0, This->sinks,
+                                      (++This->sinks_size)*sizeof(*This->sinks));
+    }else {
+        This->sinks = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->sinks));
+        This->sinks_size = 1;
+        i = 0;
+    }
+
+    This->sinks[i] = disp;
+    *pdwCookie = i+1;
+
+    return S_OK;
 }
 
 static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
 {
     ConnectionPoint *This = CONPOINT_THIS(iface);
-    FIXME("(%p)->(%ld)\n", This, dwCookie);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%ld)\n", This, dwCookie);
+
+    if(!dwCookie || dwCookie > This->sinks_size || !This->sinks[dwCookie-1])
+        return CONNECT_E_NOCONNECTION;
+
+    IDispatch_Release(This->sinks[dwCookie-1]);
+    This->sinks[dwCookie-1] = NULL;
+
+    return S_OK;
 }
 
 static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface,
@@ -214,17 +255,45 @@
     ConnectionPoint_EnumConnections
 };
 
-static void ConnectionPoint_Create(WebBrowser *wb, REFIID riid, IConnectionPoint **cp)
+void call_sink(ConnectionPoint *This, DISPID dispid, DISPPARAMS *dispparams)
 {
+    DWORD i;
+
+    for(i=0; i<This->sinks_size; i++) {
+        if(This->sinks[i])
+            IDispatch_Invoke(This->sinks[i], dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
+                             DISPATCH_METHOD, dispparams, NULL, NULL, NULL);
+    }
+}
+
+static void ConnectionPoint_Create(WebBrowser *wb, REFIID riid, ConnectionPoint **cp)
+{
     ConnectionPoint *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(ConnectionPoint));
 
     ret->lpConnectionPointVtbl = &ConnectionPointVtbl;
     ret->webbrowser = wb;
+
+    ret->sinks = NULL;
+    ret->sinks_size = 0;
+
     memcpy(&ret->iid, riid, sizeof(IID));
 
-    *cp = CONPOINT(ret);
+    *cp = ret;
 }
 
+static void ConnectionPoint_Destroy(ConnectionPoint *This)
+{
+    int i;
+
+    for(i=0; i<This->sinks_size; i++) {
+        if(This->sinks[i])
+            IDispatch_Release(This->sinks[i]);
+    }
+
+    HeapFree(GetProcessHeap(), 0, This->sinks);
+    HeapFree(GetProcessHeap(), 0, This);
+}
+
 void WebBrowser_Events_Init(WebBrowser *This)
 {
     This->lpConnectionPointContainerVtbl = &ConnectionPointContainerVtbl;
@@ -236,7 +305,7 @@
 
 void WebBrowser_Events_Destroy(WebBrowser *This)
 {
-    HeapFree(GetProcessHeap(), 0, This->cp_wbe2);
-    HeapFree(GetProcessHeap(), 0, This->cp_wbe);
-    HeapFree(GetProcessHeap(), 0, This->cp_pns);
+    ConnectionPoint_Destroy(This->cp_wbe2);
+    ConnectionPoint_Destroy(This->cp_wbe);
+    ConnectionPoint_Destroy(This->cp_pns);
 }

Copied: trunk/reactos/lib/shdocvw/frame.c (from rev 20168, vendor/wine/dlls/shdocvw/current/frame.c)
Property changes on: trunk/reactos/lib/shdocvw/frame.c ___________________________________________________________________ Name: svn:keywords   + Author Date Id Revision Name: svn:eol-style   + native
Modified: trunk/reactos/lib/shdocvw/oleobject.c
--- trunk/reactos/lib/shdocvw/oleobject.c	2005-12-14 19:41:46 UTC (rev 20169)
+++ trunk/reactos/lib/shdocvw/oleobject.c	2005-12-14 19:42:38 UTC (rev 20170)
@@ -29,44 +29,36 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
 
-static ATOM doc_view_atom = 0;
 static ATOM shell_embedding_atom = 0;
 
-static LRESULT WINAPI doc_view_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+static LRESULT resize_window(WebBrowser *This, LONG width, LONG height)
 {
-    return DefWindowProcA(hwnd, msg, wParam, lParam);
+    if(This->doc_view_hwnd)
+        SetWindowPos(This->doc_view_hwnd, NULL, 0, 0, width, height,
+                     SWP_NOZORDER | SWP_NOACTIVATE);
+
+    return 0;
 }
 
 static LRESULT WINAPI shell_embedding_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-    return DefWindowProcA(hwnd, msg, wParam, lParam);
-}
+    WebBrowser *This;
 
-static void create_doc_view_hwnd(WebBrowser *This)
-{
-    static const WCHAR wszShell_DocObject_View[] =
-        {'S','h','e','l','l',' ','D','o','c','O','b','j','e','c','t',' ','V','i','e','w',0};
+    static const WCHAR wszTHIS[] = {'T','H','I','S',0};
 
-    if(!doc_view_atom) {
-        static WNDCLASSEXW wndclass = {
-            sizeof(wndclass),
-            CS_PARENTDC,
-            doc_view_proc,
-            0, 0 /* native uses 4*/, NULL, NULL, NULL,
-            (HBRUSH)COLOR_WINDOWFRAME, NULL,
-            wszShell_DocObject_View,
-            NULL
-        };
+    if(msg == WM_CREATE) {
+        This = *(WebBrowser**)lParam;
+        SetPropW(hwnd, wszTHIS, This);
+    }else {
+        This = GetPropW(hwnd, wszTHIS);
+    }
 
-        wndclass.hInstance = shdocvw_hinstance;
-
-        doc_view_atom = RegisterClassExW(&wndclass);
+    switch(msg) {
+    case WM_SIZE:
+        return resize_window(This, LOWORD(lParam), HIWORD(lParam));
     }
 
-    This->doc_view_hwnd = CreateWindowExW(0, wszShell_DocObject_View, NULL,
-         WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | WS_MAXIMIZEBOX,
-         0, 0, 0, 0, This->shell_embedding_hwnd,
-         NULL, shdocvw_hinstance, This);
+    return DefWindowProcA(hwnd, msg, wParam, lParam);
 }
 
 static void create_shell_embedding_hwnd(WebBrowser *This)
@@ -99,12 +91,10 @@
         IOleInPlaceSite_Release(inplace);
     }
 
-    This->shell_embedding_hwnd = CreateWindowExW(0, wszShellEmbedding, NULL,
+    This->shell_embedding_hwnd = CreateWindowExW(0, wszShellEmbedding, wszShellEmbedding,
          WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | WS_MAXIMIZEBOX,
          0, 0, 0, 0, parent,
          NULL, shdocvw_hinstance, This);
-
-    create_doc_view_hwnd(This);
 }
 
 /**********************************************************************
@@ -151,7 +141,7 @@
     This->client = pClientSite;
     if(!pClientSite)
         return S_OK;
-    
+
     IOleClientSite_AddRef(pClientSite);
 
     create_shell_embedding_hwnd(This);
@@ -227,11 +217,14 @@
     WebBrowser *This = OLEOBJ_THIS(iface);
     HRESULT hres;
 
+    static const WCHAR wszitem[] = {'i','t','e','m',0};
+
     TRACE("(%p)->(%ld %p %p %ld %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent,
             lprcPosRect);
 
     switch (iVerb)
     {
+    case OLEIVERB_SHOW:
     case OLEIVERB_INPLACEACTIVATE: {
         IOleInPlaceSite *inplace;
 
@@ -264,8 +257,15 @@
                                          &This->frameinfo);
 
 
-        IOleInPlaceSite_Release(inplace);
+        if(iVerb == OLEIVERB_INPLACEACTIVATE)
+            IOleInPlaceSite_Release(inplace);
 
+        SetWindowPos(This->shell_embedding_hwnd, NULL,
+                     This->pos_rect.left, This->pos_rect.top,
+                     This->pos_rect.right-This->pos_rect.left,
+                     This->pos_rect.bottom-This->pos_rect.top,
+                     SWP_NOZORDER | SWP_SHOWWINDOW);
+
         if(This->client) {
             IOleClientSite_ShowObject(This->client);
             IOleClientSite_GetContainer(This->client, &This->container);
@@ -274,6 +274,20 @@
         if(This->frame)
             IOleInPlaceFrame_GetWindow(This->frame, &This->frame_hwnd);
 
+        if(iVerb == OLEIVERB_INPLACEACTIVATE)
+            return S_OK;
+
+        TRACE("OLEIVERB_SHOW\n");
+
+        IOleInPlaceSite_OnUIActivate(inplace);
+        IOleInPlaceSite_Release(inplace);
+
+        IOleInPlaceFrame_SetActiveObject(This->frame, ACTIVEOBJ(This), wszitem);
+
+        /* TODO:
+         * IOleInPlaceFrmae_SetMenu
+         */
+
         return S_OK;
     }
     default:
@@ -482,8 +496,18 @@
         LPCRECT lprcPosRect, LPCRECT lprcClipRect)
 {
     WebBrowser *This = INPLACEOBJ_THIS(iface);
-    FIXME("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
+
+    if(This->shell_embedding_hwnd) {
+        SetWindowPos(This->shell_embedding_hwnd, NULL,
+                     lprcPosRect->left, lprcPosRect->top,
+                     lprcPosRect->right-lprcPosRect->left,
+                     lprcPosRect->bottom-lprcPosRect->top,
+                     SWP_NOZORDER | SWP_NOACTIVATE);
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject *iface)
@@ -574,11 +598,102 @@
     OleControl_FreezeEvents
 };
 
+#define ACTIVEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceActiveObject, iface)
+
+static HRESULT WINAPI InPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface,
+                                                            REFIID riid, void **ppv)
+{
+    WebBrowser *This = ACTIVEOBJ_THIS(iface);
+    return IWebBrowser2_QueryInterface(WEBBROWSER2(This), riid, ppv);
+}
+
+static ULONG WINAPI InPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
+{
+    WebBrowser *This = ACTIVEOBJ_THIS(iface);
+    return IWebBrowser2_AddRef(WEBBROWSER2(This));
+}
+
+static ULONG WINAPI InPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
+{
+    WebBrowser *This = ACTIVEOBJ_THIS(iface);
+    return IWebBrowser2_Release(WEBBROWSER2(This));
+}
+
+static HRESULT WINAPI InPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface,
+                                                    HWND *phwnd)
+{
+    WebBrowser *This = ACTIVEOBJ_THIS(iface);
+    return IOleInPlaceObject_GetWindow(INPLACEOBJ(This), phwnd);
+}
+
+static HRESULT WINAPI InPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface,
+                                                               BOOL fEnterMode)
+{
+    WebBrowser *This = ACTIVEOBJ_THIS(iface);
+    return IOleInPlaceObject_ContextSensitiveHelp(INPLACEOBJ(This), fEnterMode);
+}
+
+static HRESULT WINAPI InPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface,
+                                                               LPMSG lpmsg)
+{
+    WebBrowser *This = ACTIVEOBJ_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, lpmsg);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI InPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface,
+                                                                BOOL fActivate)
+{
+    WebBrowser *This = ACTIVEOBJ_THIS(iface);
+    FIXME("(%p)->(%x)\n", This, fActivate);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI InPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface,
+                                                              BOOL fActivate)
+{
+    WebBrowser *This = ACTIVEOBJ_THIS(iface);
+    FIXME("(%p)->(%x)\n", This, fActivate);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI InPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface,
+        LPCRECT lprcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
+{
+    WebBrowser *This = ACTIVEOBJ_THIS(iface);
+    FIXME("(%p)->(%p %p %x)\n", This, lprcBorder, pUIWindow, fFrameWindow);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI InPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface,
+                                                         BOOL fEnable)
+{
+    WebBrowser *This = ACTIVEOBJ_THIS(iface);
+    FIXME("(%p)->(%x)\n", This, fEnable);
+    return E_NOTIMPL;
+}
+
+#undef ACTIVEOBJ_THIS
+
+static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
+    InPlaceActiveObject_QueryInterface,
+    InPlaceActiveObject_AddRef,
+    InPlaceActiveObject_Release,
+    InPlaceActiveObject_GetWindow,
+    InPlaceActiveObject_ContextSensitiveHelp,
+    InPlaceActiveObject_TranslateAccelerator,
+    InPlaceActiveObject_OnFrameWindowActivate,
+    InPlaceActiveObject_OnDocWindowActivate,
+    InPlaceActiveObject_ResizeBorder,
+    InPlaceActiveObject_EnableModeless
+};
+
 void WebBrowser_OleObject_Init(WebBrowser *This)
 {
-    This->lpOleObjectVtbl        = &OleObjectVtbl;
-    This->lpOleInPlaceObjectVtbl = &OleInPlaceObjectVtbl;
-    This->lpOleControlVtbl       = &OleControlVtbl;
+    This->lpOleObjectVtbl              = &OleObjectVtbl;
+    This->lpOleInPlaceObjectVtbl       = &OleInPlaceObjectVtbl;
+    This->lpOleControlVtbl             = &OleControlVtbl;
+    This->lpOleInPlaceActiveObjectVtbl = &OleInPlaceActiveObjectVtbl;
 
     This->client = NULL;
     This->container = NULL;
@@ -586,6 +701,7 @@
     This->frame_hwnd = NULL;
     This->frame = NULL;
     This->uiwindow = NULL;
+    This->shell_embedding_hwnd = NULL;
 
     memset(&This->pos_rect, 0, sizeof(RECT));
     memset(&This->clip_rect, 0, sizeof(RECT));

Modified: trunk/reactos/lib/shdocvw/shdocvw.h
--- trunk/reactos/lib/shdocvw/shdocvw.h	2005-12-14 19:41:46 UTC (rev 20169)
+++ trunk/reactos/lib/shdocvw/shdocvw.h	2005-12-14 19:42:38 UTC (rev 20170)
@@ -58,6 +58,9 @@
 /**********************************************************************
  * WebBrowser declaration for SHDOCVW.DLL
  */
+
+typedef struct ConnectionPoint ConnectionPoint;
+
 typedef struct {
     /* Interfaces available via WebBrowser object */
 
@@ -71,20 +74,29 @@
     const IQuickActivateVtbl            *lpQuickActivateVtbl;
     const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
     const IViewObject2Vtbl              *lpViewObjectVtbl;
+    const IOleInPlaceActiveObjectVtbl   *lpOleInPlaceActiveObjectVtbl;
 
     /* Interfaces available for embeded document */
 
     const IOleClientSiteVtbl            *lpOleClientSiteVtbl;
     const IOleInPlaceSiteVtbl           *lpOleInPlaceSiteVtbl;
     const IDocHostUIHandler2Vtbl        *lpDocHostUIHandlerVtbl;
+    const IOleDocumentSiteVtbl          *lpOleDocumentSiteVtbl;
 
+    /* Interfaces of InPlaceFrame object */
+
+    const IOleInPlaceFrameVtbl          *lpOleInPlaceFrameVtbl;
+
     LONG ref;
 
     IUnknown *document;
 
     IOleClientSite *client;
     IOleContainer *container;
+    IOleDocumentView *view;
 
+    LPOLESTR url;
+
     /* window context */
 
     HWND iphwnd;
@@ -100,9 +112,9 @@
 
     /* Connection points */
 
-    IConnectionPoint *cp_wbe2;
-    IConnectionPoint *cp_wbe;
-    IConnectionPoint *cp_pns;
+    ConnectionPoint *cp_wbe2;
+    ConnectionPoint *cp_wbe;
+    ConnectionPoint *cp_pns;
 } WebBrowser;
 
 #define WEBBROWSER(x)   ((IWebBrowser*)                 &(x)->lpWebBrowser2Vtbl)
@@ -117,12 +129,16 @@
 #define CONPTCONT(x)    ((IConnectionPointContainer*)   &(x)->lpConnectionPointContainerVtbl)
 #define VIEWOBJ(x)      ((IViewObject*)                 &(x)->lpViewObjectVtbl);
 #define VIEWOBJ2(x)     ((IViewObject2*)                &(x)->lpViewObjectVtbl);
+#define ACTIVEOBJ(x)    ((IOleInPlaceActiveObject*)     &(x)->lpOleInPlaceActiveObjectVtbl)
 
 #define CLIENTSITE(x)   ((IOleClientSite*)              &(x)->lpOleClientSiteVtbl)
 #define INPLACESITE(x)  ((IOleInPlaceSite*)             &(x)->lpOleInPlaceSiteVtbl)
 #define DOCHOSTUI(x)    ((IDocHostUIHandler*)           &(x)->lpDocHostUIHandlerVtbl)
 #define DOCHOSTUI2(x)   ((IDocHostUIHandler2*)          &(x)->lpDocHostUIHandlerVtbl)
+#define DOCSITE(x)      ((IOleDocumentSite*)            &(x)->lpOleDocumentSiteVtbl)
 
+#define INPLACEFRAME(x) ((IOleInPlaceFrame*)            &(x)->lpOleInPlaceFrameVtbl)
+
 void WebBrowser_OleObject_Init(WebBrowser*);
 void WebBrowser_ViewObject_Init(WebBrowser*);
 void WebBrowser_Persist_Init(WebBrowser*);
@@ -133,11 +149,19 @@
 void WebBrowser_ClientSite_Init(WebBrowser*);
 void WebBrowser_DocHost_Init(WebBrowser*);
 
+void WebBrowser_Frame_Init(WebBrowser*);
+
 void WebBrowser_OleObject_Destroy(WebBrowser*);
 void WebBrowser_Events_Destroy(WebBrowser*);
+void WebBrowser_ClientSite_Destroy(WebBrowser*);
 
 HRESULT WebBrowser_Create(IUnknown*,REFIID,void**);
 
+void create_doc_view_hwnd(WebBrowser *This);
+void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*);
+
+#define WB_WM_NAVIGATE2 (WM_USER+100)
+
 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
 
 /**********************************************************************

Modified: trunk/reactos/lib/shdocvw/shdocvw.xml
--- trunk/reactos/lib/shdocvw/shdocvw.xml	2005-12-14 19:41:46 UTC (rev 20169)
+++ trunk/reactos/lib/shdocvw/shdocvw.xml	2005-12-14 19:42:38 UTC (rev 20170)
@@ -23,6 +23,7 @@
 	<file>dochost.c</file>
 	<file>events.c</file>
 	<file>factory.c</file>
+	<file>frame.c</file>
 	<file>misc.c</file>
 	<file>oleobject.c</file>
 	<file>persist.c</file>

Modified: trunk/reactos/lib/shdocvw/webbrowser.c
--- trunk/reactos/lib/shdocvw/webbrowser.c	2005-12-14 19:41:46 UTC (rev 20169)
+++ trunk/reactos/lib/shdocvw/webbrowser.c	2005-12-14 19:42:38 UTC (rev 20170)
@@ -94,6 +94,9 @@
     }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
         TRACE("(%p)->(IID_IViewObject2 %p)\n", This, ppv);
         *ppv = VIEWOBJ2(This);
+    }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
+        TRACE("(%p)->(IID_IOleInPlaceActiveObject %p)\n", This, ppv);
+        *ppv = ACTIVEOBJ(This);
     }
 
     if(*ppv) {
@@ -126,7 +129,9 @@
 
         WebBrowser_OleObject_Destroy(This);
         WebBrowser_Events_Destroy(This);
+        WebBrowser_ClientSite_Destroy(This);
 
+        SysFreeString(This->url);
         HeapFree(GetProcessHeap(), 0, This);
         SHDOCVW_UnlockModule();
     }
@@ -255,8 +260,14 @@
 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
 {
     WebBrowser *This = WEBBROWSER_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, ppDisp);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, ppDisp);
+
+    *ppDisp = NULL;
+    if(This->document)
+        IUnknown_QueryInterface(This->document, &IID_IDispatch, (void**)ppDisp);
+
+    return S_OK;
 }
 
 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
@@ -504,13 +515,20 @@
     if(!This->client)
         return E_FAIL;
 
-    if(V_VT(Flags) != VT_EMPTY || V_VT(TargetFrameName) != VT_EMPTY
-       || V_VT(PostData) != VT_EMPTY || V_VT(Headers) != VT_EMPTY)
+    if((Flags && V_VT(Flags) != VT_EMPTY) 
+       || (TargetFrameName && V_VT(TargetFrameName) != VT_EMPTY)
+       || (PostData && V_VT(PostData) != VT_EMPTY) 
+       || (Headers && V_VT(Headers) != VT_EMPTY))
         FIXME("Unsupported arguments\n");
 
+    if(!URL)
+        return S_OK;
     if(V_VT(URL) != VT_BSTR)
-        FIXME("V_VT(URL) != VT_BSTR\n");
+        return E_INVALIDARG;
 
+    if(!This->doc_view_hwnd)
+        create_doc_view_hwnd(This);
+
     /*
      * FIXME:
      * We should use URLMoniker's BindToObject instead creating HTMLDocument here.
@@ -543,6 +561,8 @@
         return hres;
     }
 
+    This->url = SysAllocString(V_BSTR(URL));
+
     hres = IUnknown_QueryInterface(This->document, &IID_IOleObject, (void**)&oleobj);
     if(FAILED(hres))
         return hres;
@@ -550,6 +570,8 @@
     hres = IOleObject_SetClientSite(oleobj, CLIENTSITE(This));
     IOleObject_Release(oleobj);
 
+    PostMessageW(This->doc_view_hwnd, WB_WM_NAVIGATE2, 0, 0);
+
     return hres;
 }
 
@@ -775,6 +797,7 @@
[truncated at 1000 lines; 1429 more skipped]