MSHTML: more view implementation

Jacek Caban jack at itma.pwr.wroc.pl
Wed Apr 13 16:06:50 CDT 2005


IE works a bit better with this patch. Now it starts and works, but,
in place of html, shows text "HTML rendering is currently disabled."
This is not temporary as even when Gecko handling will be implemented,
it'll be still used when Gecko is not be available.

Changelog:
    Added more implementation of IDocumentView
-------------- next part --------------
Index: dlls/mshtml/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/mshtml/Makefile.in,v
retrieving revision 1.9
diff -u -p -r1.9 Makefile.in
--- dlls/mshtml/Makefile.in	13 Apr 2005 14:41:19 -0000	1.9
+++ dlls/mshtml/Makefile.in	13 Apr 2005 19:32:50 -0000
@@ -3,7 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = mshtml.dll
-IMPORTS   = user32 advapi32 kernel32 ntdll
+IMPORTS   = user32 advapi32 kernel32 ntdll gdi32
 EXTRALIBS = $(LIBUNICODE) -lstrmiids -luuid
 EXTRADEFS = -DCOM_NO_WINDOWS_H
 
Index: dlls/mshtml/htmldoc.c
===================================================================
RCS file: /home/wine/wine/dlls/mshtml/htmldoc.c,v
retrieving revision 1.4
diff -u -p -r1.4 htmldoc.c
--- dlls/mshtml/htmldoc.c	13 Apr 2005 14:41:19 -0000	1.4
+++ dlls/mshtml/htmldoc.c	13 Apr 2005 19:32:50 -0000
@@ -53,7 +53,7 @@ static HRESULT WINAPI HTMLDocument_Query
         TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppvObject);
         *ppvObject = HTMLDOC(This);
     }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
-        TRACE("(%p)->(IID_IDocument2, %p)\n", This, ppvObject);
+        TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppvObject);
         *ppvObject = HTMLDOC(This);
     }else if(IsEqualGUID(&IID_IPersist, riid)) {
         TRACE("(%p)->(IID_IPersist, %p)\n", This, ppvObject);
Index: dlls/mshtml/main.c
===================================================================
RCS file: /home/wine/wine/dlls/mshtml/main.c,v
retrieving revision 1.8
diff -u -p -r1.8 main.c
--- dlls/mshtml/main.c	12 Apr 2005 11:57:51 -0000	1.8
+++ dlls/mshtml/main.c	13 Apr 2005 19:32:50 -0000
@@ -52,6 +52,7 @@ typedef BOOL (WINAPI *fnCanUnloadNow)();
 
 static HMODULE hMozCtl;
 
+HINSTANCE hInst;
 
 /* convert a guid to a wide character string */
 static void MSHTML_guid2wstr( const GUID *guid, LPWSTR wstr )
@@ -109,6 +110,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, 
                 MESSAGE("You need to install the Mozilla ActiveX control to\n");
                 MESSAGE("use Wine's builtin MSHTML dll.\n");
             }
+            hInst = hInstDLL;
 	    break;
 	case DLL_PROCESS_DETACH:
             if(hMozCtl)
Index: dlls/mshtml/view.c
===================================================================
RCS file: /home/wine/wine/dlls/mshtml/view.c,v
retrieving revision 1.1
diff -u -p -r1.1 view.c
--- dlls/mshtml/view.c	13 Apr 2005 14:41:19 -0000	1.1
+++ dlls/mshtml/view.c	13 Apr 2005 19:32:50 -0000
@@ -26,6 +26,7 @@
 #include "windef.h"
 #include "winbase.h"
 #include "winuser.h"
+#include "wingdi.h"
 #include "ole2.h"
 #include "docobj.h"
 
