2 * Copyright 2005 Jacek Caban
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #include "wine/debug.h"
37 #include "mshtml_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
41 static const WCHAR wszInternetExplorer_Server[] =
42 {'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','_','S','e','r','v','e','r',0};
44 static ATOM serverwnd_class = 0;
46 static void paint_disabled(HWND hwnd) {
53 font = CreateFontA(25,0,0,0,400,0,0,0,ANSI_CHARSET,0,0,DEFAULT_QUALITY,DEFAULT_PITCH,NULL);
54 brush = CreateSolidBrush(RGB(255,255,255));
55 GetClientRect(hwnd, &rect);
57 hdc = BeginPaint(hwnd, &ps);
58 SelectObject(hdc, font);
59 SelectObject(hdc, brush);
60 Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
61 DrawTextA(hdc, "HTML rendering is currently disabled.",-1, &rect,
62 DT_CENTER | DT_SINGLELINE | DT_VCENTER);
69 static LRESULT WINAPI serverwnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
74 return DefWindowProcW(hwnd, msg, wParam, lParam);
77 static void register_serverwnd_class()
79 static WNDCLASSEXW wndclass = {
83 0, 0, NULL, NULL, NULL, NULL, NULL,
84 wszInternetExplorer_Server,
87 wndclass.hInstance = hInst;
88 serverwnd_class = RegisterClassExW(&wndclass);
92 /**********************************************************
93 * IOleDocumentView implementation
96 #define DOCVIEW_THIS \
97 HTMLDocument* const This=(HTMLDocument*)((char*)(iface)-offsetof(HTMLDocument,lpOleDocumentViewVtbl));
99 static HRESULT WINAPI OleDocumentView_QueryInterface(IOleDocumentView *iface, REFIID riid, void **ppvObject)
102 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
105 static ULONG WINAPI OleDocumentView_AddRef(IOleDocumentView *iface)
108 return IHTMLDocument2_AddRef(HTMLDOC(This));
111 static ULONG WINAPI OleDocumentView_Release(IOleDocumentView *iface)
114 return IHTMLDocument2_Release(HTMLDOC(This));
117 static HRESULT WINAPI OleDocumentView_SetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite *pIPSite)
120 TRACE("(%p)->(%p)\n", This, pIPSite);
126 IOleInPlaceSite_AddRef(pIPSite);
129 IOleInPlaceSite_Release(This->ipsite);
131 This->ipsite = pIPSite;
135 static HRESULT WINAPI OleDocumentView_GetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite **ppIPSite)
138 TRACE("(%p)->(%p)\n", This, ppIPSite);
144 IOleInPlaceSite_AddRef(This->ipsite);
146 *ppIPSite = This->ipsite;
150 static HRESULT WINAPI OleDocumentView_GetDocument(IOleDocumentView *iface, IUnknown **ppunk)
153 TRACE("(%p)->(%p)\n", This, ppunk);
158 IHTMLDocument2_AddRef(HTMLDOC(This));
159 *ppunk = (IUnknown*)HTMLDOC(This);
163 static HRESULT WINAPI OleDocumentView_SetRect(IOleDocumentView *iface, LPRECT prcView)
168 TRACE("(%p)->(%p)\n", This, prcView);
174 GetClientRect(This->hwnd, &rect);
175 if(memcmp(prcView, &rect, sizeof(RECT))) {
176 InvalidateRect(This->hwnd,NULL,TRUE);
177 SetWindowPos(This->hwnd, NULL, prcView->left, prcView->top, prcView->right,
178 prcView->bottom, SWP_NOZORDER | SWP_NOACTIVATE);
185 static HRESULT WINAPI OleDocumentView_GetRect(IOleDocumentView *iface, LPRECT prcView)
189 TRACE("(%p)->(%p)\n", This, prcView);
194 GetClientRect(This->hwnd, prcView);
198 static HRESULT WINAPI OleDocumentView_SetRectComplex(IOleDocumentView *iface, LPRECT prcView,
199 LPRECT prcHScroll, LPRECT prcVScroll, LPRECT prcSizeBox)
202 FIXME("(%p)->(%p %p %p %p)\n", This, prcView, prcHScroll, prcVScroll, prcSizeBox);
206 static HRESULT WINAPI OleDocumentView_Show(IOleDocumentView *iface, BOOL fShow)
209 FIXME("(%p)->(%x)\n", This, fShow);
213 static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL fUIActivate)
217 IOleInPlaceUIWindow *pIPWnd;
218 IOleInPlaceFrame *pIPFrame;
219 RECT posrect, cliprect;
220 OLEINPLACEFRAMEINFO frameinfo;
221 HWND parent_hwnd, hwnd;
223 TRACE("(%p)->(%x)\n", This, fUIActivate);
226 FIXME("This->ipsite = NULL\n");
234 register_serverwnd_class();
236 hres = IOleInPlaceSite_CanInPlaceActivate(This->ipsite);
238 WARN("CanInPlaceActivate returned: %08lx\n", hres);
239 return FAILED(hres) ? hres : E_FAIL;
242 hres = IOleInPlaceSite_GetWindowContext(This->ipsite, &pIPFrame, &pIPWnd, &posrect, &cliprect, &frameinfo);
244 WARN("GetWindowContext failed: %08lx\n", hres);
248 IOleInPlaceFrame_Release(pIPFrame);
250 IOleInPlaceUIWindow_Release(pIPWnd);
251 TRACE("got window context: %p %p {%ld %ld %ld %ld} {%ld %ld %ld %ld} {%d %x %p %p %d}\n",
252 pIPFrame, pIPWnd, posrect.left, posrect.top, posrect.right, posrect.bottom,
253 cliprect.left, cliprect.top, cliprect.right, cliprect.bottom,
254 frameinfo.cb, frameinfo.fMDIApp, frameinfo.hwndFrame, frameinfo.haccel, frameinfo.cAccelEntries);
256 hres = IOleInPlaceSite_GetWindow(This->ipsite, &parent_hwnd);
258 WARN("GetWindow failed: %08lx\n", hres);
262 hwnd = CreateWindowExW(0, wszInternetExplorer_Server, NULL,
263 WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
264 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
265 parent_hwnd, NULL, hInst, This);
267 hres = IOleInPlaceSite_OnInPlaceActivate(This->ipsite);
269 WARN("OnInPlaceActivate failed: %08lx\n", hres);
273 SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
274 SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_SHOWWINDOW);
275 RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE | RDW_ALLCHILDREN);
279 * Windows implementation calls:
280 * RegisterWindowMessage("MSWHEEL_ROLLMSG");
281 * SetTimer(This->hwnd, TIMER_ID, 100, NULL);
284 hres = IOleInPlaceSite_OnUIActivate(This->ipsite);
285 if(SUCCEEDED(hres)) {
286 /* IOleInPlaceFrame_SetActiveObject(pIPFrame, ACTOBJ(This->pDoc), wszHTMLDocument); */
288 FIXME("OnUIActivate failed: %08lx\n", hres);
294 FIXME("deactivating is not supported\n");
300 static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface)
303 FIXME("(%p)\n", This);
307 static HRESULT WINAPI OleDocumentView_CloseView(IOleDocumentView *iface, DWORD dwReserved)
310 FIXME("(%p)->(%lx)\n", This, dwReserved);
314 static HRESULT WINAPI OleDocumentView_SaveViewState(IOleDocumentView *iface, LPSTREAM pstm)
317 FIXME("(%p)->(%p)\n", This, pstm);
321 static HRESULT WINAPI OleDocumentView_ApplyViewState(IOleDocumentView *iface, LPSTREAM pstm)
324 FIXME("(%p)->(%p)\n", This, pstm);
328 static HRESULT WINAPI OleDocumentView_Clone(IOleDocumentView *iface, IOleInPlaceSite *pIPSiteNew,
329 IOleDocumentView **ppViewNew)
332 FIXME("(%p)->(%p %p)\n", This, pIPSiteNew, ppViewNew);
336 static IOleDocumentViewVtbl OleDocumentViewVtbl = {
337 OleDocumentView_QueryInterface,
338 OleDocumentView_AddRef,
339 OleDocumentView_Release,
340 OleDocumentView_SetInPlaceSite,
341 OleDocumentView_GetInPlaceSite,
342 OleDocumentView_GetDocument,
343 OleDocumentView_SetRect,
344 OleDocumentView_GetRect,
345 OleDocumentView_SetRectComplex,
346 OleDocumentView_Show,
347 OleDocumentView_UIActivate,
348 OleDocumentView_Open,
349 OleDocumentView_CloseView,
350 OleDocumentView_SaveViewState,
351 OleDocumentView_ApplyViewState,
352 OleDocumentView_Clone
355 void HTMLDocument_View_Init(HTMLDocument *This)
357 This->lpOleDocumentViewVtbl = &OleDocumentViewVtbl;