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
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
38 /**********************************************************
39 * IOleInPlaceActiveObject implementation
42 #define ACTOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, OleInPlaceActiveObject, iface)
44 static HRESULT WINAPI
OleInPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject
*iface
, REFIID riid
, void **ppvObject
)
46 HTMLDocument
*This
= ACTOBJ_THIS(iface
);
47 return IHTMLDocument2_QueryInterface(HTMLDOC(This
), riid
, ppvObject
);
50 static ULONG WINAPI
OleInPlaceActiveObject_AddRef(IOleInPlaceActiveObject
*iface
)
52 HTMLDocument
*This
= ACTOBJ_THIS(iface
);
53 return IHTMLDocument2_AddRef(HTMLDOC(This
));
56 static ULONG WINAPI
OleInPlaceActiveObject_Release(IOleInPlaceActiveObject
*iface
)
58 HTMLDocument
*This
= ACTOBJ_THIS(iface
);
59 return IHTMLDocument2_Release(HTMLDOC(This
));
62 static HRESULT WINAPI
OleInPlaceActiveObject_GetWindow(IOleInPlaceActiveObject
*iface
, HWND
*phwnd
)
64 HTMLDocument
*This
= ACTOBJ_THIS(iface
);
66 TRACE("(%p)->(%p)\n", This
, phwnd
);
71 if(!This
->in_place_active
) {
80 static HRESULT WINAPI
OleInPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject
*iface
, BOOL fEnterMode
)
82 HTMLDocument
*This
= ACTOBJ_THIS(iface
);
83 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
87 static HRESULT WINAPI
OleInPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject
*iface
, LPMSG lpmsg
)
89 HTMLDocument
*This
= ACTOBJ_THIS(iface
);
90 FIXME("(%p)->(%p)\n", This
, lpmsg
);
94 static HRESULT WINAPI
OleInPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject
*iface
, BOOL fActivate
)
96 HTMLDocument
*This
= ACTOBJ_THIS(iface
);
97 FIXME("(%p)->(%x)\n", This
, fActivate
);
101 static HRESULT WINAPI
OleInPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject
*iface
, BOOL fActivate
)
103 HTMLDocument
*This
= ACTOBJ_THIS(iface
);
104 FIXME("(%p)->(%x)\n", This
, fActivate
);
108 static HRESULT WINAPI
OleInPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject
*iface
, LPCRECT prcBorder
,
109 IOleInPlaceUIWindow
*pUIWindow
, BOOL fFrameWindow
)
111 HTMLDocument
*This
= ACTOBJ_THIS(iface
);
112 FIXME("(%p)->(%p %p %x)\n", This
, prcBorder
, pUIWindow
, fFrameWindow
);
116 static HRESULT WINAPI
OleInPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject
*iface
, BOOL fEnable
)
118 HTMLDocument
*This
= ACTOBJ_THIS(iface
);
119 FIXME("(%p)->(%x)\n", This
, fEnable
);
123 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl
= {
124 OleInPlaceActiveObject_QueryInterface
,
125 OleInPlaceActiveObject_AddRef
,
126 OleInPlaceActiveObject_Release
,
127 OleInPlaceActiveObject_GetWindow
,
128 OleInPlaceActiveObject_ContextSensitiveHelp
,
129 OleInPlaceActiveObject_TranslateAccelerator
,
130 OleInPlaceActiveObject_OnFrameWindowActivate
,
131 OleInPlaceActiveObject_OnDocWindowActivate
,
132 OleInPlaceActiveObject_ResizeBorder
,
133 OleInPlaceActiveObject_EnableModeless
138 /**********************************************************
139 * IOleInPlaceObjectWindowless implementation
142 #define OLEINPLACEWND_THIS(iface) DEFINE_THIS(HTMLDocument, OleInPlaceObjectWindowless, iface)
144 static HRESULT WINAPI
OleInPlaceObjectWindowless_QueryInterface(IOleInPlaceObjectWindowless
*iface
,
145 REFIID riid
, void **ppvObject
)
147 HTMLDocument
*This
= OLEINPLACEWND_THIS(iface
);
148 return IHTMLDocument2_QueryInterface(HTMLDOC(This
), riid
, ppvObject
);
151 static ULONG WINAPI
OleInPlaceObjectWindowless_AddRef(IOleInPlaceObjectWindowless
*iface
)
153 HTMLDocument
*This
= OLEINPLACEWND_THIS(iface
);
154 return IHTMLDocument2_AddRef(HTMLDOC(This
));
157 static ULONG WINAPI
OleInPlaceObjectWindowless_Release(IOleInPlaceObjectWindowless
*iface
)
159 HTMLDocument
*This
= OLEINPLACEWND_THIS(iface
);
160 return IHTMLDocument2_Release(HTMLDOC(This
));
163 static HRESULT WINAPI
OleInPlaceObjectWindowless_GetWindow(IOleInPlaceObjectWindowless
*iface
,
166 HTMLDocument
*This
= OLEINPLACEWND_THIS(iface
);
167 return IOleWindow_GetWindow(OLEWIN(This
), phwnd
);
170 static HRESULT WINAPI
OleInPlaceObjectWindowless_ContextSensitiveHelp(IOleInPlaceObjectWindowless
*iface
,
173 HTMLDocument
*This
= OLEINPLACEWND_THIS(iface
);
174 return IOleWindow_ContextSensitiveHelp(OLEWIN(This
), fEnterMode
);
177 static HRESULT WINAPI
OleInPlaceObjectWindowless_InPlaceDeactivate(IOleInPlaceObjectWindowless
*iface
)
179 HTMLDocument
*This
= OLEINPLACEWND_THIS(iface
);
181 TRACE("(%p)\n", This
);
184 IOleDocumentView_UIActivate(DOCVIEW(This
), FALSE
);
185 This
->window_active
= FALSE
;
187 if(!This
->in_place_active
)
191 IOleInPlaceFrame_Release(This
->frame
);
194 ShowWindow(This
->hwnd
, SW_HIDE
);
195 SetWindowPos(This
->hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
);
198 This
->in_place_active
= FALSE
;
200 IOleInPlaceSite_OnInPlaceDeactivate(This
->ipsite
);
205 static HRESULT WINAPI
OleInPlaceObjectWindowless_UIDeactivate(IOleInPlaceObjectWindowless
*iface
)
207 HTMLDocument
*This
= OLEINPLACEWND_THIS(iface
);
208 FIXME("(%p)\n", This
);
212 static HRESULT WINAPI
OleInPlaceObjectWindowless_SetObjectRects(IOleInPlaceObjectWindowless
*iface
,
213 LPCRECT lprcPosRect
, LPCRECT lprcClipRect
)
215 HTMLDocument
*This
= OLEINPLACEWND_THIS(iface
);
216 FIXME("(%p)->(%p %p)\n", This
, lprcPosRect
, lprcClipRect
);
220 static HRESULT WINAPI
OleInPlaceObjectWindowless_ReactivateAndUndo(IOleInPlaceObjectWindowless
*iface
)
222 HTMLDocument
*This
= OLEINPLACEWND_THIS(iface
);
223 FIXME("(%p)\n", This
);
227 static HRESULT WINAPI
OleInPlaceObjectWindowless_OnWindowMessage(IOleInPlaceObjectWindowless
*iface
,
228 UINT msg
, WPARAM wParam
, LPARAM lParam
, LRESULT
*lpResult
)
230 HTMLDocument
*This
= OLEINPLACEWND_THIS(iface
);
231 FIXME("(%p)->(%u %u %lu %p)\n", This
, msg
, wParam
, lParam
, lpResult
);
235 static HRESULT WINAPI
OleInPlaceObjectWindowless_GetDropTarget(IOleInPlaceObjectWindowless
*iface
,
236 IDropTarget
**ppDropTarget
)
238 HTMLDocument
*This
= OLEINPLACEWND_THIS(iface
);
239 FIXME("(%p)->(%p)\n", This
, ppDropTarget
);
243 static const IOleInPlaceObjectWindowlessVtbl OleInPlaceObjectWindowlessVtbl
= {
244 OleInPlaceObjectWindowless_QueryInterface
,
245 OleInPlaceObjectWindowless_AddRef
,
246 OleInPlaceObjectWindowless_Release
,
247 OleInPlaceObjectWindowless_GetWindow
,
248 OleInPlaceObjectWindowless_ContextSensitiveHelp
,
249 OleInPlaceObjectWindowless_InPlaceDeactivate
,
250 OleInPlaceObjectWindowless_UIDeactivate
,
251 OleInPlaceObjectWindowless_SetObjectRects
,
252 OleInPlaceObjectWindowless_ReactivateAndUndo
,
253 OleInPlaceObjectWindowless_OnWindowMessage
,
254 OleInPlaceObjectWindowless_GetDropTarget
257 #undef INPLACEWIN_THIS
259 void HTMLDocument_ShowContextMenu(HTMLDocument
*This
, DWORD dwID
, POINT
*ppt
)
261 HMENU menu_res
, menu
;
264 hres
= IDocHostUIHandler_ShowContextMenu(This
->hostui
, dwID
, ppt
,
265 (IUnknown
*)CMDTARGET(This
), (IDispatch
*)HTMLDOC(This
));
269 menu_res
= LoadMenuW(hInst
, MAKEINTRESOURCEW(IDR_BROWSE_CONTEXT_MENU
));
270 menu
= GetSubMenu(menu_res
, dwID
);
272 TrackPopupMenu(menu
, TPM_LEFTALIGN
| TPM_RIGHTBUTTON
| TPM_RETURNCMD
,
273 ppt
->x
, ppt
->y
, 0, This
->hwnd
, NULL
);
275 DestroyMenu(menu_res
);
278 void HTMLDocument_Window_Init(HTMLDocument
*This
)
280 This
->lpOleInPlaceActiveObjectVtbl
= &OleInPlaceActiveObjectVtbl
;
281 This
->lpOleInPlaceObjectWindowlessVtbl
= &OleInPlaceObjectWindowlessVtbl
;