1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
4 * Digital video MCI Wine Driver
6 * Copyright 1999, 2000 Eric POUECH
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "private_mciavi.h"
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(mciavi
);
29 static LRESULT WINAPI
MCIAVI_WindowProc(HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
31 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hWnd
, uMsg
, wParam
, lParam
);
33 if (!(WINE_MCIAVI
*)GetWindowLongA(hWnd
, 0) && uMsg
!= WM_CREATE
)
34 return DefWindowProcA(hWnd
, uMsg
, wParam
, lParam
);
38 SetWindowLongA(hWnd
, 0, (LPARAM
)((CREATESTRUCTA
*)lParam
)->lpCreateParams
);
39 return DefWindowProcA(hWnd
, uMsg
, wParam
, lParam
);
42 SetWindowLongA(hWnd
, 0, 0);
43 return DefWindowProcA(hWnd
, uMsg
, wParam
, lParam
);
48 GetClientRect(hWnd
, &rect
);
49 FillRect((HDC
)wParam
, &rect
, GetStockObject(BLACK_BRUSH
));
54 WINE_MCIAVI
* wma
= (WINE_MCIAVI
*)GetWindowLongA(hWnd
, 0);
56 /* the animation isn't playing, don't paint */
57 if (wma
->dwStatus
== MCI_MODE_NOT_READY
)
58 /* default paint handling */
59 return DefWindowProcA(hWnd
, uMsg
, wParam
, lParam
);
62 EnterCriticalSection(&wma
->cs
);
63 MCIAVI_PaintFrame(wma
, (HDC
)wParam
);
64 LeaveCriticalSection(&wma
->cs
);
67 HDC hDC
= BeginPaint(hWnd
, &ps
);
69 EnterCriticalSection(&wma
->cs
);
70 MCIAVI_PaintFrame(wma
, hDC
);
71 LeaveCriticalSection(&wma
->cs
);
79 return DefWindowProcA(hWnd
, uMsg
, wParam
, lParam
);
84 BOOL
MCIAVI_CreateWindow(WINE_MCIAVI
* wma
, DWORD dwFlags
, LPMCI_DGV_OPEN_PARMSA lpOpenParms
)
88 DWORD dwStyle
= WS_OVERLAPPEDWINDOW
;
89 int p
= CW_USEDEFAULT
;
91 /* what should be done ? */
92 if (wma
->hWnd
) return TRUE
;
94 ZeroMemory(&wndClass
, sizeof(WNDCLASSA
));
95 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
96 wndClass
.lpfnWndProc
= (WNDPROC
)MCIAVI_WindowProc
;
97 wndClass
.cbClsExtra
= 0;
98 wndClass
.cbWndExtra
= sizeof(WINE_MCIAVI
*);
99 wndClass
.hCursor
= LoadCursorA(0, IDC_ARROWA
);
100 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
101 wndClass
.lpszClassName
= "MCIAVI";
103 RegisterClassA(&wndClass
);
105 if (dwFlags
& MCI_DGV_OPEN_PARENT
) hParent
= lpOpenParms
->hWndParent
;
106 if (dwFlags
& MCI_DGV_OPEN_WS
) dwStyle
= lpOpenParms
->dwStyle
;
107 if (dwStyle
& WS_CHILD
) p
= 0;
109 wma
->hWnd
= CreateWindowA("MCIAVI", "Wine MCI-AVI player",
111 (wma
->hic
? wma
->outbih
: wma
->inbih
)->biWidth
,
112 (wma
->hic
? wma
->outbih
: wma
->inbih
)->biHeight
,
113 hParent
, 0, MCIAVI_hInstance
, wma
);
114 return (BOOL
)wma
->hWnd
;
117 /***************************************************************************
118 * MCIAVI_mciPut [internal]
120 DWORD
MCIAVI_mciPut(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_PUT_PARMS lpParms
)
122 WINE_MCIAVI
* wma
= MCIAVI_mciGetOpenDev(wDevID
);
126 FIXME("(%04x, %08lX, %p) : stub\n", wDevID
, dwFlags
, lpParms
);
128 if (lpParms
== NULL
) return MCIERR_NULL_PARAMETER_BLOCK
;
129 if (wma
== NULL
) return MCIERR_INVALID_DEVICE_ID
;
131 if (dwFlags
& MCI_DGV_RECT
) {
138 if (dwFlags
& MCI_DGV_PUT_CLIENT
) {
139 strncat(buffer
, "PUT_CLIENT", sizeof(buffer
));
141 if (dwFlags
& MCI_DGV_PUT_DESTINATION
) {
142 strncat(buffer
, "PUT_DESTINATION", sizeof(buffer
));
144 if (dwFlags
& MCI_DGV_PUT_FRAME
) {
145 strncat(buffer
, "PUT_FRAME", sizeof(buffer
));
147 if (dwFlags
& MCI_DGV_PUT_SOURCE
) {
148 strncat(buffer
, "PUT_SOURCE", sizeof(buffer
));
150 if (dwFlags
& MCI_DGV_PUT_VIDEO
) {
151 strncat(buffer
, "PUT_VIDEO", sizeof(buffer
));
153 if (dwFlags
& MCI_DGV_PUT_WINDOW
) {
154 strncat(buffer
, "PUT_WINDOW", sizeof(buffer
));
156 TRACE("%s (%ld,%ld,%ld,%ld)\n", buffer
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
161 /******************************************************************************
162 * MCIAVI_mciWhere [internal]
164 DWORD
MCIAVI_mciWhere(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_RECT_PARMS lpParms
)
166 WINE_MCIAVI
* wma
= MCIAVI_mciGetOpenDev(wDevID
);
169 TRACE("(%04x, %08lx, %p)\n", wDevID
, dwFlags
, lpParms
);
171 if (lpParms
== NULL
) return MCIERR_NULL_PARAMETER_BLOCK
;
172 if (wma
== NULL
) return MCIERR_INVALID_DEVICE_ID
;
174 if (dwFlags
& MCI_DGV_WHERE_MAX
) FIXME("Max NIY\n");
176 if (dwFlags
& MCI_DGV_WHERE_DESTINATION
) {
178 GetClientRect(wma
->hWnd
, &lpParms
->rc
);
180 if (dwFlags
& MCI_DGV_WHERE_FRAME
) {
181 FIXME(x
= "Frame\n");
182 return MCIERR_UNRECOGNIZED_COMMAND
;
184 if (dwFlags
& MCI_DGV_WHERE_SOURCE
) {
186 lpParms
->rc
.left
= lpParms
->rc
.top
= 0;
187 lpParms
->rc
.right
= wma
->mah
.dwWidth
;
188 lpParms
->rc
.bottom
= wma
->mah
.dwHeight
;
190 if (dwFlags
& MCI_DGV_WHERE_VIDEO
) {
191 FIXME(x
= "Video\n");
192 return MCIERR_UNRECOGNIZED_COMMAND
;
194 if (dwFlags
& MCI_DGV_WHERE_WINDOW
) {
196 GetClientRect(wma
->hWnd
, &lpParms
->rc
);
198 TRACE("%s -> (%ld,%ld,%ld,%ld)\n",
199 x
, lpParms
->rc
.left
, lpParms
->rc
.top
, lpParms
->rc
.right
, lpParms
->rc
.bottom
);
204 /***************************************************************************
205 * MCIAVI_mciWindow [internal]
207 DWORD
MCIAVI_mciWindow(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_WINDOW_PARMSA lpParms
)
209 WINE_MCIAVI
* wma
= MCIAVI_mciGetOpenDev(wDevID
);
211 TRACE("(%04x, %08lX, %p)\n", wDevID
, dwFlags
, lpParms
);
213 if (lpParms
== NULL
) return MCIERR_NULL_PARAMETER_BLOCK
;
214 if (wma
== NULL
) return MCIERR_INVALID_DEVICE_ID
;
216 if (dwFlags
& MCI_DGV_WINDOW_HWND
) {
217 FIXME("Setting hWnd to %08lx\n", (DWORD
)lpParms
->hWnd
);
219 if (wma
->hWnd
) DestroyWindow(wma
->hWnd
);
220 /* is the window to be subclassed ? */
221 wma
->hWnd
= lpParms
->hWnd
;
224 if (dwFlags
& MCI_DGV_WINDOW_STATE
) {
225 TRACE("Setting nCmdShow to %d\n", lpParms
->nCmdShow
);
226 ShowWindow(wma
->hWnd
, lpParms
->nCmdShow
);
228 if (dwFlags
& MCI_DGV_WINDOW_TEXT
) {
229 TRACE("Setting caption to '%s'\n", lpParms
->lpstrText
);
230 SetWindowTextA(wma
->hWnd
, lpParms
->lpstrText
);