comctl32/listview: Fix hittest flag calculation for negative Y values on report mode.
[wine] / dlls / mciqtz32 / mciqtz.c
1 /*
2  * DirectShow MCI Driver
3  *
4  * Copyright 2009 Christian Costa
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 <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winuser.h"
25 #include "mmddk.h"
26 #include "wine/debug.h"
27 #include "mciqtz_private.h"
28 #include "digitalv.h"
29 #include "wownt32.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(mciqtz);
32
33 static DWORD MCIQTZ_mciClose(UINT, DWORD, LPMCI_GENERIC_PARMS);
34 static DWORD MCIQTZ_mciStop(UINT, DWORD, LPMCI_GENERIC_PARMS);
35
36 /*======================================================================*
37  *                          MCI QTZ implementation                      *
38  *======================================================================*/
39
40 HINSTANCE MCIQTZ_hInstance = 0;
41
42 /***********************************************************************
43  *              DllMain (MCIQTZ.0)
44  */
45 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
46 {
47     switch (fdwReason) {
48     case DLL_PROCESS_ATTACH:
49         DisableThreadLibraryCalls(hInstDLL);
50         MCIQTZ_hInstance = hInstDLL;
51         break;
52     }
53     return TRUE;
54 }
55
56 /**************************************************************************
57  *                              MCIQTZ_mciGetOpenDev            [internal]
58  */
59 static WINE_MCIQTZ* MCIQTZ_mciGetOpenDev(UINT wDevID)
60 {
61     WINE_MCIQTZ* wma = (WINE_MCIQTZ*)mciGetDriverData(wDevID);
62
63     if (!wma) {
64         WARN("Invalid wDevID=%u\n", wDevID);
65         return NULL;
66     }
67     return wma;
68 }
69
70 /**************************************************************************
71  *                              MCIQTZ_drvOpen                  [internal]
72  */
73 static DWORD MCIQTZ_drvOpen(LPCWSTR str, LPMCI_OPEN_DRIVER_PARMSW modp)
74 {
75     WINE_MCIQTZ* wma;
76
77     TRACE("(%s, %p)\n", debugstr_w(str), modp);
78
79     /* session instance */
80     if (!modp)
81         return 0xFFFFFFFF;
82
83     wma = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MCIQTZ));
84     if (!wma)
85         return 0;
86
87     wma->wDevID = modp->wDeviceID;
88     mciSetDriverData(wma->wDevID, (DWORD_PTR)wma);
89
90     return modp->wDeviceID;
91 }
92
93 /**************************************************************************
94  *                              MCIQTZ_drvClose         [internal]
95  */
96 static DWORD MCIQTZ_drvClose(DWORD dwDevID)
97 {
98     WINE_MCIQTZ* wma;
99
100     TRACE("(%04x)\n", dwDevID);
101
102     wma = MCIQTZ_mciGetOpenDev(dwDevID);
103
104     if (wma) {
105         /* finish all outstanding things */
106         MCIQTZ_mciClose(dwDevID, MCI_WAIT, NULL);
107
108         HeapFree(GetProcessHeap(), 0, wma);
109         return 1;
110     }
111
112     return (dwDevID == 0xFFFFFFFF) ? 1 : 0;
113 }
114
115 /**************************************************************************
116  *                              MCIQTZ_drvConfigure             [internal]
117  */
118 static DWORD MCIQTZ_drvConfigure(DWORD dwDevID)
119 {
120     WINE_MCIQTZ* wma;
121
122     TRACE("(%04x)\n", dwDevID);
123
124     wma = MCIQTZ_mciGetOpenDev(dwDevID);
125     if (!wma)
126         return 0;
127
128     MCIQTZ_mciStop(dwDevID, MCI_WAIT, NULL);
129
130     MessageBoxA(0, "Sample QTZ Wine Driver !", "MM-Wine Driver", MB_OK);
131
132     return 1;
133 }
134
135 /***************************************************************************
136  *                              MCIQTZ_mciOpen                  [internal]
137  */
138 static DWORD MCIQTZ_mciOpen(UINT wDevID, DWORD dwFlags,
139                             LPMCI_DGV_OPEN_PARMSW lpOpenParms)
140 {
141     WINE_MCIQTZ* wma;
142     HRESULT hr;
143
144     TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpOpenParms);
145
146     if (!lpOpenParms)
147         return MCIERR_NULL_PARAMETER_BLOCK;
148
149     wma = MCIQTZ_mciGetOpenDev(wDevID);
150     if (!wma)
151         return MCIERR_INVALID_DEVICE_ID;
152
153     MCIQTZ_mciStop(wDevID, MCI_WAIT, NULL);
154
155     CoInitializeEx(NULL, COINIT_MULTITHREADED);
156
157     hr = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IGraphBuilder, (LPVOID*)&wma->pgraph);
158     if (FAILED(hr)) {
159         TRACE("Cannot create filtergraph (hr = %x)\n", hr);
160         goto err;
161     }
162
163     hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IMediaControl, (LPVOID*)&wma->pmctrl);
164     if (FAILED(hr)) {
165         TRACE("Cannot get IMediaControl interface (hr = %x)\n", hr);
166         goto err;
167     }
168
169     if (!((dwFlags & MCI_OPEN_ELEMENT) && (dwFlags & MCI_OPEN_ELEMENT))) {
170         TRACE("Wrong dwFlags %x\n", dwFlags);
171         goto err;
172     }
173
174     if (!lpOpenParms->lpstrElementName || !lpOpenParms->lpstrElementName[0]) {
175         TRACE("Invalid filename specified\n");
176         goto err;
177     }
178
179     TRACE("Open file %s\n", debugstr_w(lpOpenParms->lpstrElementName));
180
181     hr = IGraphBuilder_RenderFile(wma->pgraph, lpOpenParms->lpstrElementName, NULL);
182     if (FAILED(hr)) {
183         TRACE("Cannot render file (hr = %x)\n", hr);
184         goto err;
185     }
186
187     wma->opened = TRUE;
188
189     return 0;
190
191 err:
192     if (wma->pgraph)
193         IGraphBuilder_Release(wma->pgraph);
194     wma->pgraph = NULL;
195     if (wma->pmctrl)
196         IMediaControl_Release(wma->pmctrl);
197     wma->pmctrl = NULL;
198
199     CoUninitialize();
200
201     return MCIERR_INTERNAL;
202 }
203
204 /***************************************************************************
205  *                              MCIQTZ_mciClose                 [internal]
206  */
207 static DWORD MCIQTZ_mciClose(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
208 {
209     WINE_MCIQTZ* wma;
210
211     TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
212
213     wma = MCIQTZ_mciGetOpenDev(wDevID);
214     if (!wma)
215         return MCIERR_INVALID_DEVICE_ID;
216
217     MCIQTZ_mciStop(wDevID, MCI_WAIT, NULL);
218
219     if (wma->opened) {
220         IGraphBuilder_Release(wma->pgraph);
221         IMediaControl_Release(wma->pmctrl);
222         CoUninitialize();
223         wma->opened = FALSE;
224     }
225
226     return 0;
227 }
228
229 /***************************************************************************
230  *                              MCIQTZ_mciPlay                  [internal]
231  */
232 static DWORD MCIQTZ_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
233 {
234     WINE_MCIQTZ* wma;
235     HRESULT hr;
236
237     TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
238
239     if (!lpParms)
240         return MCIERR_NULL_PARAMETER_BLOCK;
241
242     wma = MCIQTZ_mciGetOpenDev(wDevID);
243     if (!wma)
244         return MCIERR_INVALID_DEVICE_ID;
245
246     hr = IMediaControl_Run(wma->pmctrl);
247     if (FAILED(hr)) {
248         TRACE("Cannot run filtergraph (hr = %x)\n", hr);
249         return MCIERR_INTERNAL;
250     }
251
252     wma->started = TRUE;
253
254     return 0;
255 }
256
257 /***************************************************************************
258  *                              MCIQTZ_mciSeek                  [internal]
259  */
260 static DWORD MCIQTZ_mciSeek(UINT wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
261 {
262     WINE_MCIQTZ* wma;
263     HRESULT hr;
264     IMediaPosition* pmpos;
265     LONGLONG newpos;
266
267     TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
268
269     if (!lpParms)
270         return MCIERR_NULL_PARAMETER_BLOCK;
271
272     wma = MCIQTZ_mciGetOpenDev(wDevID);
273     if (!wma)
274         return MCIERR_INVALID_DEVICE_ID;
275
276     MCIQTZ_mciStop(wDevID, MCI_WAIT, NULL);
277
278     if (dwFlags & MCI_SEEK_TO_START) {
279         newpos = 0;
280     } else if (dwFlags & MCI_SEEK_TO_END) {
281         FIXME("MCI_SEEK_TO_END not implemented yet\n");
282         return MCIERR_INTERNAL;
283     } else if (dwFlags & MCI_TO) {
284         FIXME("MCI_TO not implemented yet\n");
285         return MCIERR_INTERNAL;
286     } else {
287         WARN("dwFlag doesn't tell where to seek to...\n");
288         return MCIERR_MISSING_PARAMETER;
289     }
290
291     hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IMediaPosition, (LPVOID*)&pmpos);
292     if (FAILED(hr)) {
293         FIXME("Cannot get IMediaPostion interface (hr = %x)\n", hr);
294         return MCIERR_INTERNAL;
295     }
296
297     hr = IMediaPosition_put_CurrentPosition(pmpos, newpos);
298     if (FAILED(hr)) {
299         FIXME("Cannot set position (hr = %x)\n", hr);
300         IMediaPosition_Release(pmpos);
301         return MCIERR_INTERNAL;
302     }
303
304     IMediaPosition_Release(pmpos);
305
306     if (dwFlags & MCI_NOTIFY)
307         mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), wDevID, MCI_NOTIFY_SUCCESSFUL);
308
309     return 0;
310 }
311
312 /***************************************************************************
313  *                              MCIQTZ_mciStop                  [internal]
314  */
315 static DWORD MCIQTZ_mciStop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
316 {
317     WINE_MCIQTZ* wma;
318     HRESULT hr;
319
320     TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
321
322     wma = MCIQTZ_mciGetOpenDev(wDevID);
323     if (!wma)
324         return MCIERR_INVALID_DEVICE_ID;
325
326     if (!wma->started)
327         return 0;
328
329     hr = IMediaControl_Stop(wma->pmctrl);
330     if (FAILED(hr)) {
331         TRACE("Cannot stop filtergraph (hr = %x)\n", hr);
332         return MCIERR_INTERNAL;
333     }
334
335     wma->started = FALSE;
336
337     return 0;
338 }
339
340 /***************************************************************************
341  *                              MCIQTZ_mciGetDevCaps            [internal]
342  */
343 static DWORD MCIQTZ_mciGetDevCaps(UINT wDevID, DWORD dwFlags, LPMCI_GETDEVCAPS_PARMS lpParms)
344 {
345     WINE_MCIQTZ* wma;
346
347     TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
348
349     if (!lpParms)
350         return MCIERR_NULL_PARAMETER_BLOCK;
351
352     wma = MCIQTZ_mciGetOpenDev(wDevID);
353     if (!wma)
354         return MCIERR_INVALID_DEVICE_ID;
355
356     if (!(dwFlags & MCI_STATUS_ITEM)) {
357         WARN("No capability item specified\n");
358         return MCIERR_UNRECOGNIZED_COMMAND;
359     }
360
361     switch (lpParms->dwItem) {
362         case MCI_GETDEVCAPS_CAN_RECORD:
363             lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
364             TRACE("MCI_GETDEVCAPS_CAN_RECORD = %08x\n", lpParms->dwReturn);
365             break;
366         case MCI_GETDEVCAPS_HAS_AUDIO:
367             lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
368             TRACE("MCI_GETDEVCAPS_HAS_AUDIO = %08x\n", lpParms->dwReturn);
369             break;
370         case MCI_GETDEVCAPS_HAS_VIDEO:
371             lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
372             TRACE("MCI_GETDEVCAPS_HAS_VIDEO = %08x\n", lpParms->dwReturn);
373             break;
374         case MCI_GETDEVCAPS_DEVICE_TYPE:
375             lpParms->dwReturn = MAKEMCIRESOURCE(MCI_DEVTYPE_DIGITAL_VIDEO, MCI_DEVTYPE_DIGITAL_VIDEO);
376             TRACE("MCI_GETDEVCAPS_DEVICE_TYPE = %08x\n", lpParms->dwReturn);
377             break;
378         case MCI_GETDEVCAPS_USES_FILES:
379             lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
380             TRACE("MCI_GETDEVCAPS_USES_FILES = %08x\n", lpParms->dwReturn);
381             break;
382         case MCI_GETDEVCAPS_COMPOUND_DEVICE:
383             lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
384             TRACE("MCI_GETDEVCAPS_COMPOUND_DEVICE = %08x\n", lpParms->dwReturn);
385             break;
386         case MCI_GETDEVCAPS_CAN_EJECT:
387             lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
388             TRACE("MCI_GETDEVCAPS_EJECT = %08x\n", lpParms->dwReturn);
389             break;
390         case MCI_GETDEVCAPS_CAN_PLAY:
391             lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
392             TRACE("MCI_GETDEVCAPS_CAN_PLAY = %08x\n", lpParms->dwReturn);
393             break;
394         case MCI_GETDEVCAPS_CAN_SAVE:
395             lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
396             TRACE("MCI_GETDEVCAPS_CAN_SAVE = %08x\n", lpParms->dwReturn);
397             break;
398         default:
399             ERR("Unknown capability %08x\n", lpParms->dwItem);
400             return MCIERR_UNRECOGNIZED_COMMAND;
401     }
402
403     return MCI_RESOURCE_RETURNED;
404 }
405
406 /***************************************************************************
407  *                              MCIQTZ_mciSet                   [internal]
408  */
409 static DWORD MCIQTZ_mciSet(UINT wDevID, DWORD dwFlags, LPMCI_DGV_SET_PARMS lpParms)
410 {
411     WINE_MCIQTZ* wma;
412
413     TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
414
415     if (!lpParms)
416         return MCIERR_NULL_PARAMETER_BLOCK;
417
418     wma = MCIQTZ_mciGetOpenDev(wDevID);
419     if (!wma)
420         return MCIERR_INVALID_DEVICE_ID;
421
422     if (dwFlags & MCI_SET_TIME_FORMAT) {
423         switch (lpParms->dwTimeFormat) {
424             case MCI_FORMAT_MILLISECONDS:
425                 TRACE("MCI_SET_TIME_FORMAT = MCI_FORMAT_MILLISECONDS\n");
426                 wma->time_format = MCI_FORMAT_MILLISECONDS;
427                 break;
428             case MCI_FORMAT_FRAMES:
429                 TRACE("MCI_SET_TIME_FORMAT = MCI_FORMAT_FRAMES\n");
430                 wma->time_format = MCI_FORMAT_FRAMES;
431                 break;
432             default:
433                 WARN("Bad time format %u\n", lpParms->dwTimeFormat);
434                 return MCIERR_BAD_TIME_FORMAT;
435         }
436     }
437
438     if (dwFlags & ~MCI_SET_TIME_FORMAT)
439         FIXME("Flags not supported yet %08lX\n", dwFlags & ~MCI_SET_TIME_FORMAT);
440
441     return 0;
442 }
443
444 /***************************************************************************
445  *                              MCIQTZ_mciStatus                [internal]
446  */
447 static DWORD MCIQTZ_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_DGV_STATUS_PARMSW lpParms)
448 {
449     WINE_MCIQTZ* wma;
450
451     TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
452
453     if (!lpParms)
454         return MCIERR_NULL_PARAMETER_BLOCK;
455
456     wma = MCIQTZ_mciGetOpenDev(wDevID);
457     if (!wma)
458         return MCIERR_INVALID_DEVICE_ID;
459
460     if (!(dwFlags & MCI_STATUS_ITEM)) {
461         WARN("No status item specified\n");
462         return MCIERR_UNRECOGNIZED_COMMAND;
463     }
464
465     switch (lpParms->dwItem) {
466         case MCI_STATUS_LENGTH:
467             FIXME("MCI_STATUS_LENGTH not implemented yet\n");
468             return MCIERR_UNRECOGNIZED_COMMAND;
469         case MCI_STATUS_POSITION:
470         {
471             HRESULT hr;
472             REFTIME curpos;
473             IMediaPosition* pmpos;
474
475             hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IMediaPosition, (LPVOID*)&pmpos);
476             if (FAILED(hr)) {
477                 FIXME("Cannot get IMediaPostion interface (hr = %x)\n", hr);
478                 return MCIERR_INTERNAL;
479             }
480
481             hr = IMediaPosition_get_CurrentPosition(pmpos, &curpos);
482             if (FAILED(hr)) {
483                 FIXME("Cannot get position (hr = %x)\n", hr);
484                 IMediaPosition_Release(pmpos);
485                 return MCIERR_INTERNAL;
486             }
487
488             IMediaPosition_Release(pmpos);
489             lpParms->dwReturn = curpos / 10000;
490
491             break;
492         }
493         case MCI_STATUS_NUMBER_OF_TRACKS:
494             FIXME("MCI_STATUS_NUMBER_OF_TRACKS not implemented yet\n");
495             return MCIERR_UNRECOGNIZED_COMMAND;
496         case MCI_STATUS_MODE:
497             FIXME("MCI_STATUS_MODE not implemented yet\n");
498             return MCIERR_UNRECOGNIZED_COMMAND;
499         case MCI_STATUS_MEDIA_PRESENT:
500             FIXME("MCI_STATUS_MEDIA_PRESENT not implemented yet\n");
501             return MCIERR_UNRECOGNIZED_COMMAND;
502         case MCI_STATUS_TIME_FORMAT:
503             FIXME("MCI_STATUS_TIME_FORMAT not implemented yet\n");
504             return MCIERR_UNRECOGNIZED_COMMAND;
505         case MCI_STATUS_READY:
506             FIXME("MCI_STATUS_READY not implemented yet\n");
507             return MCIERR_UNRECOGNIZED_COMMAND;
508         case MCI_STATUS_CURRENT_TRACK:
509             FIXME("MCI_STATUS_CURRENT_TRACK not implemented yet\n");
510             return MCIERR_UNRECOGNIZED_COMMAND;
511         default:
512             FIXME("Unknown command %08X\n", lpParms->dwItem);
513             return MCIERR_UNRECOGNIZED_COMMAND;
514     }
515
516     if (dwFlags & MCI_NOTIFY)
517         mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), wDevID, MCI_NOTIFY_SUCCESSFUL);
518
519     return 0;
520 }
521
522 /***************************************************************************
523  *                              MCIQTZ_mciWhere                 [internal]
524  */
525 static DWORD MCIQTZ_mciWhere(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms)
526 {
527     WINE_MCIQTZ* wma;
528     IVideoWindow* pVideoWindow;
529     HRESULT hr;
530     HWND hWnd;
531     RECT rc;
532
533     TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
534
535     if (!lpParms)
536         return MCIERR_NULL_PARAMETER_BLOCK;
537
538     wma = MCIQTZ_mciGetOpenDev(wDevID);
539     if (!wma)
540         return MCIERR_INVALID_DEVICE_ID;
541
542     /* Find if there is a video stream and get the display window */
543     hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
544     if (FAILED(hr)) {
545         ERR("Cannot get IVideoWindow interface (hr = %x)\n", hr);
546         return MCIERR_INTERNAL;
547     }
548
549     hr = IVideoWindow_get_Owner(pVideoWindow, (OAHWND*)&hWnd);
550     IVideoWindow_Release(pVideoWindow);
551     if (FAILED(hr)) {
552         TRACE("No video stream, returning no window error\n");
553         return MCIERR_NO_WINDOW;
554     }
555
556     if (dwFlags & MCI_DGV_WHERE_SOURCE) {
557         if (dwFlags & MCI_DGV_WHERE_MAX)
558             FIXME("MCI_DGV_WHERE_SOURCE_MAX not supported yet\n");
559         else
560             FIXME("MCI_DGV_WHERE_SOURCE not supported yet\n");
561         return MCIERR_UNRECOGNIZED_COMMAND;
562     }
563     if (dwFlags & MCI_DGV_WHERE_DESTINATION) {
564         if (dwFlags & MCI_DGV_WHERE_MAX) {
565             GetClientRect(hWnd, &rc);
566             TRACE("MCI_DGV_WHERE_DESTINATION_MAX %s\n", wine_dbgstr_rect(&rc));
567         } else {
568             FIXME("MCI_DGV_WHERE_DESTINATION not supported yet\n");
569             return MCIERR_UNRECOGNIZED_COMMAND;
570         }
571     }
572     if (dwFlags & MCI_DGV_WHERE_FRAME) {
573         if (dwFlags & MCI_DGV_WHERE_MAX)
574             FIXME("MCI_DGV_WHERE_FRAME_MAX not supported yet\n");
575         else
576             FIXME("MCI_DGV_WHERE_FRAME not supported yet\n");
577         return MCIERR_UNRECOGNIZED_COMMAND;
578     }
579     if (dwFlags & MCI_DGV_WHERE_VIDEO) {
580         if (dwFlags & MCI_DGV_WHERE_MAX)
581             FIXME("MCI_DGV_WHERE_VIDEO_MAX not supported yet\n");
582         else
583             FIXME("MCI_DGV_WHERE_VIDEO not supported yet\n");
584         return MCIERR_UNRECOGNIZED_COMMAND;
585     }
586     if (dwFlags & MCI_DGV_WHERE_WINDOW) {
587         if (dwFlags & MCI_DGV_WHERE_MAX) {
588             GetWindowRect(GetDesktopWindow(), &rc);
589             TRACE("MCI_DGV_WHERE_WINDOW_MAX %s\n", wine_dbgstr_rect(&rc));
590         } else {
591             GetWindowRect(hWnd, &rc);
592             TRACE("MCI_DGV_WHERE_WINDOW %s\n", wine_dbgstr_rect(&rc));
593         }
594     }
595
596     /* In MCI, RECT structure is used differently: rc.right = width & rc.bottom = height
597      * So convert the normal RECT into a MCI RECT before returning */
598     lpParms->rc.left = rc.left;
599     lpParms->rc.top = rc.right;
600     lpParms->rc.right = rc.right - rc.left;
601     lpParms->rc.bottom = rc.bottom - rc.top;
602
603     return 0;
604 }
605
606 /*======================================================================*
607  *                          MCI QTZ entry points                        *
608  *======================================================================*/
609
610 /**************************************************************************
611  *                              DriverProc (MCIQTZ.@)
612  */
613 LRESULT CALLBACK MCIQTZ_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
614                                    LPARAM dwParam1, LPARAM dwParam2)
615 {
616     TRACE("(%08lX, %p, %08X, %08lX, %08lX)\n",
617           dwDevID, hDriv, wMsg, dwParam1, dwParam2);
618
619     switch (wMsg) {
620         case DRV_LOAD:                  return 1;
621         case DRV_FREE:                  return 1;
622         case DRV_OPEN:                  return MCIQTZ_drvOpen((LPCWSTR)dwParam1, (LPMCI_OPEN_DRIVER_PARMSW)dwParam2);
623         case DRV_CLOSE:                 return MCIQTZ_drvClose(dwDevID);
624         case DRV_ENABLE:                return 1;
625         case DRV_DISABLE:               return 1;
626         case DRV_QUERYCONFIGURE:        return 1;
627         case DRV_CONFIGURE:             return MCIQTZ_drvConfigure(dwDevID);
628         case DRV_INSTALL:               return DRVCNF_RESTART;
629         case DRV_REMOVE:                return DRVCNF_RESTART;
630     }
631
632     /* session instance */
633     if (dwDevID == 0xFFFFFFFF)
634         return 1;
635
636     switch (wMsg) {
637         case MCI_OPEN_DRIVER:   return MCIQTZ_mciOpen      (dwDevID, dwParam1, (LPMCI_DGV_OPEN_PARMSW)     dwParam2);
638         case MCI_CLOSE_DRIVER:  return MCIQTZ_mciClose     (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)       dwParam2);
639         case MCI_PLAY:          return MCIQTZ_mciPlay      (dwDevID, dwParam1, (LPMCI_PLAY_PARMS)          dwParam2);
640         case MCI_SEEK:          return MCIQTZ_mciSeek      (dwDevID, dwParam1, (LPMCI_SEEK_PARMS)          dwParam2);
641         case MCI_STOP:          return MCIQTZ_mciStop      (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)       dwParam2);
642         case MCI_GETDEVCAPS:    return MCIQTZ_mciGetDevCaps(dwDevID, dwParam1, (LPMCI_GETDEVCAPS_PARMS)    dwParam2);
643         case MCI_SET:           return MCIQTZ_mciSet       (dwDevID, dwParam1, (LPMCI_DGV_SET_PARMS)       dwParam2);
644         case MCI_STATUS:        return MCIQTZ_mciStatus    (dwDevID, dwParam1, (LPMCI_DGV_STATUS_PARMSW)   dwParam2);
645         case MCI_WHERE:         return MCIQTZ_mciWhere     (dwDevID, dwParam1, (LPMCI_DGV_RECT_PARMS)      dwParam2);
646         case MCI_RECORD:
647         case MCI_PAUSE:
648         case MCI_RESUME:
649         case MCI_INFO:
650         case MCI_PUT:
651         case MCI_WINDOW:
652         case MCI_LOAD:
653         case MCI_SAVE:
654         case MCI_FREEZE:
655         case MCI_REALIZE:
656         case MCI_UNFREEZE:
657         case MCI_UPDATE:
658         case MCI_STEP:
659         case MCI_COPY:
660         case MCI_CUT:
661         case MCI_DELETE:
662         case MCI_PASTE:
663         case MCI_CUE:
664         /* Digital Video specific */
665         case MCI_CAPTURE:
666         case MCI_MONITOR:
667         case MCI_RESERVE:
668         case MCI_SETAUDIO:
669         case MCI_SIGNAL:
670         case MCI_SETVIDEO:
671         case MCI_QUALITY:
672         case MCI_LIST:
673         case MCI_UNDO:
674         case MCI_CONFIGURE:
675         case MCI_RESTORE:
676             FIXME("Unimplemented command [%08X]\n", wMsg);
677             break;
678         case MCI_SPIN:
679         case MCI_ESCAPE:
680             WARN("Unsupported command [%08X]\n", wMsg);
681             break;
682         case MCI_OPEN:
683         case MCI_CLOSE:
684             FIXME("Shouldn't receive a MCI_OPEN or CLOSE message\n");
685             break;
686         default:
687             TRACE("Sending msg [%08X] to default driver proc\n", wMsg);
688             return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
689     }
690
691     return MCIERR_UNRECOGNIZED_COMMAND;
692 }