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;
92 /* what should be done ? */
93 if (wma->hWnd) return TRUE;
95 ZeroMemory(&wndClass, sizeof(WNDCLASSA));
96 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
97 wndClass.lpfnWndProc = (WNDPROC)MCIAVI_WindowProc;
98 wndClass.cbClsExtra = 0;
99 wndClass.cbWndExtra = sizeof(WINE_MCIAVI*);
100 wndClass.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
101 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
102 wndClass.lpszClassName = "MCIAVI";
104 RegisterClassA(&wndClass);
106 if (dwFlags & MCI_DGV_OPEN_PARENT) hParent = lpOpenParms->hWndParent;
107 if (dwFlags & MCI_DGV_OPEN_WS) dwStyle = lpOpenParms->dwStyle;
108 if (dwStyle & WS_CHILD) p = 0;
112 rc.right = (wma->hic ? wma->outbih : wma->inbih)->biWidth;
113 rc.bottom = (wma->hic ? wma->outbih : wma->inbih)->biHeight;
114 AdjustWindowRect(&rc, dwStyle, FALSE);
116 wma->hWnd = CreateWindowA("MCIAVI", "Wine MCI-AVI player",
117 dwStyle, rc.left, rc.top,
119 hParent, 0, MCIAVI_hInstance, wma);
120 wma->hWndPaint = wma->hWnd;
121 return (BOOL)wma->hWnd;
124 /***************************************************************************
125 * MCIAVI_mciPut [internal]
127 DWORD MCIAVI_mciPut(UINT wDevID, DWORD dwFlags, LPMCI_DGV_PUT_PARMS lpParms)
129 WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID);
133 FIXME("(%04x, %08lX, %p) : stub\n", wDevID, dwFlags, lpParms);
135 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
136 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
138 if (dwFlags & MCI_DGV_RECT) {
145 if (dwFlags & MCI_DGV_PUT_CLIENT) {
146 strncat(buffer, "PUT_CLIENT", sizeof(buffer));
148 if (dwFlags & MCI_DGV_PUT_DESTINATION) {
149 strncat(buffer, "PUT_DESTINATION", sizeof(buffer));
151 if (dwFlags & MCI_DGV_PUT_FRAME) {
152 strncat(buffer, "PUT_FRAME", sizeof(buffer));
154 if (dwFlags & MCI_DGV_PUT_SOURCE) {
155 strncat(buffer, "PUT_SOURCE", sizeof(buffer));
157 if (dwFlags & MCI_DGV_PUT_VIDEO) {
158 strncat(buffer, "PUT_VIDEO", sizeof(buffer));
160 if (dwFlags & MCI_DGV_PUT_WINDOW) {
161 strncat(buffer, "PUT_WINDOW", sizeof(buffer));
163 TRACE("%s (%ld,%ld,%ld,%ld)\n", buffer, rc.left, rc.top, rc.right, rc.bottom);
168 /******************************************************************************
169 * MCIAVI_mciWhere [internal]
171 DWORD MCIAVI_mciWhere(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms)
173 WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID);
176 TRACE("(%04x, %08lx, %p)\n", wDevID, dwFlags, lpParms);
178 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
179 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
181 if (dwFlags & MCI_DGV_WHERE_MAX) FIXME("Max NIY\n");
183 if (dwFlags & MCI_DGV_WHERE_DESTINATION) {
185 GetClientRect(wma->hWnd, &lpParms->rc);
187 if (dwFlags & MCI_DGV_WHERE_FRAME) {
188 FIXME(x = "Frame\n");
189 return MCIERR_UNRECOGNIZED_COMMAND;
191 if (dwFlags & MCI_DGV_WHERE_SOURCE) {
193 lpParms->rc.left = lpParms->rc.top = 0;
194 lpParms->rc.right = wma->mah.dwWidth;
195 lpParms->rc.bottom = wma->mah.dwHeight;
197 if (dwFlags & MCI_DGV_WHERE_VIDEO) {
198 FIXME(x = "Video\n");
199 return MCIERR_UNRECOGNIZED_COMMAND;
201 if (dwFlags & MCI_DGV_WHERE_WINDOW) {
203 GetClientRect(wma->hWndPaint, &lpParms->rc);
205 TRACE("%s -> (%ld,%ld,%ld,%ld)\n",
206 x, lpParms->rc.left, lpParms->rc.top, lpParms->rc.right, lpParms->rc.bottom);
211 /***************************************************************************
212 * MCIAVI_mciWindow [internal]
214 DWORD MCIAVI_mciWindow(UINT wDevID, DWORD dwFlags, LPMCI_DGV_WINDOW_PARMSA lpParms)
216 WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID);
218 TRACE("(%04x, %08lX, %p)\n", wDevID, dwFlags, lpParms);
220 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
221 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
223 if (dwFlags & MCI_DGV_WINDOW_HWND) {
224 TRACE("Setting hWnd to %p\n", lpParms->hWnd);
225 if (wma->hWnd) ShowWindow(wma->hWnd, SW_HIDE);
226 wma->hWndPaint = (lpParms->hWnd == MCI_DGV_WINDOW_DEFAULT) ? wma->hWnd : lpParms->hWnd;
227 InvalidateRect(wma->hWndPaint, NULL, FALSE);
229 if (dwFlags & MCI_DGV_WINDOW_STATE) {
230 TRACE("Setting nCmdShow to %d\n", lpParms->nCmdShow);
231 ShowWindow(wma->hWndPaint, lpParms->nCmdShow);
233 if (dwFlags & MCI_DGV_WINDOW_TEXT) {
234 TRACE("Setting caption to '%s'\n", lpParms->lpstrText);
235 SetWindowTextA(wma->hWndPaint, lpParms->lpstrText);