wevtapi: Fix typo in spec file.
[wine/zf.git] / dlls / wmp / oleobj.c
blobcbbd965c38b3ce852e61ca773ca38e4771dfd7b6
1 /*
2 * Copyright 2014 Jacek Caban for CodeWeavers
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "wmp_private.h"
20 #include "olectl.h"
22 #include "wine/debug.h"
23 #include "wine/heap.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(wmp);
27 static HWND get_container_hwnd(WindowsMediaPlayer *This)
29 IOleWindow *ole_window;
30 HWND hwnd = NULL;
31 HRESULT hres;
33 /* IOleInPlaceSite (which inherits from IOleWindow) is preferred. */
34 hres = IOleClientSite_QueryInterface(This->client_site, &IID_IOleInPlaceSite, (void**)&ole_window);
35 if(FAILED(hres)) {
36 hres = IOleClientSite_QueryInterface(This->client_site, &IID_IOleWindow, (void**)&ole_window);
37 if(FAILED(hres)) {
38 IOleContainer *container = NULL;
40 hres = IOleClientSite_GetContainer(This->client_site, &container);
41 if(SUCCEEDED(hres)) {
42 hres = IOleContainer_QueryInterface(container, &IID_IOleWindow, (void**)&ole_window);
43 IOleContainer_Release(container);
48 if(FAILED(hres))
49 return NULL;
51 hres = IOleWindow_GetWindow(ole_window, &hwnd);
52 IOleWindow_Release(ole_window);
53 if(FAILED(hres))
54 return NULL;
56 TRACE("Got window %p\n", hwnd);
57 return hwnd;
60 static LRESULT WINAPI wmp_wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
62 switch(msg) {
63 case WM_PAINT: {
64 PAINTSTRUCT ps;
65 HFONT font;
66 RECT rect;
67 HDC hdc;
69 TRACE("WM_PAINT\n");
71 GetClientRect(hwnd, &rect);
72 hdc = BeginPaint(hwnd, &ps);
74 SelectObject(hdc, GetStockObject(DC_BRUSH));
75 SetDCBrushColor(hdc, RGB(255,0,0));
76 SetBkColor(hdc, RGB(255,0,0));
78 font = CreateFontA(25,0,0,0,400,0,0,0,ANSI_CHARSET,0,0,DEFAULT_QUALITY,DEFAULT_PITCH,NULL);
79 SelectObject(hdc, font);
81 Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
82 DrawTextA(hdc, "FIXME: WMP", -1, &rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER);
84 DeleteObject(font);
85 EndPaint(hwnd, &ps);
86 break;
90 return DefWindowProcW(hwnd, msg, wParam, lParam);
94 static ATOM wmp_class;
96 static BOOL WINAPI register_wmp_class(INIT_ONCE *once, void *param, void **context)
98 /* It seems that native uses ATL for this. We use a fake name to make tests happy. */
99 static const WCHAR atl_wmpW[] = {'A','T','L',':','W','M','P',0};
101 static WNDCLASSEXW wndclass = {
102 sizeof(wndclass), CS_DBLCLKS, wmp_wnd_proc, 0, 0,
103 NULL, NULL, NULL, NULL, NULL,
104 atl_wmpW, NULL
107 wndclass.hInstance = wmp_instance;
108 wmp_class = RegisterClassExW(&wndclass);
109 return TRUE;
112 void unregister_wmp_class(void)
114 if(wmp_class)
115 UnregisterClassW(MAKEINTRESOURCEW(wmp_class), wmp_instance);
118 static HWND create_wmp_window(WindowsMediaPlayer *wmp, const RECT *posrect)
120 static INIT_ONCE class_init_once = INIT_ONCE_STATIC_INIT;
122 InitOnceExecuteOnce(&class_init_once, register_wmp_class, NULL, NULL);
123 if(!wmp_class)
124 return NULL;
126 return CreateWindowExW(0, MAKEINTRESOURCEW(wmp_class), NULL, WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_VISIBLE|WS_CHILD,
127 posrect->left, posrect->top, posrect->right-posrect->left, posrect->bottom-posrect->top,
128 get_container_hwnd(wmp), NULL, wmp_instance, NULL);
131 static HRESULT activate_inplace(WindowsMediaPlayer *This)
133 IOleInPlaceSiteWindowless *ipsite_windowless;
134 IOleInPlaceSiteEx *ipsiteex = NULL;
135 IOleInPlaceSite *ipsite;
136 IOleInPlaceUIWindow *ip_window = NULL;
137 IOleInPlaceFrame *ip_frame = NULL;
138 RECT posrect = {0}, cliprect = {0};
139 OLEINPLACEFRAMEINFO frameinfo = { sizeof(frameinfo) };
140 HRESULT hres;
142 if(This->hwnd) {
143 FIXME("Already activated\n");
144 return E_UNEXPECTED;
147 hres = IOleClientSite_QueryInterface(This->client_site, &IID_IOleInPlaceSiteWindowless, (void**)&ipsite_windowless);
148 if(SUCCEEDED(hres)) {
149 hres = IOleInPlaceSiteWindowless_CanWindowlessActivate(ipsite_windowless);
150 IOleInPlaceSiteWindowless_Release(ipsite_windowless);
151 if(hres == S_OK)
152 FIXME("Windowless activation not supported\n");
153 ipsiteex = (IOleInPlaceSiteEx*)ipsite_windowless;
154 }else {
155 IOleClientSite_QueryInterface(This->client_site, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
158 if(ipsiteex) {
159 BOOL redraw = FALSE; /* Not really used. */
160 IOleInPlaceSiteEx_OnInPlaceActivateEx(ipsiteex, &redraw, 0);
161 ipsite = (IOleInPlaceSite*)ipsiteex;
162 }else {
163 IOleClientSite_QueryInterface(This->client_site, &IID_IOleInPlaceSite, (void**)&ipsite);
164 if(FAILED(hres)) {
165 FIXME("No IOleInPlaceSite instance\n");
166 return hres;
169 IOleInPlaceSite_OnInPlaceActivate(ipsite);
172 hres = IOleInPlaceSite_GetWindowContext(ipsite, &ip_frame, &ip_window, &posrect, &cliprect, &frameinfo);
173 IOleInPlaceSite_Release(ipsite);
174 if(FAILED(hres)) {
175 FIXME("GetWindowContext failed: %08x\n", hres);
176 return hres;
179 This->hwnd = create_wmp_window(This, &posrect);
180 if(!This->hwnd)
181 return E_FAIL;
183 IOleClientSite_ShowObject(This->client_site);
184 return S_OK;
187 static void deactivate_window(WindowsMediaPlayer *This)
189 IOleInPlaceSite *ip_site;
190 HRESULT hres;
192 hres = IOleClientSite_QueryInterface(This->client_site, &IID_IOleInPlaceSite, (void**)&ip_site);
193 if(SUCCEEDED(hres)) {
194 IOleInPlaceSite_OnInPlaceDeactivate(ip_site);
195 IOleInPlaceSite_Release(ip_site);
198 DestroyWindow(This->hwnd);
199 This->hwnd = NULL;
202 static void release_client_site(WindowsMediaPlayer *This)
204 if(!This->client_site)
205 return;
207 if(This->hwnd)
208 deactivate_window(This);
210 IOleClientSite_Release(This->client_site);
211 This->client_site = NULL;
214 static inline WindowsMediaPlayer *impl_from_IOleObject(IOleObject *iface)
216 return CONTAINING_RECORD(iface, WindowsMediaPlayer, IOleObject_iface);
219 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppv)
221 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
223 *ppv = NULL;
225 if(IsEqualGUID(riid, &IID_IUnknown)) {
226 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
227 *ppv = &This->IOleObject_iface;
228 }else if(IsEqualGUID(riid, &IID_IOleObject)) {
229 TRACE("(%p)->(IID_IOleObject %p)\n", This, ppv);
230 *ppv = &This->IOleObject_iface;
231 }else if(IsEqualGUID(riid, &IID_IProvideClassInfo)) {
232 TRACE("(%p)->(IID_IProvideClassInfo %p)\n", This, ppv);
233 *ppv = &This->IProvideClassInfo2_iface;
234 }else if(IsEqualGUID(riid, &IID_IProvideClassInfo2)) {
235 TRACE("(%p)->(IID_IProvideClassInfo2 %p)\n", This, ppv);
236 *ppv = &This->IProvideClassInfo2_iface;
237 }else if(IsEqualGUID(riid, &IID_IPersist)) {
238 TRACE("(%p)->(IID_IPersist %p)\n", This, ppv);
239 *ppv = &This->IPersistStreamInit_iface;
240 }else if(IsEqualGUID(riid, &IID_IPersistStreamInit)) {
241 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
242 *ppv = &This->IPersistStreamInit_iface;
243 }else if(IsEqualGUID(riid, &IID_IOleWindow)) {
244 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
245 *ppv = &This->IOleInPlaceObjectWindowless_iface;
246 }else if(IsEqualGUID(riid, &IID_IOleInPlaceObject)) {
247 TRACE("(%p)->(IID_IOleInPlaceObject %p)\n", This, ppv);
248 *ppv = &This->IOleInPlaceObjectWindowless_iface;
249 }else if(IsEqualGUID(riid, &IID_IOleInPlaceObjectWindowless)) {
250 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless %p)\n", This, ppv);
251 *ppv = &This->IOleInPlaceObjectWindowless_iface;
252 }else if(IsEqualGUID(riid, &IID_IConnectionPointContainer)) {
253 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
254 *ppv = &This->IConnectionPointContainer_iface;
255 }else if(IsEqualGUID(riid, &IID_IWMPCore)) {
256 TRACE("(%p)->(IID_IWMPCore %p)\n", This, ppv);
257 *ppv = &This->IWMPPlayer4_iface;
258 }else if(IsEqualGUID(riid, &IID_IWMPCore2)) {
259 TRACE("(%p)->(IID_IWMPCore2 %p)\n", This, ppv);
260 *ppv = &This->IWMPPlayer4_iface;
261 }else if(IsEqualGUID(riid, &IID_IWMPCore3)) {
262 TRACE("(%p)->(IID_IWMPCore3 %p)\n", This, ppv);
263 *ppv = &This->IWMPPlayer4_iface;
264 }else if(IsEqualGUID(riid, &IID_IWMPPlayer4)) {
265 TRACE("(%p)->(IID_IWMPPlayer4 %p)\n", This, ppv);
266 *ppv = &This->IWMPPlayer4_iface;
267 }else if(IsEqualGUID(riid, &IID_IWMPPlayer)) {
268 TRACE("(%p)->(IID_IWMPPlayer %p)\n", This, ppv);
269 *ppv = &This->IWMPPlayer_iface;
270 }else if(IsEqualGUID(riid, &IID_IWMPSettings)) {
271 TRACE("(%p)->(IID_IWMPSettings %p)\n", This, ppv);
272 *ppv = &This->IWMPSettings_iface;
273 }else if(IsEqualGUID(riid, &IID_IOleControl)) {
274 TRACE("(%p)->(IID_IOleControl %p)\n", This, ppv);
275 *ppv = &This->IOleControl_iface;
276 }else if(IsEqualGUID(riid, &IID_IMarshal)) {
277 TRACE("(%p)->(IID_IMarshal %p)\n", This, ppv);
278 return E_NOINTERFACE;
279 }else if(IsEqualGUID(riid, &IID_IQuickActivate)) {
280 TRACE("(%p)->(IID_IQuickActivate %p)\n", This, ppv);
281 return E_NOINTERFACE;
282 }else {
283 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
284 return E_NOINTERFACE;
287 IUnknown_AddRef((IUnknown*)*ppv);
288 return S_OK;
291 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
293 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
294 LONG ref = InterlockedIncrement(&This->ref);
296 TRACE("(%p) ref=%d\n", This, ref);
298 return ref;
301 static ULONG WINAPI OleObject_Release(IOleObject *iface)
303 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
304 LONG ref = InterlockedDecrement(&This->ref);
306 TRACE("(%p) ref=%d\n", This, ref);
308 if(!ref) {
309 release_client_site(This);
310 destroy_player(This);
311 ConnectionPointContainer_Destroy(This);
312 heap_free(This);
315 return ref;
318 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite *pClientSite)
320 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
321 IOleControlSite *control_site;
322 HRESULT hres;
324 TRACE("(%p)->(%p)\n", This, pClientSite);
326 release_client_site(This);
327 if(!pClientSite)
328 return S_OK;
330 IOleClientSite_AddRef(pClientSite);
331 This->client_site = pClientSite;
333 hres = IOleClientSite_QueryInterface(pClientSite, &IID_IOleControlSite, (void**)&control_site);
334 if(SUCCEEDED(hres)) {
335 IDispatch *disp;
337 hres = IOleControlSite_GetExtendedControl(control_site, &disp);
338 if(SUCCEEDED(hres) && disp) {
339 FIXME("Use extended control\n");
340 IDispatch_Release(disp);
343 IOleControlSite_Release(control_site);
346 return S_OK;
349 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, IOleClientSite **ppClientSite)
351 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
353 TRACE("(%p)->(%p)\n", This, ppClientSite);
355 *ppClientSite = This->client_site;
356 return This->client_site ? S_OK : E_FAIL;
359 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
361 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
362 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
363 return E_NOTIMPL;
366 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
368 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
370 TRACE("(%p)->(%08x)\n", This, dwSaveOption);
372 if(dwSaveOption)
373 FIXME("Unsupported option %d\n", dwSaveOption);
375 if(This->hwnd) /* FIXME: Possibly hide window */
376 deactivate_window(This);
377 return S_OK;
380 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker *pmk)
382 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
383 FIXME("(%p %d %p)->()\n", This, dwWhichMoniker, pmk);
384 return E_NOTIMPL;
387 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
389 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
390 FIXME("(%p)->(%d %d %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
391 return E_NOTIMPL;
394 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, IDataObject *pDataObject, BOOL fCreation,
395 DWORD dwReserved)
397 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
398 FIXME("(%p)->(%p %x %d)\n", This, pDataObject, fCreation, dwReserved);
399 return E_NOTIMPL;
402 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved, IDataObject **ppDataObject)
404 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
405 FIXME("(%p)->(%d %p)\n", This, dwReserved, ppDataObject);
406 return E_NOTIMPL;
409 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite,
410 LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
412 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
414 switch(iVerb) {
415 case OLEIVERB_INPLACEACTIVATE:
416 TRACE("(%p)->(OLEIVERB_INPLACEACTIVATE)\n", This);
417 return activate_inplace(This);
419 case OLEIVERB_HIDE:
420 if(!This->hwnd) {
421 FIXME("No window to hide\n");
422 return E_UNEXPECTED;
425 ShowWindow(This->hwnd, SW_HIDE);
426 return S_OK;
428 default:
429 FIXME("Unsupported iVerb %d\n", iVerb);
432 return E_NOTIMPL;
435 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
437 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
438 FIXME("(%p)->(%p)\n", This, ppEnumOleVerb);
439 return E_NOTIMPL;
442 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
444 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
445 FIXME("(%p)\n", This);
446 return E_NOTIMPL;
449 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
451 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
452 FIXME("(%p)\n", This);
453 return E_NOTIMPL;
456 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID *pClsid)
458 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
459 FIXME("(%p)->(%p)\n", This, pClsid);
460 return E_NOTIMPL;
463 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType, LPOLESTR *pszUserType)
465 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
466 FIXME("(%p)->(%d %p)\n", This, dwFormOfType, pszUserType);
467 return E_NOTIMPL;
470 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
472 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
474 TRACE("(%p)->(%d %p)\n", This, dwDrawAspect, psizel);
476 if(dwDrawAspect != DVASPECT_CONTENT)
477 return DV_E_DVASPECT;
479 This->extent = *psizel;
480 return S_OK;
483 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
485 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
487 TRACE("(%p)->(%d %p)\n", This, dwDrawAspect, psizel);
489 if(dwDrawAspect != DVASPECT_CONTENT)
490 return E_FAIL;
492 *psizel = This->extent;
493 return S_OK;
496 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink, DWORD *pdwConnection)
498 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
499 FIXME("(%p)->(%p %p)\n", This, pAdvSink, pdwConnection);
500 return E_NOTIMPL;
503 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
505 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
506 FIXME("(%p)->(%d)\n", This, dwConnection);
507 return E_NOTIMPL;
510 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
512 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
513 FIXME("(%p)->(%p)\n", This, ppenumAdvise);
514 return E_NOTIMPL;
517 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
519 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
521 TRACE("(%p)->(%d %p)\n", This, dwAspect, pdwStatus);
523 switch(dwAspect) {
524 case DVASPECT_CONTENT:
525 *pdwStatus = OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
526 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE;
527 break;
528 default:
529 FIXME("Unhandled aspect %d\n", dwAspect);
530 return E_NOTIMPL;
533 return S_OK;
536 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE *pLogpal)
538 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
539 FIXME("(%p)->(%p)\n", This, pLogpal);
540 return E_NOTIMPL;
543 static const IOleObjectVtbl OleObjectVtbl = {
544 OleObject_QueryInterface,
545 OleObject_AddRef,
546 OleObject_Release,
547 OleObject_SetClientSite,
548 OleObject_GetClientSite,
549 OleObject_SetHostNames,
550 OleObject_Close,
551 OleObject_SetMoniker,
552 OleObject_GetMoniker,
553 OleObject_InitFromData,
554 OleObject_GetClipboardData,
555 OleObject_DoVerb,
556 OleObject_EnumVerbs,
557 OleObject_Update,
558 OleObject_IsUpToDate,
559 OleObject_GetUserClassID,
560 OleObject_GetUserType,
561 OleObject_SetExtent,
562 OleObject_GetExtent,
563 OleObject_Advise,
564 OleObject_Unadvise,
565 OleObject_EnumAdvise,
566 OleObject_GetMiscStatus,
567 OleObject_SetColorScheme
570 static inline WindowsMediaPlayer *impl_from_IOleInPlaceObjectWindowless(IOleInPlaceObjectWindowless *iface)
572 return CONTAINING_RECORD(iface, WindowsMediaPlayer, IOleInPlaceObjectWindowless_iface);
575 static HRESULT WINAPI OleInPlaceObjectWindowless_QueryInterface(IOleInPlaceObjectWindowless *iface,
576 REFIID riid, void **ppv)
578 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
579 return IOleObject_QueryInterface(&This->IOleObject_iface, riid, ppv);
582 static ULONG WINAPI OleInPlaceObjectWindowless_AddRef(IOleInPlaceObjectWindowless *iface)
584 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
585 return IOleObject_AddRef(&This->IOleObject_iface);
588 static ULONG WINAPI OleInPlaceObjectWindowless_Release(IOleInPlaceObjectWindowless *iface)
590 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
591 return IOleObject_Release(&This->IOleObject_iface);
594 static HRESULT WINAPI OleInPlaceObjectWindowless_GetWindow(IOleInPlaceObjectWindowless *iface, HWND *phwnd)
596 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
598 TRACE("(%p)->(%p)\n", This, phwnd);
600 *phwnd = This->hwnd;
601 return This->hwnd ? S_OK : E_UNEXPECTED;
604 static HRESULT WINAPI OleInPlaceObjectWindowless_ContextSensitiveHelp(IOleInPlaceObjectWindowless *iface,
605 BOOL fEnterMode)
607 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
608 FIXME("(%p)->(%x)\n", This, fEnterMode);
609 return E_NOTIMPL;
612 static HRESULT WINAPI OleInPlaceObjectWindowless_InPlaceDeactivate(IOleInPlaceObjectWindowless *iface)
614 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
615 FIXME("(%p)\n", This);
616 return E_NOTIMPL;
619 static HRESULT WINAPI OleInPlaceObjectWindowless_UIDeactivate(IOleInPlaceObjectWindowless *iface)
621 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
622 FIXME("(%p)\n", This);
623 return E_NOTIMPL;
626 static HRESULT WINAPI OleInPlaceObjectWindowless_SetObjectRects(IOleInPlaceObjectWindowless *iface,
627 LPCRECT lprcPosRect, LPCRECT lprcClipRect)
629 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
631 TRACE("(%p)->(%s %s)\n", This, wine_dbgstr_rect(lprcPosRect), wine_dbgstr_rect(lprcClipRect));
633 if(This->hwnd) {
634 SetWindowPos(This->hwnd, NULL, lprcPosRect->left, lprcPosRect->top,
635 lprcPosRect->right-lprcPosRect->left, lprcPosRect->bottom-lprcPosRect->top,
636 SWP_NOZORDER | SWP_NOACTIVATE);
639 return S_OK;
642 static HRESULT WINAPI OleInPlaceObjectWindowless_ReactivateAndUndo(IOleInPlaceObjectWindowless *iface)
644 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
645 FIXME("(%p)\n", This);
646 return E_NOTIMPL;
649 static HRESULT WINAPI OleInPlaceObjectWindowless_OnWindowMessage(IOleInPlaceObjectWindowless *iface,
650 UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *lpResult)
652 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
653 FIXME("(%p)->(%u %lu %lu %p)\n", This, msg, wParam, lParam, lpResult);
654 return E_NOTIMPL;
657 static HRESULT WINAPI OleInPlaceObjectWindowless_GetDropTarget(IOleInPlaceObjectWindowless *iface,
658 IDropTarget **ppDropTarget)
660 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
661 FIXME("(%p)->(%p)\n", This, ppDropTarget);
662 return E_NOTIMPL;
665 static const IOleInPlaceObjectWindowlessVtbl OleInPlaceObjectWindowlessVtbl = {
666 OleInPlaceObjectWindowless_QueryInterface,
667 OleInPlaceObjectWindowless_AddRef,
668 OleInPlaceObjectWindowless_Release,
669 OleInPlaceObjectWindowless_GetWindow,
670 OleInPlaceObjectWindowless_ContextSensitiveHelp,
671 OleInPlaceObjectWindowless_InPlaceDeactivate,
672 OleInPlaceObjectWindowless_UIDeactivate,
673 OleInPlaceObjectWindowless_SetObjectRects,
674 OleInPlaceObjectWindowless_ReactivateAndUndo,
675 OleInPlaceObjectWindowless_OnWindowMessage,
676 OleInPlaceObjectWindowless_GetDropTarget
679 static inline WindowsMediaPlayer *impl_from_IOleControl(IOleControl *iface)
681 return CONTAINING_RECORD(iface, WindowsMediaPlayer, IOleControl_iface);
684 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface, REFIID riid, void **ppv)
686 WindowsMediaPlayer *This = impl_from_IOleControl(iface);
687 return IOleObject_QueryInterface(&This->IOleObject_iface, riid, ppv);
690 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
692 WindowsMediaPlayer *This = impl_from_IOleControl(iface);
693 return IOleObject_AddRef(&This->IOleObject_iface);
696 static ULONG WINAPI OleControl_Release(IOleControl *iface)
698 WindowsMediaPlayer *This = impl_from_IOleControl(iface);
699 return IOleObject_Release(&This->IOleObject_iface);
702 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, CONTROLINFO *pCI)
704 WindowsMediaPlayer *This = impl_from_IOleControl(iface);
705 FIXME("(%p)->(%p)\n", This, pCI);
706 return E_NOTIMPL;
709 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, MSG *msg)
711 WindowsMediaPlayer *This = impl_from_IOleControl(iface);
712 FIXME("(%p)->(%p)\n", This, msg);
713 return E_NOTIMPL;
716 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
718 WindowsMediaPlayer *This = impl_from_IOleControl(iface);
719 FIXME("(%p)->(%d)\n", This, dispID);
720 return E_NOTIMPL;
723 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL freeze)
725 WindowsMediaPlayer *This = impl_from_IOleControl(iface);
726 FIXME("(%p)->(%x)\n", This, freeze);
727 return E_NOTIMPL;
730 static const IOleControlVtbl OleControlVtbl = {
731 OleControl_QueryInterface,
732 OleControl_AddRef,
733 OleControl_Release,
734 OleControl_GetControlInfo,
735 OleControl_OnMnemonic,
736 OleControl_OnAmbientPropertyChange,
737 OleControl_FreezeEvents
740 static inline WindowsMediaPlayer *impl_from_IProvideClassInfo2(IProvideClassInfo2 *iface)
742 return CONTAINING_RECORD(iface, WindowsMediaPlayer, IProvideClassInfo2_iface);
745 static HRESULT WINAPI ProvideClassInfo2_QueryInterface(IProvideClassInfo2 *iface, REFIID riid, void **ppv)
747 WindowsMediaPlayer *This = impl_from_IProvideClassInfo2(iface);
748 return IOleObject_QueryInterface(&This->IOleObject_iface, riid, ppv);
751 static ULONG WINAPI ProvideClassInfo2_AddRef(IProvideClassInfo2 *iface)
753 WindowsMediaPlayer *This = impl_from_IProvideClassInfo2(iface);
754 return IOleObject_AddRef(&This->IOleObject_iface);
757 static ULONG WINAPI ProvideClassInfo2_Release(IProvideClassInfo2 *iface)
759 WindowsMediaPlayer *This = impl_from_IProvideClassInfo2(iface);
760 return IOleObject_Release(&This->IOleObject_iface);
763 static HRESULT WINAPI ProvideClassInfo2_GetClassInfo(IProvideClassInfo2 *iface, ITypeInfo **ti)
765 WindowsMediaPlayer *This = impl_from_IProvideClassInfo2(iface);
767 TRACE("(%p)->(%p)\n", This, ti);
769 if (!ti)
770 return E_POINTER;
772 return get_typeinfo(WindowsMediaPlayer_tid, ti);
775 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideClassInfo2 *iface, DWORD dwGuidKind, GUID *pGUID)
777 WindowsMediaPlayer *This = impl_from_IProvideClassInfo2(iface);
779 TRACE("(%p)->(%d %p)\n", This, dwGuidKind, pGUID);
781 if(dwGuidKind != GUIDKIND_DEFAULT_SOURCE_DISP_IID) {
782 FIXME("Unexpected dwGuidKind %d\n", dwGuidKind);
783 return E_INVALIDARG;
786 *pGUID = IID__WMPOCXEvents;
787 return S_OK;
790 static const IProvideClassInfo2Vtbl ProvideClassInfo2Vtbl = {
791 ProvideClassInfo2_QueryInterface,
792 ProvideClassInfo2_AddRef,
793 ProvideClassInfo2_Release,
794 ProvideClassInfo2_GetClassInfo,
795 ProvideClassInfo2_GetGUID
798 static inline WindowsMediaPlayer *impl_from_IPersistStreamInit(IPersistStreamInit *iface)
800 return CONTAINING_RECORD(iface, WindowsMediaPlayer, IPersistStreamInit_iface);
803 static HRESULT WINAPI PersistStreamInit_QueryInterface(IPersistStreamInit *iface,
804 REFIID riid, void **ppv)
806 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
807 return IOleObject_QueryInterface(&This->IOleObject_iface, riid, ppv);
810 static ULONG WINAPI PersistStreamInit_AddRef(IPersistStreamInit *iface)
812 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
813 return IOleObject_AddRef(&This->IOleObject_iface);
816 static ULONG WINAPI PersistStreamInit_Release(IPersistStreamInit *iface)
818 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
819 return IOleObject_Release(&This->IOleObject_iface);
822 static HRESULT WINAPI PersistStreamInit_GetClassID(IPersistStreamInit *iface, CLSID *pClassID)
824 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
825 FIXME("(%p)->(%p)\n", This, pClassID);
826 return E_NOTIMPL;
829 static HRESULT WINAPI PersistStreamInit_IsDirty(IPersistStreamInit *iface)
831 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
832 FIXME("(%p)\n", This);
833 return E_NOTIMPL;
836 static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, LPSTREAM pStm)
838 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
839 FIXME("(%p)->(%p)\n", This, pStm);
840 return E_NOTIMPL;
843 static HRESULT WINAPI PersistStreamInit_Save(IPersistStreamInit *iface, LPSTREAM pStm,
844 BOOL fClearDirty)
846 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
847 FIXME("(%p)->(%p %x)\n", This, pStm, fClearDirty);
848 return E_NOTIMPL;
851 static HRESULT WINAPI PersistStreamInit_GetSizeMax(IPersistStreamInit *iface,
852 ULARGE_INTEGER *pcbSize)
854 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
855 FIXME("(%p)->(%p)\n", This, pcbSize);
856 return E_NOTIMPL;
859 static HRESULT WINAPI PersistStreamInit_InitNew(IPersistStreamInit *iface)
861 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
863 TRACE("(%p)\n", This);
865 if(!This->client_site)
866 return E_FAIL;
868 /* Nothing to do, yet. */
869 get_container_hwnd(This);
870 return S_OK;
873 static const IPersistStreamInitVtbl PersistStreamInitVtbl = {
874 PersistStreamInit_QueryInterface,
875 PersistStreamInit_AddRef,
876 PersistStreamInit_Release,
877 PersistStreamInit_GetClassID,
878 PersistStreamInit_IsDirty,
879 PersistStreamInit_Load,
880 PersistStreamInit_Save,
881 PersistStreamInit_GetSizeMax,
882 PersistStreamInit_InitNew
885 HRESULT WINAPI WMPFactory_CreateInstance(IClassFactory *iface, IUnknown *outer,
886 REFIID riid, void **ppv)
888 WindowsMediaPlayer *wmp;
889 DWORD dpi_x, dpi_y;
890 HDC hdc;
891 HRESULT hres;
893 TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
895 wmp = heap_alloc_zero(sizeof(*wmp));
896 if(!wmp)
897 return E_OUTOFMEMORY;
899 wmp->IOleObject_iface.lpVtbl = &OleObjectVtbl;
900 wmp->IProvideClassInfo2_iface.lpVtbl = &ProvideClassInfo2Vtbl;
901 wmp->IPersistStreamInit_iface.lpVtbl = &PersistStreamInitVtbl;
902 wmp->IOleInPlaceObjectWindowless_iface.lpVtbl = &OleInPlaceObjectWindowlessVtbl;
903 wmp->IOleControl_iface.lpVtbl = &OleControlVtbl;
905 wmp->ref = 1;
907 if (init_player(wmp)) {
908 ConnectionPointContainer_Init(wmp);
909 hdc = GetDC(0);
910 dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
911 dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
912 ReleaseDC(0, hdc);
914 wmp->extent.cx = MulDiv(192, 2540, dpi_x);
915 wmp->extent.cy = MulDiv(192, 2540, dpi_y);
917 hres = IOleObject_QueryInterface(&wmp->IOleObject_iface, riid, ppv);
918 } else {
919 hres = E_FAIL;
921 IOleObject_Release(&wmp->IOleObject_iface);
922 return hres;