winenas.drv: Add workaround for INT64 type too.
[wine] / dlls / mshtml / olewnd.c
1 /*
2  * Copyright 2005 Jacek Caban
3  *
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.
8  *
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.
13  *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #define COBJMACROS
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30
31 #include "wine/debug.h"
32
33 #include "mshtml_private.h"
34 #include "resource.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37
38 /**********************************************************
39  * IOleInPlaceActiveObject implementation
40  */
41
42 #define ACTOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, OleInPlaceActiveObject, iface)
43
44 static HRESULT WINAPI OleInPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface, REFIID riid, void **ppvObject)
45 {
46     HTMLDocument *This = ACTOBJ_THIS(iface);
47     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
48 }
49
50 static ULONG WINAPI OleInPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
51 {
52     HTMLDocument *This = ACTOBJ_THIS(iface);
53     return IHTMLDocument2_AddRef(HTMLDOC(This));
54 }
55
56 static ULONG WINAPI OleInPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
57 {
58     HTMLDocument *This = ACTOBJ_THIS(iface);
59     return IHTMLDocument2_Release(HTMLDOC(This));
60 }
61
62 static HRESULT WINAPI OleInPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface, HWND *phwnd)
63 {
64     HTMLDocument *This = ACTOBJ_THIS(iface);
65
66     TRACE("(%p)->(%p)\n", This, phwnd);
67
68     if(!phwnd)
69         return E_INVALIDARG;
70
71     if(!This->in_place_active) {
72         *phwnd = NULL;
73         return E_FAIL;
74     }
75
76     *phwnd = This->hwnd;
77     return S_OK;
78 }
79
80 static HRESULT WINAPI OleInPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface, BOOL fEnterMode)
81 {
82     HTMLDocument *This = ACTOBJ_THIS(iface);
83     FIXME("(%p)->(%x)\n", This, fEnterMode);
84     return E_NOTIMPL;
85 }
86
87 static HRESULT WINAPI OleInPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface, LPMSG lpmsg)
88 {
89     HTMLDocument *This = ACTOBJ_THIS(iface);
90     FIXME("(%p)->(%p)\n", This, lpmsg);
91     return E_NOTIMPL;
92 }
93
94 static HRESULT WINAPI OleInPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface,
95         BOOL fActivate)
96 {
97     HTMLDocument *This = ACTOBJ_THIS(iface);
98
99     TRACE("(%p)->(%x)\n", This, fActivate);
100
101     if(This->hostui)
102         IDocHostUIHandler_OnFrameWindowActivate(This->hostui, fActivate);
103
104     if(fActivate && This->nscontainer)
105         nsIWebBrowserFocus_Activate(This->nscontainer->focus);
106
107     return S_OK;
108 }
109
110 static HRESULT WINAPI OleInPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface, BOOL fActivate)
111 {
112     HTMLDocument *This = ACTOBJ_THIS(iface);
113     FIXME("(%p)->(%x)\n", This, fActivate);
114     return E_NOTIMPL;
115 }
116
117 static HRESULT WINAPI OleInPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface, LPCRECT prcBorder,
118                                                 IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
119 {
120     HTMLDocument *This = ACTOBJ_THIS(iface);
121     FIXME("(%p)->(%p %p %x)\n", This, prcBorder, pUIWindow, fFrameWindow);
122     return E_NOTIMPL;
123 }
124
125 static HRESULT WINAPI OleInPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface, BOOL fEnable)
126 {
127     HTMLDocument *This = ACTOBJ_THIS(iface);
128     FIXME("(%p)->(%x)\n", This, fEnable);
129     return E_NOTIMPL;
130 }
131
132 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
133     OleInPlaceActiveObject_QueryInterface,
134     OleInPlaceActiveObject_AddRef,
135     OleInPlaceActiveObject_Release,
136     OleInPlaceActiveObject_GetWindow,
137     OleInPlaceActiveObject_ContextSensitiveHelp,
138     OleInPlaceActiveObject_TranslateAccelerator,
139     OleInPlaceActiveObject_OnFrameWindowActivate,
140     OleInPlaceActiveObject_OnDocWindowActivate,
141     OleInPlaceActiveObject_ResizeBorder,
142     OleInPlaceActiveObject_EnableModeless
143 };
144
145 #undef ACTOBJ_THIS
146
147 /**********************************************************
148  * IOleInPlaceObjectWindowless implementation
149  */
150
151 #define OLEINPLACEWND_THIS(iface) DEFINE_THIS(HTMLDocument, OleInPlaceObjectWindowless, iface)
152
153 static HRESULT WINAPI OleInPlaceObjectWindowless_QueryInterface(IOleInPlaceObjectWindowless *iface,
154         REFIID riid, void **ppvObject)
155 {
156     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
157     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
158 }
159
160 static ULONG WINAPI OleInPlaceObjectWindowless_AddRef(IOleInPlaceObjectWindowless *iface)
161 {
162     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
163     return IHTMLDocument2_AddRef(HTMLDOC(This));
164 }
165
166 static ULONG WINAPI OleInPlaceObjectWindowless_Release(IOleInPlaceObjectWindowless *iface)
167 {
168     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
169     return IHTMLDocument2_Release(HTMLDOC(This));
170 }
171
172 static HRESULT WINAPI OleInPlaceObjectWindowless_GetWindow(IOleInPlaceObjectWindowless *iface,
173         HWND *phwnd)
174 {
175     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
176     return IOleWindow_GetWindow(OLEWIN(This), phwnd);
177 }
178
179 static HRESULT WINAPI OleInPlaceObjectWindowless_ContextSensitiveHelp(IOleInPlaceObjectWindowless *iface,
180         BOOL fEnterMode)
181 {
182     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
183     return IOleWindow_ContextSensitiveHelp(OLEWIN(This), fEnterMode);
184 }
185
186 static HRESULT WINAPI OleInPlaceObjectWindowless_InPlaceDeactivate(IOleInPlaceObjectWindowless *iface)
187 {
188     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
189
190     TRACE("(%p)\n", This);
191
192     if(This->ui_active)
193         IOleDocumentView_UIActivate(DOCVIEW(This), FALSE);
194     This->window_active = FALSE;
195
196     if(!This->in_place_active)
197         return S_OK;
198
199     if(This->frame)
200         IOleInPlaceFrame_Release(This->frame);
201
202     if(This->hwnd) {
203         ShowWindow(This->hwnd, SW_HIDE);
204         SetWindowPos(This->hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
205     }
206
207     This->focus = FALSE;
208     notif_focus(This);
209
210     This->in_place_active = FALSE;
211     if(This->ipsite) {
212         IOleInPlaceSiteEx *ipsiteex;
213         HRESULT hres;
214
215         hres = IOleInPlaceSite_QueryInterface(This->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
216         if(SUCCEEDED(hres)) {
217             IOleInPlaceSiteEx_OnInPlaceDeactivateEx(ipsiteex, TRUE);
218             IOleInPlaceSiteEx_Release(ipsiteex);
219         }else {
220             IOleInPlaceSite_OnInPlaceDeactivate(This->ipsite);
221         }
222     }
223
224     return S_OK;
225 }
226
227 static HRESULT WINAPI OleInPlaceObjectWindowless_UIDeactivate(IOleInPlaceObjectWindowless *iface)
228 {
229     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
230     FIXME("(%p)\n", This);
231     return E_NOTIMPL;
232 }
233
234 static HRESULT WINAPI OleInPlaceObjectWindowless_SetObjectRects(IOleInPlaceObjectWindowless *iface,
235         LPCRECT lprcPosRect, LPCRECT lprcClipRect)
236 {
237     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
238     FIXME("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
239     return E_NOTIMPL;
240 }
241
242 static HRESULT WINAPI OleInPlaceObjectWindowless_ReactivateAndUndo(IOleInPlaceObjectWindowless *iface)
243 {
244     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
245     FIXME("(%p)\n", This);
246     return E_NOTIMPL;
247 }
248
249 static HRESULT WINAPI OleInPlaceObjectWindowless_OnWindowMessage(IOleInPlaceObjectWindowless *iface,
250         UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *lpResult)
251 {
252     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
253     FIXME("(%p)->(%u %lu %lu %p)\n", This, msg, wParam, lParam, lpResult);
254     return E_NOTIMPL;
255 }
256
257 static HRESULT WINAPI OleInPlaceObjectWindowless_GetDropTarget(IOleInPlaceObjectWindowless *iface,
258         IDropTarget **ppDropTarget)
259 {
260     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
261     FIXME("(%p)->(%p)\n", This, ppDropTarget);
262     return E_NOTIMPL;
263 }
264
265 static const IOleInPlaceObjectWindowlessVtbl OleInPlaceObjectWindowlessVtbl = {
266     OleInPlaceObjectWindowless_QueryInterface,
267     OleInPlaceObjectWindowless_AddRef,
268     OleInPlaceObjectWindowless_Release,
269     OleInPlaceObjectWindowless_GetWindow,
270     OleInPlaceObjectWindowless_ContextSensitiveHelp,
271     OleInPlaceObjectWindowless_InPlaceDeactivate,
272     OleInPlaceObjectWindowless_UIDeactivate,
273     OleInPlaceObjectWindowless_SetObjectRects,
274     OleInPlaceObjectWindowless_ReactivateAndUndo,
275     OleInPlaceObjectWindowless_OnWindowMessage,
276     OleInPlaceObjectWindowless_GetDropTarget
277 };
278
279 #undef INPLACEWIN_THIS
280
281 void HTMLDocument_Window_Init(HTMLDocument *This)
282 {
283     This->lpOleInPlaceActiveObjectVtbl = &OleInPlaceActiveObjectVtbl;
284     This->lpOleInPlaceObjectWindowlessVtbl = &OleInPlaceObjectWindowlessVtbl;
285 }