winedump: Dump MSC's S_UNAMESPACE entries.
[wine.git] / dlls / wmp / oleobj.c
blob04a9f204639f3482746694e79b506eead6c57876
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 static WNDCLASSEXW wndclass = {
99 sizeof(wndclass), CS_DBLCLKS, wmp_wnd_proc, 0, 0,
100 NULL, NULL, NULL, NULL, NULL,
101 /* It seems that native uses ATL for this. We use a fake name to make tests happy. */
102 L"ATL:WMP", NULL
105 wndclass.hInstance = wmp_instance;
106 wmp_class = RegisterClassExW(&wndclass);
107 return TRUE;
110 void unregister_wmp_class(void)
112 if(wmp_class)
113 UnregisterClassW(MAKEINTRESOURCEW(wmp_class), wmp_instance);
116 static HWND create_wmp_window(WindowsMediaPlayer *wmp, const RECT *posrect)
118 static INIT_ONCE class_init_once = INIT_ONCE_STATIC_INIT;
120 InitOnceExecuteOnce(&class_init_once, register_wmp_class, NULL, NULL);
121 if(!wmp_class)
122 return NULL;
124 return CreateWindowExW(0, MAKEINTRESOURCEW(wmp_class), NULL, WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_VISIBLE|WS_CHILD,
125 posrect->left, posrect->top, posrect->right-posrect->left, posrect->bottom-posrect->top,
126 get_container_hwnd(wmp), NULL, wmp_instance, NULL);
129 static HRESULT activate_inplace(WindowsMediaPlayer *This)
131 IOleInPlaceSiteWindowless *ipsite_windowless;
132 IOleInPlaceSiteEx *ipsiteex = NULL;
133 IOleInPlaceSite *ipsite;
134 IOleInPlaceUIWindow *ip_window = NULL;
135 IOleInPlaceFrame *ip_frame = NULL;
136 RECT posrect = {0}, cliprect = {0};
137 OLEINPLACEFRAMEINFO frameinfo = { sizeof(frameinfo) };
138 HRESULT hres;
140 if(This->hwnd) {
141 FIXME("Already activated\n");
142 return E_UNEXPECTED;
145 hres = IOleClientSite_QueryInterface(This->client_site, &IID_IOleInPlaceSiteWindowless, (void**)&ipsite_windowless);
146 if(SUCCEEDED(hres)) {
147 hres = IOleInPlaceSiteWindowless_CanWindowlessActivate(ipsite_windowless);
148 IOleInPlaceSiteWindowless_Release(ipsite_windowless);
149 if(hres == S_OK)
150 FIXME("Windowless activation not supported\n");
151 ipsiteex = (IOleInPlaceSiteEx*)ipsite_windowless;
152 }else {
153 IOleClientSite_QueryInterface(This->client_site, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
156 if(ipsiteex) {
157 BOOL redraw = FALSE; /* Not really used. */
158 IOleInPlaceSiteEx_OnInPlaceActivateEx(ipsiteex, &redraw, 0);
159 ipsite = (IOleInPlaceSite*)ipsiteex;
160 }else {
161 IOleClientSite_QueryInterface(This->client_site, &IID_IOleInPlaceSite, (void**)&ipsite);
162 if(FAILED(hres)) {
163 FIXME("No IOleInPlaceSite instance\n");
164 return hres;
167 IOleInPlaceSite_OnInPlaceActivate(ipsite);
170 hres = IOleInPlaceSite_GetWindowContext(ipsite, &ip_frame, &ip_window, &posrect, &cliprect, &frameinfo);
171 IOleInPlaceSite_Release(ipsite);
172 if(FAILED(hres)) {
173 FIXME("GetWindowContext failed: %08x\n", hres);
174 return hres;
177 This->hwnd = create_wmp_window(This, &posrect);
178 if(!This->hwnd)
179 return E_FAIL;
181 IOleClientSite_ShowObject(This->client_site);
182 return S_OK;
185 static void deactivate_window(WindowsMediaPlayer *This)
187 IOleInPlaceSite *ip_site;
188 HRESULT hres;
190 hres = IOleClientSite_QueryInterface(This->client_site, &IID_IOleInPlaceSite, (void**)&ip_site);
191 if(SUCCEEDED(hres)) {
192 IOleInPlaceSite_OnInPlaceDeactivate(ip_site);
193 IOleInPlaceSite_Release(ip_site);
196 DestroyWindow(This->hwnd);
197 This->hwnd = NULL;
200 static void release_client_site(WindowsMediaPlayer *This)
202 if(!This->client_site)
203 return;
205 if(This->hwnd)
206 deactivate_window(This);
208 IOleClientSite_Release(This->client_site);
209 This->client_site = NULL;
212 static inline WindowsMediaPlayer *impl_from_IOleObject(IOleObject *iface)
214 return CONTAINING_RECORD(iface, WindowsMediaPlayer, IOleObject_iface);
217 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppv)
219 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
221 *ppv = NULL;
223 if(IsEqualGUID(riid, &IID_IUnknown)) {
224 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
225 *ppv = &This->IOleObject_iface;
226 }else if(IsEqualGUID(riid, &IID_IOleObject)) {
227 TRACE("(%p)->(IID_IOleObject %p)\n", This, ppv);
228 *ppv = &This->IOleObject_iface;
229 }else if(IsEqualGUID(riid, &IID_IProvideClassInfo)) {
230 TRACE("(%p)->(IID_IProvideClassInfo %p)\n", This, ppv);
231 *ppv = &This->IProvideClassInfo2_iface;
232 }else if(IsEqualGUID(riid, &IID_IProvideClassInfo2)) {
233 TRACE("(%p)->(IID_IProvideClassInfo2 %p)\n", This, ppv);
234 *ppv = &This->IProvideClassInfo2_iface;
235 }else if(IsEqualGUID(riid, &IID_IPersist)) {
236 TRACE("(%p)->(IID_IPersist %p)\n", This, ppv);
237 *ppv = &This->IPersistStreamInit_iface;
238 }else if(IsEqualGUID(riid, &IID_IPersistStreamInit)) {
239 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
240 *ppv = &This->IPersistStreamInit_iface;
241 }else if(IsEqualGUID(riid, &IID_IOleWindow)) {
242 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
243 *ppv = &This->IOleInPlaceObjectWindowless_iface;
244 }else if(IsEqualGUID(riid, &IID_IOleInPlaceObject)) {
245 TRACE("(%p)->(IID_IOleInPlaceObject %p)\n", This, ppv);
246 *ppv = &This->IOleInPlaceObjectWindowless_iface;
247 }else if(IsEqualGUID(riid, &IID_IOleInPlaceObjectWindowless)) {
248 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless %p)\n", This, ppv);
249 *ppv = &This->IOleInPlaceObjectWindowless_iface;
250 }else if(IsEqualGUID(riid, &IID_IConnectionPointContainer)) {
251 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
252 *ppv = &This->IConnectionPointContainer_iface;
253 }else if(IsEqualGUID(riid, &IID_IWMPCore)) {
254 TRACE("(%p)->(IID_IWMPCore %p)\n", This, ppv);
255 *ppv = &This->IWMPPlayer4_iface;
256 }else if(IsEqualGUID(riid, &IID_IWMPCore2)) {
257 TRACE("(%p)->(IID_IWMPCore2 %p)\n", This, ppv);
258 *ppv = &This->IWMPPlayer4_iface;
259 }else if(IsEqualGUID(riid, &IID_IWMPCore3)) {
260 TRACE("(%p)->(IID_IWMPCore3 %p)\n", This, ppv);
261 *ppv = &This->IWMPPlayer4_iface;
262 }else if(IsEqualGUID(riid, &IID_IWMPPlayer4)) {
263 TRACE("(%p)->(IID_IWMPPlayer4 %p)\n", This, ppv);
264 *ppv = &This->IWMPPlayer4_iface;
265 }else if(IsEqualGUID(riid, &IID_IWMPPlayer)) {
266 TRACE("(%p)->(IID_IWMPPlayer %p)\n", This, ppv);
267 *ppv = &This->IWMPPlayer_iface;
268 }else if(IsEqualGUID(riid, &IID_IWMPSettings)) {
269 TRACE("(%p)->(IID_IWMPSettings %p)\n", This, ppv);
270 *ppv = &This->IWMPSettings_iface;
271 }else if(IsEqualGUID(riid, &IID_IOleControl)) {
272 TRACE("(%p)->(IID_IOleControl %p)\n", This, ppv);
273 *ppv = &This->IOleControl_iface;
274 }else if(IsEqualGUID(riid, &IID_IMarshal)) {
275 TRACE("(%p)->(IID_IMarshal %p)\n", This, ppv);
276 return E_NOINTERFACE;
277 }else if(IsEqualGUID(riid, &IID_IQuickActivate)) {
278 TRACE("(%p)->(IID_IQuickActivate %p)\n", This, ppv);
279 return E_NOINTERFACE;
280 }else {
281 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
282 return E_NOINTERFACE;
285 IUnknown_AddRef((IUnknown*)*ppv);
286 return S_OK;
289 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
291 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
292 LONG ref = InterlockedIncrement(&This->ref);
294 TRACE("(%p) ref=%d\n", This, ref);
296 return ref;
299 static ULONG WINAPI OleObject_Release(IOleObject *iface)
301 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
302 LONG ref = InterlockedDecrement(&This->ref);
304 TRACE("(%p) ref=%d\n", This, ref);
306 if(!ref) {
307 release_client_site(This);
308 destroy_player(This);
309 ConnectionPointContainer_Destroy(This);
310 heap_free(This);
313 return ref;
316 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite *pClientSite)
318 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
319 IOleControlSite *control_site;
320 HRESULT hres;
322 TRACE("(%p)->(%p)\n", This, pClientSite);
324 release_client_site(This);
325 if(!pClientSite)
326 return S_OK;
328 IOleClientSite_AddRef(pClientSite);
329 This->client_site = pClientSite;
331 hres = IOleClientSite_QueryInterface(pClientSite, &IID_IOleControlSite, (void**)&control_site);
332 if(SUCCEEDED(hres)) {
333 IDispatch *disp;
335 hres = IOleControlSite_GetExtendedControl(control_site, &disp);
336 if(SUCCEEDED(hres) && disp) {
337 FIXME("Use extended control\n");
338 IDispatch_Release(disp);
341 IOleControlSite_Release(control_site);
344 return S_OK;
347 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, IOleClientSite **ppClientSite)
349 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
351 TRACE("(%p)->(%p)\n", This, ppClientSite);
353 *ppClientSite = This->client_site;
354 return This->client_site ? S_OK : E_FAIL;
357 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
359 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
360 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
361 return E_NOTIMPL;
364 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
366 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
368 TRACE("(%p)->(%08x)\n", This, dwSaveOption);
370 if(dwSaveOption)
371 FIXME("Unsupported option %d\n", dwSaveOption);
373 if(This->hwnd) /* FIXME: Possibly hide window */
374 deactivate_window(This);
375 return S_OK;
378 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker *pmk)
380 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
381 FIXME("(%p %d %p)->()\n", This, dwWhichMoniker, pmk);
382 return E_NOTIMPL;
385 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
387 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
388 FIXME("(%p)->(%d %d %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
389 return E_NOTIMPL;
392 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, IDataObject *pDataObject, BOOL fCreation,
393 DWORD dwReserved)
395 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
396 FIXME("(%p)->(%p %x %d)\n", This, pDataObject, fCreation, dwReserved);
397 return E_NOTIMPL;
400 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved, IDataObject **ppDataObject)
402 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
403 FIXME("(%p)->(%d %p)\n", This, dwReserved, ppDataObject);
404 return E_NOTIMPL;
407 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite,
408 LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
410 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
412 switch(iVerb) {
413 case OLEIVERB_INPLACEACTIVATE:
414 TRACE("(%p)->(OLEIVERB_INPLACEACTIVATE)\n", This);
415 return activate_inplace(This);
417 case OLEIVERB_HIDE:
418 if(!This->hwnd) {
419 FIXME("No window to hide\n");
420 return E_UNEXPECTED;
423 ShowWindow(This->hwnd, SW_HIDE);
424 return S_OK;
426 default:
427 FIXME("Unsupported iVerb %d\n", iVerb);
430 return E_NOTIMPL;
433 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
435 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
436 FIXME("(%p)->(%p)\n", This, ppEnumOleVerb);
437 return E_NOTIMPL;
440 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
442 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
443 FIXME("(%p)\n", This);
444 return E_NOTIMPL;
447 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
449 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
450 FIXME("(%p)\n", This);
451 return E_NOTIMPL;
454 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID *pClsid)
456 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
457 FIXME("(%p)->(%p)\n", This, pClsid);
458 return E_NOTIMPL;
461 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType, LPOLESTR *pszUserType)
463 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
464 FIXME("(%p)->(%d %p)\n", This, dwFormOfType, pszUserType);
465 return E_NOTIMPL;
468 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
470 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
472 TRACE("(%p)->(%d %p)\n", This, dwDrawAspect, psizel);
474 if(dwDrawAspect != DVASPECT_CONTENT)
475 return DV_E_DVASPECT;
477 This->extent = *psizel;
478 return S_OK;
481 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
483 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
485 TRACE("(%p)->(%d %p)\n", This, dwDrawAspect, psizel);
487 if(dwDrawAspect != DVASPECT_CONTENT)
488 return E_FAIL;
490 *psizel = This->extent;
491 return S_OK;
494 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink, DWORD *pdwConnection)
496 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
497 FIXME("(%p)->(%p %p)\n", This, pAdvSink, pdwConnection);
498 return E_NOTIMPL;
501 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
503 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
504 FIXME("(%p)->(%d)\n", This, dwConnection);
505 return E_NOTIMPL;
508 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
510 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
511 FIXME("(%p)->(%p)\n", This, ppenumAdvise);
512 return E_NOTIMPL;
515 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
517 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
519 TRACE("(%p)->(%d %p)\n", This, dwAspect, pdwStatus);
521 switch(dwAspect) {
522 case DVASPECT_CONTENT:
523 *pdwStatus = OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
524 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE;
525 break;
526 default:
527 FIXME("Unhandled aspect %d\n", dwAspect);
528 return E_NOTIMPL;
531 return S_OK;
534 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE *pLogpal)
536 WindowsMediaPlayer *This = impl_from_IOleObject(iface);
537 FIXME("(%p)->(%p)\n", This, pLogpal);
538 return E_NOTIMPL;
541 static const IOleObjectVtbl OleObjectVtbl = {
542 OleObject_QueryInterface,
543 OleObject_AddRef,
544 OleObject_Release,
545 OleObject_SetClientSite,
546 OleObject_GetClientSite,
547 OleObject_SetHostNames,
548 OleObject_Close,
549 OleObject_SetMoniker,
550 OleObject_GetMoniker,
551 OleObject_InitFromData,
552 OleObject_GetClipboardData,
553 OleObject_DoVerb,
554 OleObject_EnumVerbs,
555 OleObject_Update,
556 OleObject_IsUpToDate,
557 OleObject_GetUserClassID,
558 OleObject_GetUserType,
559 OleObject_SetExtent,
560 OleObject_GetExtent,
561 OleObject_Advise,
562 OleObject_Unadvise,
563 OleObject_EnumAdvise,
564 OleObject_GetMiscStatus,
565 OleObject_SetColorScheme
568 static inline WindowsMediaPlayer *impl_from_IOleInPlaceObjectWindowless(IOleInPlaceObjectWindowless *iface)
570 return CONTAINING_RECORD(iface, WindowsMediaPlayer, IOleInPlaceObjectWindowless_iface);
573 static HRESULT WINAPI OleInPlaceObjectWindowless_QueryInterface(IOleInPlaceObjectWindowless *iface,
574 REFIID riid, void **ppv)
576 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
577 return IOleObject_QueryInterface(&This->IOleObject_iface, riid, ppv);
580 static ULONG WINAPI OleInPlaceObjectWindowless_AddRef(IOleInPlaceObjectWindowless *iface)
582 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
583 return IOleObject_AddRef(&This->IOleObject_iface);
586 static ULONG WINAPI OleInPlaceObjectWindowless_Release(IOleInPlaceObjectWindowless *iface)
588 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
589 return IOleObject_Release(&This->IOleObject_iface);
592 static HRESULT WINAPI OleInPlaceObjectWindowless_GetWindow(IOleInPlaceObjectWindowless *iface, HWND *phwnd)
594 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
596 TRACE("(%p)->(%p)\n", This, phwnd);
598 *phwnd = This->hwnd;
599 return This->hwnd ? S_OK : E_UNEXPECTED;
602 static HRESULT WINAPI OleInPlaceObjectWindowless_ContextSensitiveHelp(IOleInPlaceObjectWindowless *iface,
603 BOOL fEnterMode)
605 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
606 FIXME("(%p)->(%x)\n", This, fEnterMode);
607 return E_NOTIMPL;
610 static HRESULT WINAPI OleInPlaceObjectWindowless_InPlaceDeactivate(IOleInPlaceObjectWindowless *iface)
612 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
613 FIXME("(%p)\n", This);
614 return E_NOTIMPL;
617 static HRESULT WINAPI OleInPlaceObjectWindowless_UIDeactivate(IOleInPlaceObjectWindowless *iface)
619 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
620 FIXME("(%p)\n", This);
621 return E_NOTIMPL;
624 static HRESULT WINAPI OleInPlaceObjectWindowless_SetObjectRects(IOleInPlaceObjectWindowless *iface,
625 LPCRECT lprcPosRect, LPCRECT lprcClipRect)
627 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
629 TRACE("(%p)->(%s %s)\n", This, wine_dbgstr_rect(lprcPosRect), wine_dbgstr_rect(lprcClipRect));
631 if(This->hwnd) {
632 SetWindowPos(This->hwnd, NULL, lprcPosRect->left, lprcPosRect->top,
633 lprcPosRect->right-lprcPosRect->left, lprcPosRect->bottom-lprcPosRect->top,
634 SWP_NOZORDER | SWP_NOACTIVATE);
637 return S_OK;
640 static HRESULT WINAPI OleInPlaceObjectWindowless_ReactivateAndUndo(IOleInPlaceObjectWindowless *iface)
642 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
643 FIXME("(%p)\n", This);
644 return E_NOTIMPL;
647 static HRESULT WINAPI OleInPlaceObjectWindowless_OnWindowMessage(IOleInPlaceObjectWindowless *iface,
648 UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *lpResult)
650 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
651 FIXME("(%p)->(%u %lu %lu %p)\n", This, msg, wParam, lParam, lpResult);
652 return E_NOTIMPL;
655 static HRESULT WINAPI OleInPlaceObjectWindowless_GetDropTarget(IOleInPlaceObjectWindowless *iface,
656 IDropTarget **ppDropTarget)
658 WindowsMediaPlayer *This = impl_from_IOleInPlaceObjectWindowless(iface);
659 FIXME("(%p)->(%p)\n", This, ppDropTarget);
660 return E_NOTIMPL;
663 static const IOleInPlaceObjectWindowlessVtbl OleInPlaceObjectWindowlessVtbl = {
664 OleInPlaceObjectWindowless_QueryInterface,
665 OleInPlaceObjectWindowless_AddRef,
666 OleInPlaceObjectWindowless_Release,
667 OleInPlaceObjectWindowless_GetWindow,
668 OleInPlaceObjectWindowless_ContextSensitiveHelp,
669 OleInPlaceObjectWindowless_InPlaceDeactivate,
670 OleInPlaceObjectWindowless_UIDeactivate,
671 OleInPlaceObjectWindowless_SetObjectRects,
672 OleInPlaceObjectWindowless_ReactivateAndUndo,
673 OleInPlaceObjectWindowless_OnWindowMessage,
674 OleInPlaceObjectWindowless_GetDropTarget
677 static inline WindowsMediaPlayer *impl_from_IOleControl(IOleControl *iface)
679 return CONTAINING_RECORD(iface, WindowsMediaPlayer, IOleControl_iface);
682 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface, REFIID riid, void **ppv)
684 WindowsMediaPlayer *This = impl_from_IOleControl(iface);
685 return IOleObject_QueryInterface(&This->IOleObject_iface, riid, ppv);
688 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
690 WindowsMediaPlayer *This = impl_from_IOleControl(iface);
691 return IOleObject_AddRef(&This->IOleObject_iface);
694 static ULONG WINAPI OleControl_Release(IOleControl *iface)
696 WindowsMediaPlayer *This = impl_from_IOleControl(iface);
697 return IOleObject_Release(&This->IOleObject_iface);
700 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, CONTROLINFO *pCI)
702 WindowsMediaPlayer *This = impl_from_IOleControl(iface);
703 FIXME("(%p)->(%p)\n", This, pCI);
704 return E_NOTIMPL;
707 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, MSG *msg)
709 WindowsMediaPlayer *This = impl_from_IOleControl(iface);
710 FIXME("(%p)->(%p)\n", This, msg);
711 return E_NOTIMPL;
714 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
716 WindowsMediaPlayer *This = impl_from_IOleControl(iface);
717 FIXME("(%p)->(%d)\n", This, dispID);
718 return E_NOTIMPL;
721 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL freeze)
723 WindowsMediaPlayer *This = impl_from_IOleControl(iface);
724 FIXME("(%p)->(%x)\n", This, freeze);
725 return E_NOTIMPL;
728 static const IOleControlVtbl OleControlVtbl = {
729 OleControl_QueryInterface,
730 OleControl_AddRef,
731 OleControl_Release,
732 OleControl_GetControlInfo,
733 OleControl_OnMnemonic,
734 OleControl_OnAmbientPropertyChange,
735 OleControl_FreezeEvents
738 static inline WindowsMediaPlayer *impl_from_IProvideClassInfo2(IProvideClassInfo2 *iface)
740 return CONTAINING_RECORD(iface, WindowsMediaPlayer, IProvideClassInfo2_iface);
743 static HRESULT WINAPI ProvideClassInfo2_QueryInterface(IProvideClassInfo2 *iface, REFIID riid, void **ppv)
745 WindowsMediaPlayer *This = impl_from_IProvideClassInfo2(iface);
746 return IOleObject_QueryInterface(&This->IOleObject_iface, riid, ppv);
749 static ULONG WINAPI ProvideClassInfo2_AddRef(IProvideClassInfo2 *iface)
751 WindowsMediaPlayer *This = impl_from_IProvideClassInfo2(iface);
752 return IOleObject_AddRef(&This->IOleObject_iface);
755 static ULONG WINAPI ProvideClassInfo2_Release(IProvideClassInfo2 *iface)
757 WindowsMediaPlayer *This = impl_from_IProvideClassInfo2(iface);
758 return IOleObject_Release(&This->IOleObject_iface);
761 static HRESULT WINAPI ProvideClassInfo2_GetClassInfo(IProvideClassInfo2 *iface, ITypeInfo **ti)
763 WindowsMediaPlayer *This = impl_from_IProvideClassInfo2(iface);
765 TRACE("(%p)->(%p)\n", This, ti);
767 if (!ti)
768 return E_POINTER;
770 return get_typeinfo(WindowsMediaPlayer_tid, ti);
773 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideClassInfo2 *iface, DWORD dwGuidKind, GUID *pGUID)
775 WindowsMediaPlayer *This = impl_from_IProvideClassInfo2(iface);
777 TRACE("(%p)->(%d %p)\n", This, dwGuidKind, pGUID);
779 if(dwGuidKind != GUIDKIND_DEFAULT_SOURCE_DISP_IID) {
780 FIXME("Unexpected dwGuidKind %d\n", dwGuidKind);
781 return E_INVALIDARG;
784 *pGUID = IID__WMPOCXEvents;
785 return S_OK;
788 static const IProvideClassInfo2Vtbl ProvideClassInfo2Vtbl = {
789 ProvideClassInfo2_QueryInterface,
790 ProvideClassInfo2_AddRef,
791 ProvideClassInfo2_Release,
792 ProvideClassInfo2_GetClassInfo,
793 ProvideClassInfo2_GetGUID
796 static inline WindowsMediaPlayer *impl_from_IPersistStreamInit(IPersistStreamInit *iface)
798 return CONTAINING_RECORD(iface, WindowsMediaPlayer, IPersistStreamInit_iface);
801 static HRESULT WINAPI PersistStreamInit_QueryInterface(IPersistStreamInit *iface,
802 REFIID riid, void **ppv)
804 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
805 return IOleObject_QueryInterface(&This->IOleObject_iface, riid, ppv);
808 static ULONG WINAPI PersistStreamInit_AddRef(IPersistStreamInit *iface)
810 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
811 return IOleObject_AddRef(&This->IOleObject_iface);
814 static ULONG WINAPI PersistStreamInit_Release(IPersistStreamInit *iface)
816 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
817 return IOleObject_Release(&This->IOleObject_iface);
820 static HRESULT WINAPI PersistStreamInit_GetClassID(IPersistStreamInit *iface, CLSID *pClassID)
822 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
823 FIXME("(%p)->(%p)\n", This, pClassID);
824 return E_NOTIMPL;
827 static HRESULT WINAPI PersistStreamInit_IsDirty(IPersistStreamInit *iface)
829 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
830 FIXME("(%p)\n", This);
831 return E_NOTIMPL;
834 static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, LPSTREAM pStm)
836 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
837 FIXME("(%p)->(%p)\n", This, pStm);
838 return E_NOTIMPL;
841 static HRESULT WINAPI PersistStreamInit_Save(IPersistStreamInit *iface, LPSTREAM pStm,
842 BOOL fClearDirty)
844 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
845 FIXME("(%p)->(%p %x)\n", This, pStm, fClearDirty);
846 return E_NOTIMPL;
849 static HRESULT WINAPI PersistStreamInit_GetSizeMax(IPersistStreamInit *iface,
850 ULARGE_INTEGER *pcbSize)
852 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
853 FIXME("(%p)->(%p)\n", This, pcbSize);
854 return E_NOTIMPL;
857 static HRESULT WINAPI PersistStreamInit_InitNew(IPersistStreamInit *iface)
859 WindowsMediaPlayer *This = impl_from_IPersistStreamInit(iface);
861 TRACE("(%p)\n", This);
863 if(!This->client_site)
864 return E_FAIL;
866 /* Nothing to do, yet. */
867 get_container_hwnd(This);
868 return S_OK;
871 static const IPersistStreamInitVtbl PersistStreamInitVtbl = {
872 PersistStreamInit_QueryInterface,
873 PersistStreamInit_AddRef,
874 PersistStreamInit_Release,
875 PersistStreamInit_GetClassID,
876 PersistStreamInit_IsDirty,
877 PersistStreamInit_Load,
878 PersistStreamInit_Save,
879 PersistStreamInit_GetSizeMax,
880 PersistStreamInit_InitNew
883 HRESULT WINAPI WMPFactory_CreateInstance(IClassFactory *iface, IUnknown *outer,
884 REFIID riid, void **ppv)
886 WindowsMediaPlayer *wmp;
887 DWORD dpi_x, dpi_y;
888 HDC hdc;
889 HRESULT hres;
891 TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
893 wmp = heap_alloc_zero(sizeof(*wmp));
894 if(!wmp)
895 return E_OUTOFMEMORY;
897 wmp->IOleObject_iface.lpVtbl = &OleObjectVtbl;
898 wmp->IProvideClassInfo2_iface.lpVtbl = &ProvideClassInfo2Vtbl;
899 wmp->IPersistStreamInit_iface.lpVtbl = &PersistStreamInitVtbl;
900 wmp->IOleInPlaceObjectWindowless_iface.lpVtbl = &OleInPlaceObjectWindowlessVtbl;
901 wmp->IOleControl_iface.lpVtbl = &OleControlVtbl;
903 wmp->ref = 1;
905 if (init_player(wmp)) {
906 ConnectionPointContainer_Init(wmp);
907 hdc = GetDC(0);
908 dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
909 dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
910 ReleaseDC(0, hdc);
912 wmp->extent.cx = MulDiv(192, 2540, dpi_x);
913 wmp->extent.cy = MulDiv(192, 2540, dpi_y);
915 hres = IOleObject_QueryInterface(&wmp->IOleObject_iface, riid, ppv);
916 } else {
917 hres = E_FAIL;
919 IOleObject_Release(&wmp->IOleObject_iface);
920 return hres;