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