@@ -37,6 +38,57 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 
+static const WCHAR wszInternetExplorer_Server[] =
+    {'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','_','S','e','r','v','e','r',0};
+
+static ATOM serverwnd_class = 0;
+
+static void paint_disabled(HWND hwnd) {
+    HDC hdc;
+    PAINTSTRUCT ps;
+    HBRUSH brush;
+    RECT rect;
+    HFONT font;
+
+    font = CreateFontA(25,0,0,0,400,0,0,0,ANSI_CHARSET,0,0,DEFAULT_QUALITY,DEFAULT_PITCH,NULL);
+    brush = CreateSolidBrush(RGB(255,255,255));
+    GetClientRect(hwnd, &rect);
+
+    hdc = BeginPaint(hwnd, &ps);
+    SelectObject(hdc, font);
+    SelectObject(hdc, brush);
+    Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
+    DrawTextA(hdc, "HTML rendering is currently disabled.",-1, &rect,
+            DT_CENTER | DT_SINGLELINE | DT_VCENTER);
+    EndPaint(hwnd, &ps);
+
+    DeleteObject(font);
+    DeleteObject(brush);
+}
+
+static LRESULT WINAPI serverwnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    if(msg == WM_PAINT)
+        paint_disabled(hwnd);
+        
+    return DefWindowProcW(hwnd, msg, wParam, lParam);
+}
+
+static void register_serverwnd_class()
+{
+    static WNDCLASSEXW wndclass = {
+        sizeof(WNDCLASSEXW),
+        CS_DBLCLKS,
+        serverwnd_proc,
+        0, 0, NULL, NULL, NULL, NULL, NULL,
+        wszInternetExplorer_Server,
+        NULL,
+    };
+    wndclass.hInstance = hInst;
+    serverwnd_class = RegisterClassExW(&wndclass);
+}
+
+
 /**********************************************************
  * IOleDocumentView implementation
  */
