strmbase: Implement BaseControlWindow.
[wine] / dlls / strmbase / window.c
1 /*
2  * Generic Implementation of strmbase window classes
3  *
4  * Copyright 2012 Aric Stewart, CodeWeavers
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #define COBJMACROS
22
23 #include "dshow.h"
24 #include "wine/debug.h"
25 #include "wine/unicode.h"
26 #include "wine/strmbase.h"
27 #include "uuids.h"
28 #include "vfwmsgs.h"
29 #include <assert.h>
30
31 WINE_DEFAULT_DEBUG_CHANNEL(strmbase);
32
33 static inline BaseControlWindow *impl_from_IVideoWindow( IVideoWindow *iface)
34 {
35     return CONTAINING_RECORD(iface, BaseControlWindow, IVideoWindow_iface);
36 }
37
38 static inline BaseControlWindow *impl_from_BaseWindow(BaseWindow *iface)
39 {
40     return CONTAINING_RECORD(iface, BaseControlWindow, baseWindow);
41 }
42
43 static LRESULT CALLBACK WndProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
44 {
45     BaseWindow* This = (BaseWindow*)GetWindowLongPtrW(hwnd, 0);
46
47     if (!This)
48         return DefWindowProcW(hwnd, uMsg, wParam, lParam);
49
50     if (This->pFuncsTable->pfnOnReceiveMessage)
51         return This->pFuncsTable->pfnOnReceiveMessage(This, hwnd, uMsg, wParam, lParam);
52     else
53         return BaseWindowImpl_OnReceiveMessage(This, hwnd, uMsg, wParam, lParam);
54 }
55
56 LRESULT WINAPI BaseWindowImpl_OnReceiveMessage(BaseWindow *This, HWND hwnd, INT uMsg, WPARAM wParam, LPARAM lParam)
57 {
58     if (This->pFuncsTable->pfnPossiblyEatMessage && This->pFuncsTable->pfnPossiblyEatMessage(This, uMsg, wParam, lParam))
59         return 0;
60
61     switch (uMsg)
62     {
63         case WM_SIZE:
64             if (This->pFuncsTable->pfnOnSize)
65                 return This->pFuncsTable->pfnOnSize(This, LOWORD(lParam), HIWORD(lParam));
66             else
67                 return BaseWindowImpl_OnSize(This, LOWORD(lParam), HIWORD(lParam));
68     }
69
70     return DefWindowProcW(hwnd, uMsg, wParam, lParam);
71 }
72
73 BOOL WINAPI BaseWindowImpl_OnSize(BaseWindow *This, LONG Width, LONG Height)
74 {
75     This->Width = Width;
76     This->Height = Height;
77     return TRUE;
78 }
79
80 HRESULT WINAPI BaseWindow_Init(BaseWindow *pBaseWindow, const BaseWindowFuncTable* pFuncsTable)
81 {
82     if (!pFuncsTable)
83         return E_INVALIDARG;
84
85     ZeroMemory(pBaseWindow,sizeof(BaseWindow));
86     pBaseWindow->pFuncsTable = pFuncsTable;
87
88     return S_OK;
89 }
90
91 HRESULT WINAPI BaseWindow_Destroy(BaseWindow *This)
92 {
93     if (This->hWnd)
94         BaseWindowImpl_DoneWithWindow(This);
95
96     HeapFree(GetProcessHeap(), 0, This);
97     return S_OK;
98 }
99
100 HRESULT WINAPI BaseWindowImpl_PrepareWindow(BaseWindow *This)
101 {
102     WNDCLASSW winclass;
103     static const WCHAR windownameW[] = { 'A','c','t','i','v','e','M','o','v','i','e',' ','W','i','n','d','o','w',0 };
104
105     This->pClassName = This->pFuncsTable->pfnGetClassWindowStyles(This, &This->ClassStyles, &This->WindowStyles, &This->WindowStylesEx);
106
107     winclass.style = This->ClassStyles;
108     winclass.lpfnWndProc = WndProcW;
109     winclass.cbClsExtra = 0;
110     winclass.cbWndExtra = sizeof(BaseWindow*);
111     winclass.hInstance = This->hInstance;
112     winclass.hIcon = NULL;
113     winclass.hCursor = NULL;
114     winclass.hbrBackground = GetStockObject(BLACK_BRUSH);
115     winclass.lpszMenuName = NULL;
116     winclass.lpszClassName = This->pClassName;
117     if (!RegisterClassW(&winclass) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS)
118     {
119         ERR("Unable to register window class: %u\n", GetLastError());
120         return E_FAIL;
121     }
122
123     This->hWnd = CreateWindowExW(This->WindowStylesEx,
124                                  This->pClassName, windownameW,
125                                  This->WindowStyles,
126                                  CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
127                                  CW_USEDEFAULT, NULL, NULL, This->hInstance,
128                                  NULL);
129
130     if (!This->hWnd)
131     {
132         ERR("Unable to create window\n");
133         return E_FAIL;
134     }
135
136     SetWindowLongPtrW(This->hWnd, 0, (LONG_PTR)This);
137
138     This->hDC = GetDC(This->hWnd);
139
140     return S_OK;
141 }
142
143 HRESULT WINAPI BaseWindowImpl_DoneWithWindow(BaseWindow *This)
144 {
145     if (!This->hWnd)
146         return S_OK;
147
148     if (This->hDC)
149         ReleaseDC(This->hWnd, This->hDC);
150     This->hDC = NULL;
151
152     DestroyWindow(This->hWnd);
153     This->hWnd = NULL;
154
155     return S_OK;
156 }
157
158 RECT WINAPI BaseWindowImpl_GetDefaultRect(BaseWindow *This)
159 {
160     static RECT defRect = {0, 0, 800, 600};
161     return defRect;
162 }
163
164 BOOL WINAPI BaseControlWindowImpl_PossiblyEatMessage(BaseWindow *This, UINT uMsg, WPARAM wParam, LPARAM lParam)
165 {
166     BaseControlWindow* pControlWindow = impl_from_BaseWindow(This);
167
168     if (pControlWindow->hwndDrain)
169     {
170         switch(uMsg)
171         {
172             case WM_KEYDOWN:
173             case WM_KEYUP:
174             case WM_LBUTTONDBLCLK:
175             case WM_LBUTTONDOWN:
176             case WM_LBUTTONUP:
177             case WM_MBUTTONDBLCLK:
178             case WM_MBUTTONDOWN:
179             case WM_MBUTTONUP:
180             case WM_MOUSEACTIVATE:
181             case WM_MOUSEMOVE:
182             case WM_NCLBUTTONDBLCLK:
183             case WM_NCLBUTTONDOWN:
184             case WM_NCLBUTTONUP:
185             case WM_NCMBUTTONDBLCLK:
186             case WM_NCMBUTTONDOWN:
187             case WM_NCMBUTTONUP:
188             case WM_NCMOUSEMOVE:
189             case WM_NCRBUTTONDBLCLK:
190             case WM_NCRBUTTONDOWN:
191             case WM_NCRBUTTONUP:
192             case WM_RBUTTONDBLCLK:
193             case WM_RBUTTONDOWN:
194             case WM_RBUTTONUP:
195                 PostMessageW(pControlWindow->hwndDrain, uMsg, wParam, lParam);
196                 return TRUE;
197                 break;
198             default:
199                 break;
200         }
201     }
202     return FALSE;
203 }
204
205 HRESULT WINAPI BaseControlWindow_Init(BaseControlWindow *pControlWindow, const IVideoWindowVtbl *lpVtbl, BaseFilter *owner, CRITICAL_SECTION *lock, BasePin* pPin,const BaseWindowFuncTable *pFuncsTable)
206 {
207     HRESULT hr;
208
209     hr = BaseWindow_Init(&pControlWindow->baseWindow, pFuncsTable);
210     if (SUCCEEDED(hr))
211     {
212         pControlWindow->IVideoWindow_iface.lpVtbl = lpVtbl;
213         pControlWindow->AutoShow = TRUE;
214         pControlWindow->hwndDrain = NULL;
215         pControlWindow->hwndOwner = NULL;
216         pControlWindow->pFilter = owner;
217         pControlWindow->pInterfaceLock = lock;
218         pControlWindow->pPin = pPin;
219     }
220     return hr;
221 }
222
223 HRESULT WINAPI BaseControlWindowImpl_GetTypeInfoCount(IVideoWindow *iface, UINT*pctinfo)
224 {
225     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
226
227     FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
228
229     return S_OK;
230 }
231
232 HRESULT WINAPI BaseControlWindowImpl_GetTypeInfo(IVideoWindow *iface, UINT iTInfo, LCID lcid, ITypeInfo**ppTInfo)
233 {
234     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
235
236     FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
237
238     return S_OK;
239 }
240
241 HRESULT WINAPI BaseControlWindowImpl_GetIDsOfNames(IVideoWindow *iface, REFIID riid, LPOLESTR*rgszNames, UINT cNames, LCID lcid, DISPID*rgDispId)
242  {
243     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
244
245     FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
246
247     return S_OK;
248 }
249
250 HRESULT WINAPI BaseControlWindowImpl_Invoke(IVideoWindow *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS*pDispParams, VARIANT*pVarResult, EXCEPINFO*pExepInfo, UINT*puArgErr)
251 {
252     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
253
254     FIXME("(%p/%p)->(%d, %s (%p), %d, %04x, %p, %p, %p, %p): stub !!!\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
255
256     return S_OK;
257 }
258
259 HRESULT WINAPI BaseControlWindowImpl_put_Caption(IVideoWindow *iface, BSTR strCaption)
260 {
261     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
262
263     TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
264
265     if (!SetWindowTextW(This->baseWindow.hWnd, strCaption))
266         return E_FAIL;
267
268     return S_OK;
269 }
270
271 HRESULT WINAPI BaseControlWindowImpl_get_Caption(IVideoWindow *iface, BSTR *strCaption)
272 {
273     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
274
275     TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
276
277     GetWindowTextW(This->baseWindow.hWnd, (LPWSTR)strCaption, 100);
278
279     return S_OK;
280 }
281
282 HRESULT WINAPI BaseControlWindowImpl_put_WindowStyle(IVideoWindow *iface, LONG WindowStyle)
283 {
284     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
285     LONG old;
286
287     old = GetWindowLongW(This->baseWindow.hWnd, GWL_STYLE);
288
289     TRACE("(%p/%p)->(%x -> %x)\n", This, iface, old, WindowStyle);
290
291     if (WindowStyle & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
292         return E_INVALIDARG;
293
294     SetWindowLongW(This->baseWindow.hWnd, GWL_STYLE, WindowStyle);
295     SetWindowPos(This->baseWindow.hWnd,0,0,0,0,0,SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOZORDER);
296
297     return S_OK;
298 }
299
300 HRESULT WINAPI BaseControlWindowImpl_get_WindowStyle(IVideoWindow *iface, LONG *WindowStyle)
301 {
302     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
303
304     TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
305
306     *WindowStyle = GetWindowLongW(This->baseWindow.hWnd, GWL_STYLE);
307
308     return S_OK;
309 }
310
311 HRESULT WINAPI BaseControlWindowImpl_put_WindowStyleEx(IVideoWindow *iface, LONG WindowStyleEx)
312 {
313     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
314
315     TRACE("(%p/%p)->(%d)\n", This, iface, WindowStyleEx);
316
317     if (!SetWindowLongW(This->baseWindow.hWnd, GWL_EXSTYLE, WindowStyleEx))
318         return E_FAIL;
319
320     return S_OK;
321 }
322
323 HRESULT WINAPI BaseControlWindowImpl_get_WindowStyleEx(IVideoWindow *iface, LONG *WindowStyleEx)
324 {
325     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
326
327     TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
328
329     *WindowStyleEx = GetWindowLongW(This->baseWindow.hWnd, GWL_EXSTYLE);
330
331     return S_OK;
332 }
333
334 HRESULT WINAPI BaseControlWindowImpl_put_AutoShow(IVideoWindow *iface, LONG AutoShow)
335 {
336     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
337
338     TRACE("(%p/%p)->(%d)\n", This, iface, AutoShow);
339
340     This->AutoShow = AutoShow;
341
342     return S_OK;
343 }
344
345 HRESULT WINAPI BaseControlWindowImpl_get_AutoShow(IVideoWindow *iface, LONG *AutoShow)
346 {
347     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
348
349     TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
350
351     *AutoShow = This->AutoShow;
352
353     return S_OK;
354 }
355
356 HRESULT WINAPI BaseControlWindowImpl_put_WindowState(IVideoWindow *iface, LONG WindowState)
357 {
358     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
359
360     TRACE("(%p/%p)->(%d)\n", This, iface, WindowState);
361     ShowWindow(This->baseWindow.hWnd, WindowState);
362     return S_OK;
363 }
364
365 HRESULT WINAPI BaseControlWindowImpl_get_WindowState(IVideoWindow *iface, LONG *WindowState)
366 {
367     WINDOWPLACEMENT place;
368     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
369
370     place.length = sizeof(place);
371     GetWindowPlacement(This->baseWindow.hWnd, &place);
372     TRACE("(%p/%p)->(%p)\n", This, iface, WindowState);
373     *WindowState = place.showCmd;
374
375     return S_OK;
376 }
377
378 HRESULT WINAPI BaseControlWindowImpl_put_BackgroundPalette(IVideoWindow *iface, LONG BackgroundPalette)
379 {
380     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
381
382     FIXME("(%p/%p)->(%d): stub !!!\n", This, iface, BackgroundPalette);
383
384     return S_OK;
385 }
386
387 HRESULT WINAPI BaseControlWindowImpl_get_BackgroundPalette(IVideoWindow *iface, LONG *pBackgroundPalette)
388 {
389     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
390
391     FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBackgroundPalette);
392
393     return S_OK;
394 }
395
396 HRESULT WINAPI BaseControlWindowImpl_put_Visible(IVideoWindow *iface, LONG Visible)
397 {
398     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
399
400     TRACE("(%p/%p)->(%d)\n", This, iface, Visible);
401
402     ShowWindow(This->baseWindow.hWnd, Visible ? SW_SHOW : SW_HIDE);
403
404     return S_OK;
405 }
406
407 HRESULT WINAPI BaseControlWindowImpl_get_Visible(IVideoWindow *iface, LONG *pVisible)
408 {
409     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
410
411     TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
412
413     *pVisible = IsWindowVisible(This->baseWindow.hWnd);
414
415     return S_OK;
416 }
417
418 HRESULT WINAPI BaseControlWindowImpl_put_Left(IVideoWindow *iface, LONG Left)
419 {
420     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
421     RECT WindowPos;
422
423     TRACE("(%p/%p)->(%d)\n", This, iface, Left);
424
425     GetWindowRect(This->baseWindow.hWnd, &WindowPos);
426     if (!SetWindowPos(This->baseWindow.hWnd, NULL, Left, WindowPos.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
427         return E_FAIL;
428
429     return S_OK;
430 }
431
432 HRESULT WINAPI BaseControlWindowImpl_get_Left(IVideoWindow *iface, LONG *pLeft)
433 {
434     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
435     RECT WindowPos;
436
437     TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
438     GetWindowRect(This->baseWindow.hWnd, &WindowPos);
439
440     *pLeft = WindowPos.left;
441
442     return S_OK;
443 }
444
445 HRESULT WINAPI BaseControlWindowImpl_put_Width(IVideoWindow *iface, LONG Width)
446 {
447     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
448
449     TRACE("(%p/%p)->(%d)\n", This, iface, Width);
450
451     if (!SetWindowPos(This->baseWindow.hWnd, NULL, 0, 0, Width, This->baseWindow.Height, SWP_NOZORDER|SWP_NOMOVE))
452         return E_FAIL;
453
454     This->baseWindow.Width = Width;
455
456     return S_OK;
457 }
458
459 HRESULT WINAPI BaseControlWindowImpl_get_Width(IVideoWindow *iface, LONG *pWidth)
460 {
461     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
462
463     TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
464
465     *pWidth = This->baseWindow.Width;
466
467     return S_OK;
468 }
469
470 HRESULT WINAPI BaseControlWindowImpl_put_Top(IVideoWindow *iface, LONG Top)
471 {
472     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
473     RECT WindowPos;
474
475     TRACE("(%p/%p)->(%d)\n", This, iface, Top);
476     GetWindowRect(This->baseWindow.hWnd, &WindowPos);
477
478     if (!SetWindowPos(This->baseWindow.hWnd, NULL, WindowPos.left, Top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
479         return E_FAIL;
480
481     return S_OK;
482 }
483
484 HRESULT WINAPI BaseControlWindowImpl_get_Top(IVideoWindow *iface, LONG *pTop)
485 {
486     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
487     RECT WindowPos;
488
489     TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
490     GetWindowRect(This->baseWindow.hWnd, &WindowPos);
491
492     *pTop = WindowPos.top;
493
494     return S_OK;
495 }
496
497 HRESULT WINAPI BaseControlWindowImpl_put_Height(IVideoWindow *iface, LONG Height)
498 {
499     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
500
501     TRACE("(%p/%p)->(%d)\n", This, iface, Height);
502
503     if (!SetWindowPos(This->baseWindow.hWnd, NULL, 0, 0, This->baseWindow.Width, Height, SWP_NOZORDER|SWP_NOMOVE))
504         return E_FAIL;
505
506     This->baseWindow.Height = Height;
507
508     return S_OK;
509 }
510
511 HRESULT WINAPI BaseControlWindowImpl_get_Height(IVideoWindow *iface, LONG *pHeight)
512 {
513     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
514
515     TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
516
517     *pHeight = This->baseWindow.Height;
518
519     return S_OK;
520 }
521
522 HRESULT WINAPI BaseControlWindowImpl_put_Owner(IVideoWindow *iface, OAHWND Owner)
523 {
524     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
525
526     TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
527
528     This->hwndOwner = (HWND)Owner;
529     SetParent(This->baseWindow.hWnd, This->hwndOwner);
530
531     return S_OK;
532 }
533
534 HRESULT WINAPI BaseControlWindowImpl_get_Owner(IVideoWindow *iface, OAHWND *Owner)
535 {
536     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
537
538     TRACE("(%p/%p)->(%p)\n", This, iface, Owner);
539
540     *(HWND*)Owner = This->hwndOwner;
541
542     return S_OK;
543 }
544
545 HRESULT WINAPI BaseControlWindowImpl_put_MessageDrain(IVideoWindow *iface, OAHWND Drain)
546 {
547     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
548
549     TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
550
551     This->hwndDrain = (HWND)Drain;
552
553     return S_OK;
554 }
555
556 HRESULT WINAPI BaseControlWindowImpl_get_MessageDrain(IVideoWindow *iface, OAHWND *Drain)
557 {
558     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
559
560     TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
561
562     *Drain = (OAHWND)This->hwndDrain;
563
564     return S_OK;
565 }
566
567 HRESULT WINAPI BaseControlWindowImpl_get_BorderColor(IVideoWindow *iface, LONG *Color)
568 {
569     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
570
571     FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, Color);
572
573     return S_OK;
574 }
575
576 HRESULT WINAPI BaseControlWindowImpl_put_BorderColor(IVideoWindow *iface, LONG Color)
577 {
578     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
579
580     FIXME("(%p/%p)->(%d): stub !!!\n", This, iface, Color);
581
582     return S_OK;
583 }
584
585 HRESULT WINAPI BaseControlWindowImpl_get_FullScreenMode(IVideoWindow *iface, LONG *FullScreenMode)
586 {
587     TRACE("(%p)->(%p)\n", iface, FullScreenMode);
588
589     return E_NOTIMPL;
590 }
591
592 HRESULT WINAPI BaseControlWindowImpl_put_FullScreenMode(IVideoWindow *iface, LONG FullScreenMode)
593 {
594     TRACE("(%p)->(%d)\n", iface, FullScreenMode);
595     return E_NOTIMPL;
596 }
597
598 HRESULT WINAPI BaseControlWindowImpl_SetWindowForeground(IVideoWindow *iface, LONG Focus)
599 {
600     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
601     BOOL ret;
602     IPin* pPin;
603     HRESULT hr;
604
605     TRACE("(%p/%p)->(%d)\n", This, iface, Focus);
606
607     if ((Focus != FALSE) && (Focus != TRUE))
608         return E_INVALIDARG;
609
610     hr = IPin_ConnectedTo(&This->pPin->IPin_iface, &pPin);
611     if ((hr != S_OK) || !pPin)
612         return VFW_E_NOT_CONNECTED;
613
614     if (Focus)
615         ret = SetForegroundWindow(This->baseWindow.hWnd);
616     else
617         ret = SetWindowPos(This->baseWindow.hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
618
619     if (!ret)
620         return E_FAIL;
621
622     return S_OK;
623 }
624
625 HRESULT WINAPI BaseControlWindowImpl_SetWindowPosition(IVideoWindow *iface, LONG Left, LONG Top, LONG Width, LONG Height)
626 {
627     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
628
629     TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
630
631     if (!SetWindowPos(This->baseWindow.hWnd, NULL, Left, Top, Width, Height, SWP_NOZORDER))
632         return E_FAIL;
633
634     This->baseWindow.Width = Width;
635     This->baseWindow.Height = Height;
636
637     return S_OK;
638 }
639
640 HRESULT WINAPI BaseControlWindowImpl_GetWindowPosition(IVideoWindow *iface, LONG *pLeft, LONG *pTop, LONG *pWidth, LONG *pHeight)
641 {
642     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
643     RECT WindowPos;
644
645     TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
646     GetWindowRect(This->baseWindow.hWnd, &WindowPos);
647
648     *pLeft = WindowPos.left;
649     *pTop = WindowPos.top;
650     *pWidth = This->baseWindow.Width;
651     *pHeight = This->baseWindow.Height;
652
653     return S_OK;
654 }
655
656 HRESULT WINAPI BaseControlWindowImpl_NotifyOwnerMessage(IVideoWindow *iface, OAHWND hwnd, LONG uMsg, LONG_PTR wParam, LONG_PTR lParam)
657 {
658     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
659
660     TRACE("(%p/%p)->(%08lx, %d, %08lx, %08lx)\n", This, iface, hwnd, uMsg, wParam, lParam);
661
662     if (!PostMessageW(This->baseWindow.hWnd, uMsg, wParam, lParam))
663         return E_FAIL;
664
665     return S_OK;
666 }
667
668 HRESULT WINAPI BaseControlWindowImpl_GetMinIdealImageSize(IVideoWindow *iface, LONG *pWidth, LONG *pHeight)
669 {
670     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
671     RECT defaultRect;
672
673     TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
674     defaultRect = This->baseWindow.pFuncsTable->pfnGetDefaultRect(&This->baseWindow);
675
676     *pWidth = defaultRect.right - defaultRect.left;
677     *pHeight = defaultRect.bottom - defaultRect.top;
678
679     return S_OK;
680 }
681
682 HRESULT WINAPI BaseControlWindowImpl_GetMaxIdealImageSize(IVideoWindow *iface, LONG *pWidth, LONG *pHeight)
683 {
684     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
685     RECT defaultRect;
686
687     TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
688     defaultRect = This->baseWindow.pFuncsTable->pfnGetDefaultRect(&This->baseWindow);
689
690     *pWidth = defaultRect.right - defaultRect.left;
691     *pHeight = defaultRect.bottom - defaultRect.top;
692
693     return S_OK;
694 }
695
696 HRESULT WINAPI BaseControlWindowImpl_GetRestorePosition(IVideoWindow *iface, LONG *pLeft, LONG *pTop, LONG *pWidth, LONG *pHeight)
697 {
698     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
699
700     FIXME("(%p/%p)->(%p, %p, %p, %p): stub !!!\n", This, iface, pLeft, pTop, pWidth, pHeight);
701
702     return S_OK;
703 }
704
705 HRESULT WINAPI BaseControlWindowImpl_HideCursor(IVideoWindow *iface, LONG HideCursor)
706 {
707     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
708
709     FIXME("(%p/%p)->(%d): stub !!!\n", This, iface, HideCursor);
710
711     return S_OK;
712 }
713
714 HRESULT WINAPI BaseControlWindowImpl_IsCursorHidden(IVideoWindow *iface, LONG *CursorHidden)
715 {
716     BaseControlWindow*  This = impl_from_IVideoWindow(iface);
717
718     FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, CursorHidden);
719
720     return S_OK;
721 }