Change RECT to use LONG to match win32 standard headers and fix format
[wine/multimedia.git] / dlls / winmm / mciavi / wnd.c
blob04450bb3fbada31000416de54f1151192327e155
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
3 /*
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
23 #include <string.h>
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);
36 switch (uMsg) {
37 case WM_CREATE:
38 SetWindowLongA(hWnd, 0, (LPARAM)((CREATESTRUCTA*)lParam)->lpCreateParams);
39 return DefWindowProcA(hWnd, uMsg, wParam, lParam);
41 case WM_DESTROY:
42 SetWindowLongA(hWnd, 0, 0);
43 return DefWindowProcA(hWnd, uMsg, wParam, lParam);
45 case WM_ERASEBKGND:
47 RECT rect;
48 GetClientRect(hWnd, &rect);
49 FillRect((HDC)wParam, &rect, GetStockObject(BLACK_BRUSH));
51 break;
52 case WM_PAINT:
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);
61 if (wParam) {
62 EnterCriticalSection(&wma->cs);
63 MCIAVI_PaintFrame(wma, (HDC)wParam);
64 LeaveCriticalSection(&wma->cs);
65 } else {
66 PAINTSTRUCT ps;
67 HDC hDC = BeginPaint(hWnd, &ps);
69 EnterCriticalSection(&wma->cs);
70 MCIAVI_PaintFrame(wma, hDC);
71 LeaveCriticalSection(&wma->cs);
73 EndPaint(hWnd, &ps);
76 break;
78 default:
79 return DefWindowProcA(hWnd, uMsg, wParam, lParam);
81 return 0;
84 BOOL MCIAVI_CreateWindow(WINE_MCIAVI* wma, DWORD dwFlags, LPMCI_DGV_OPEN_PARMSA lpOpenParms)
86 WNDCLASSA wndClass;
87 HWND hParent = 0;
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",
110 dwStyle, p, p,
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);
123 RECT rc;
124 char buffer[256];
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) {
132 rc = lpParms->rc;
133 } else {
134 SetRectEmpty(&rc);
137 *buffer = 0;
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);
158 return 0;
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);
167 LPSTR x = "";
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) {
177 x = "Dest";
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) {
185 x = "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) {
195 x = "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);
201 return 0;
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);
218 #if 0
219 if (wma->hWnd) DestroyWindow(wma->hWnd);
220 /* is the window to be subclassed ? */
221 wma->hWnd = lpParms->hWnd;
222 #endif
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);
233 return 0;