@@ -111,15 +163,36 @@ static HRESULT WINAPI OleDocumentView_Ge
 static HRESULT WINAPI OleDocumentView_SetRect(IOleDocumentView *iface, LPRECT prcView)
 {
     DOCVIEW_THIS
-    FIXME("(%p)->(%p)\n", This, prcView);
-    return E_NOTIMPL;
+    RECT rect;
+
+    TRACE("(%p)->(%p)\n", This, prcView);
+
+    if(!prcView)
+        return E_INVALIDARG;
+
+    if(This->hwnd) {
+        GetClientRect(This->hwnd, &rect);
+        if(memcmp(prcView, &rect, sizeof(RECT))) {
+            InvalidateRect(This->hwnd,NULL,TRUE);
+            SetWindowPos(This->hwnd, NULL, prcView->left, prcView->top, prcView->right,
+                    prcView->bottom, SWP_NOZORDER | SWP_NOACTIVATE);
+        }
+    }
+    
+    return S_OK;
 }
 
 static HRESULT WINAPI OleDocumentView_GetRect(IOleDocumentView *iface, LPRECT prcView)
 {
     DOCVIEW_THIS
-    FIXME("(%p)->(%p)\n", This, prcView);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, prcView);
+
+    if(!prcView)
+        return E_INVALIDARG;
+
+    GetClientRect(This->hwnd, prcView);
+    return S_OK;
 }
 
 static HRESULT WINAPI OleDocumentView_SetRectComplex(IOleDocumentView *iface, LPRECT prcView,
@@ -140,8 +213,88 @@ static HRESULT WINAPI OleDocumentView_Sh
 static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL fUIActivate)
 {
     DOCVIEW_THIS
-    FIXME("(%p)->(%x)\n", This, fUIActivate);
-    return E_NOTIMPL;
+    HRESULT hres;
+    IOleInPlaceUIWindow *pIPWnd;
+    IOleInPlaceFrame *pIPFrame;
+    RECT posrect, cliprect;
+    OLEINPLACEFRAMEINFO frameinfo;
+    HWND parent_hwnd, hwnd;
+
+    TRACE("(%p)->(%x)\n", This, fUIActivate);
+
+    if(!This->ipsite) {
+        FIXME("This->ipsite = NULL\n");
+        return E_FAIL;
+    }
+
+    if(fUIActivate) {
+        if(This->hwnd)
+            return S_OK;
+        if(!serverwnd_class)
+            register_serverwnd_class();
+
+        hres = IOleInPlaceSite_CanInPlaceActivate(This->ipsite);
+        if(hres != S_OK) {
+            WARN("CanInPlaceActivate returned: %08lx\n", hres);
+            return FAILED(hres) ? hres : E_FAIL;
+        }
+
+        hres = IOleInPlaceSite_GetWindowContext(This->ipsite, &pIPFrame, &pIPWnd, &posrect, &cliprect, &frameinfo);
+        if(FAILED(hres)) {
+            WARN("GetWindowContext failed: %08lx\n", hres);
+            return hres;
+        }
+        if(pIPFrame)
+            IOleInPlaceFrame_Release(pIPFrame);
+        if(pIPWnd)
+            IOleInPlaceUIWindow_Release(pIPWnd);
+        TRACE("got window context: %p %p {%ld %ld %ld %ld} {%ld %ld %ld %ld} {%d %x %p %p %d}\n",
+                pIPFrame, pIPWnd, posrect.left, posrect.top, posrect.right, posrect.bottom,
+                cliprect.left, cliprect.top, cliprect.right, cliprect.bottom,
+                frameinfo.cb, frameinfo.fMDIApp, frameinfo.hwndFrame, frameinfo.haccel, frameinfo.cAccelEntries);
+
+        hres = IOleInPlaceSite_GetWindow(This->ipsite, &parent_hwnd);
+        if(FAILED(hres)) {
+            WARN("GetWindow failed: %08lx\n", hres);
+            return hres;
+        }
+
+        hwnd = CreateWindowExW(0, wszInternetExplorer_Server, NULL,
+                WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+                posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
+                parent_hwnd, NULL, hInst, This);
+
+        hres = IOleInPlaceSite_OnInPlaceActivate(This->ipsite);
+        if(FAILED(hres)) {
+            WARN("OnInPlaceActivate failed: %08lx\n", hres);
+            return hres;
+        }
+
+        SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
+                SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_SHOWWINDOW);
+        RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE | RDW_ALLCHILDREN);
+        SetFocus(hwnd);
+
+        /* NOTE:
+         * Windows implementation calls:
+         * RegisterWindowMessage("MSWHEEL_ROLLMSG");
+         * SetTimer(This->hwnd, TIMER_ID, 100, NULL);
+         */
+
+        hres = IOleInPlaceSite_OnUIActivate(This->ipsite);
+        if(SUCCEEDED(hres)) {
+            /* IOleInPlaceFrame_SetActiveObject(pIPFrame, ACTOBJ(This->pDoc), wszHTMLDocument); */
+        }else {
+            FIXME("OnUIActivate failed: %08lx\n", hres);
+            DestroyWindow(hwnd);
+            return hres;
+        }
+        This->hwnd = hwnd;
+    }else {
+        FIXME("deactivating is not supported\n");
+        return E_NOTIMPL;
+    }
+    return S_OK;
 }
 
 static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface)
@@ -204,4 +357,5 @@ void HTMLDocument_View_Init(HTMLDocument
     This->lpOleDocumentViewVtbl = &OleDocumentViewVtbl;
 
     This->ipsite = NULL;
+    This->hwnd = NULL;
 }
Index: dlls/mshtml/mshtml_private.h
===================================================================
RCS file: /home/wine/wine/dlls/mshtml/mshtml_private.h,v
retrieving revision 1.4
diff -u -p -r1.4 mshtml_private.h
--- dlls/mshtml/mshtml_private.h	13 Apr 2005 14:41:19 -0000	1.4
+++ dlls/mshtml/mshtml_private.h	13 Apr 2005 19:32:50 -0000
@@ -29,6 +29,8 @@ typedef struct {
 
     IOleClientSite *client;
     IOleInPlaceSite *ipsite;
+
+    HWND hwnd;
 } HTMLDocument;
 
 #define HTMLDOC(x)       ((IHTMLDocument2*)     &(x)->lpHTMLDocument2Vtbl)
@@ -45,3 +47,5 @@ HRESULT HTMLDocument_Create(IUnknown*,RE
 void HTMLDocument_Persist_Init(HTMLDocument*);
 void HTMLDocument_OleObj_Init(HTMLDocument*);
 void HTMLDocument_View_Init(HTMLDocument*);
+
+extern HINSTANCE hInst;


More information about the wine-patches mailing list