Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenwnd.c
Go to the documentation of this file.
00001 /* 00002 * Digital video MCI Wine Driver 00003 * 00004 * Copyright 1999, 2000 Eric POUECH 00005 * Copyright 2003 Dmitry Timoshkov 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00020 */ 00021 00022 #include <string.h> 00023 #include "private_mciavi.h" 00024 #include "wine/debug.h" 00025 00026 WINE_DEFAULT_DEBUG_CHANNEL(mciavi); 00027 00028 static const WCHAR mciaviW[] = {'M','C','I','A','V','I',0}; 00029 00030 static LRESULT WINAPI MCIAVI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 00031 { 00032 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n", hWnd, uMsg, wParam, lParam); 00033 00034 switch (uMsg) { 00035 case WM_CREATE: 00036 SetWindowLongW(hWnd, 0, (LPARAM)((CREATESTRUCTW *)lParam)->lpCreateParams); 00037 return DefWindowProcW(hWnd, uMsg, wParam, lParam); 00038 00039 case WM_DESTROY: 00040 MCIAVI_mciClose(GetWindowLongW(hWnd, 0), MCI_WAIT, NULL); 00041 SetWindowLongW(hWnd, 0, 0); 00042 return DefWindowProcW(hWnd, uMsg, wParam, lParam); 00043 00044 case WM_ERASEBKGND: 00045 { 00046 RECT rect; 00047 GetClientRect(hWnd, &rect); 00048 FillRect((HDC)wParam, &rect, GetStockObject(BLACK_BRUSH)); 00049 } 00050 return 1; 00051 00052 case WM_PAINT: 00053 { 00054 WINE_MCIAVI *wma = (WINE_MCIAVI *)mciGetDriverData(GetWindowLongW(hWnd, 0)); 00055 00056 if (!wma) 00057 return DefWindowProcW(hWnd, uMsg, wParam, lParam); 00058 00059 EnterCriticalSection(&wma->cs); 00060 00061 /* the animation isn't playing, don't paint */ 00062 if (wma->dwStatus == MCI_MODE_NOT_READY) 00063 { 00064 LeaveCriticalSection(&wma->cs); 00065 /* default paint handling */ 00066 return DefWindowProcW(hWnd, uMsg, wParam, lParam); 00067 } 00068 00069 if (wParam) 00070 MCIAVI_PaintFrame(wma, (HDC)wParam); 00071 else 00072 { 00073 PAINTSTRUCT ps; 00074 BeginPaint(hWnd, &ps); 00075 MCIAVI_PaintFrame(wma, ps.hdc); 00076 EndPaint(hWnd, &ps); 00077 } 00078 00079 LeaveCriticalSection(&wma->cs); 00080 } 00081 return 1; 00082 00083 default: 00084 return DefWindowProcW(hWnd, uMsg, wParam, lParam); 00085 } 00086 } 00087 00088 BOOL MCIAVI_UnregisterClass(void) 00089 { 00090 return UnregisterClassW(mciaviW, MCIAVI_hInstance); 00091 } 00092 00093 BOOL MCIAVI_RegisterClass(void) 00094 { 00095 WNDCLASSW wndClass; 00096 00097 ZeroMemory(&wndClass, sizeof(WNDCLASSW)); 00098 wndClass.style = CS_DBLCLKS; 00099 wndClass.lpfnWndProc = MCIAVI_WindowProc; 00100 wndClass.cbWndExtra = sizeof(MCIDEVICEID); 00101 wndClass.hInstance = MCIAVI_hInstance; 00102 wndClass.hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW); 00103 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); 00104 wndClass.lpszClassName = mciaviW; 00105 00106 if (RegisterClassW(&wndClass)) return TRUE; 00107 if (GetLastError() == ERROR_CLASS_ALREADY_EXISTS) return TRUE; 00108 00109 return FALSE; 00110 } 00111 00112 BOOL MCIAVI_CreateWindow(WINE_MCIAVI* wma, DWORD dwFlags, LPMCI_DGV_OPEN_PARMSW lpOpenParms) 00113 { 00114 static const WCHAR captionW[] = {'W','i','n','e',' ','M','C','I','-','A','V','I',' ','p','l','a','y','e','r',0}; 00115 HWND hParent = 0; 00116 DWORD dwStyle = WS_OVERLAPPEDWINDOW; 00117 RECT rc; 00118 00119 /* what should be done ? */ 00120 if (wma->hWnd) return TRUE; 00121 00122 if (dwFlags & MCI_DGV_OPEN_PARENT) hParent = lpOpenParms->hWndParent; 00123 if (dwFlags & MCI_DGV_OPEN_WS) dwStyle = lpOpenParms->dwStyle; 00124 00125 rc.left = rc.top = 0; 00126 rc.right = (wma->hic ? wma->outbih : wma->inbih)->biWidth; 00127 rc.bottom = (wma->hic ? wma->outbih : wma->inbih)->biHeight; 00128 AdjustWindowRect(&rc, dwStyle, FALSE); 00129 if (!(dwStyle & (WS_CHILD|WS_POPUP))) /* overlapped window ? */ 00130 { 00131 rc.right -= rc.left; 00132 rc.bottom -= rc.top; 00133 rc.left = rc.top = CW_USEDEFAULT; 00134 } 00135 00136 wma->hWnd = CreateWindowW(mciaviW, captionW, 00137 dwStyle, rc.left, rc.top, 00138 rc.right, rc.bottom, 00139 hParent, 0, MCIAVI_hInstance, 00140 ULongToPtr(wma->wDevID)); 00141 wma->hWndPaint = wma->hWnd; 00142 return wma->hWnd != 0; 00143 } 00144 00145 /*************************************************************************** 00146 * MCIAVI_mciPut [internal] 00147 */ 00148 DWORD MCIAVI_mciPut(UINT wDevID, DWORD dwFlags, LPMCI_DGV_PUT_PARMS lpParms) 00149 { 00150 WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID); 00151 RECT rc; 00152 00153 TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms); 00154 00155 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; 00156 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID; 00157 if (dwFlags & MCI_TEST) return 0; 00158 00159 EnterCriticalSection(&wma->cs); 00160 00161 if (dwFlags & MCI_DGV_RECT) { 00162 /* In MCI, RECT structure is used differently: rc.right = width & rc.bottom = height 00163 * So convert input MCI RECT into a normal RECT */ 00164 rc.left = lpParms->rc.left; 00165 rc.top = lpParms->rc.top; 00166 rc.right = lpParms->rc.left + lpParms->rc.right; 00167 rc.bottom = lpParms->rc.top + lpParms->rc.bottom; 00168 } else { 00169 GetClientRect(wma->hWndPaint, &rc); 00170 } 00171 00172 if (dwFlags & MCI_DGV_PUT_CLIENT) { 00173 FIXME("PUT_CLIENT %s\n", wine_dbgstr_rect(&rc)); 00174 LeaveCriticalSection(&wma->cs); 00175 return MCIERR_UNRECOGNIZED_COMMAND; 00176 } 00177 if (dwFlags & MCI_DGV_PUT_DESTINATION) { 00178 TRACE("PUT_DESTINATION %s\n", wine_dbgstr_rect(&rc)); 00179 wma->dest = rc; 00180 } 00181 if (dwFlags & MCI_DGV_PUT_FRAME) { 00182 FIXME("PUT_FRAME %s\n", wine_dbgstr_rect(&rc)); 00183 LeaveCriticalSection(&wma->cs); 00184 return MCIERR_UNRECOGNIZED_COMMAND; 00185 } 00186 if (dwFlags & MCI_DGV_PUT_SOURCE) { 00187 TRACE("PUT_SOURCE %s\n", wine_dbgstr_rect(&rc)); 00188 wma->source = rc; 00189 } 00190 if (dwFlags & MCI_DGV_PUT_VIDEO) { 00191 FIXME("PUT_VIDEO %s\n", wine_dbgstr_rect(&rc)); 00192 LeaveCriticalSection(&wma->cs); 00193 return MCIERR_UNRECOGNIZED_COMMAND; 00194 } 00195 if (dwFlags & MCI_DGV_PUT_WINDOW) { 00196 TRACE("PUT_WINDOW %s\n", wine_dbgstr_rect(&rc)); 00197 SetWindowPos(wma->hWndPaint, NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOZORDER); 00198 } 00199 LeaveCriticalSection(&wma->cs); 00200 return 0; 00201 } 00202 00203 /****************************************************************************** 00204 * MCIAVI_mciWhere [internal] 00205 */ 00206 DWORD MCIAVI_mciWhere(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms) 00207 { 00208 WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID); 00209 RECT rc; 00210 00211 TRACE("(%04x, %08x, %p)\n", wDevID, dwFlags, lpParms); 00212 00213 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; 00214 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID; 00215 /* Ignore MCI_TEST flag. */ 00216 00217 EnterCriticalSection(&wma->cs); 00218 00219 if (dwFlags & MCI_DGV_WHERE_DESTINATION) { 00220 if (dwFlags & MCI_DGV_WHERE_MAX) { 00221 GetClientRect(wma->hWndPaint, &rc); 00222 TRACE("WHERE_DESTINATION_MAX %s\n", wine_dbgstr_rect(&rc)); 00223 } else { 00224 TRACE("WHERE_DESTINATION %s\n", wine_dbgstr_rect(&wma->dest)); 00225 rc = wma->dest; 00226 } 00227 } 00228 if (dwFlags & MCI_DGV_WHERE_FRAME) { 00229 if (dwFlags & MCI_DGV_WHERE_MAX) 00230 FIXME("MCI_DGV_WHERE_FRAME_MAX\n"); 00231 else 00232 FIXME("MCI_DGV_WHERE_FRAME\n"); 00233 LeaveCriticalSection(&wma->cs); 00234 return MCIERR_UNRECOGNIZED_COMMAND; 00235 } 00236 if (dwFlags & MCI_DGV_WHERE_SOURCE) { 00237 if (dwFlags & MCI_DGV_WHERE_MAX) { 00238 rc.left = 0; 00239 rc.top = 0; 00240 rc.right = wma->inbih->biWidth; 00241 rc.bottom = wma->inbih->biHeight; 00242 TRACE("WHERE_SOURCE_MAX %s\n", wine_dbgstr_rect(&rc)); 00243 } else { 00244 TRACE("WHERE_SOURCE %s\n", wine_dbgstr_rect(&wma->source)); 00245 rc = wma->source; 00246 } 00247 } 00248 if (dwFlags & MCI_DGV_WHERE_VIDEO) { 00249 if (dwFlags & MCI_DGV_WHERE_MAX) 00250 FIXME("WHERE_VIDEO_MAX\n"); 00251 else 00252 FIXME("WHERE_VIDEO\n"); 00253 LeaveCriticalSection(&wma->cs); 00254 return MCIERR_UNRECOGNIZED_COMMAND; 00255 } 00256 if (dwFlags & MCI_DGV_WHERE_WINDOW) { 00257 if (dwFlags & MCI_DGV_WHERE_MAX) { 00258 GetWindowRect(GetDesktopWindow(), &rc); 00259 TRACE("WHERE_WINDOW_MAX %s\n", wine_dbgstr_rect(&rc)); 00260 } else { 00261 GetWindowRect(wma->hWndPaint, &rc); 00262 TRACE("WHERE_WINDOW %s\n", wine_dbgstr_rect(&rc)); 00263 } 00264 } 00265 00266 /* In MCI, RECT structure is used differently: rc.right = width & rc.bottom = height 00267 * So convert the normal RECT into a MCI RECT before returning */ 00268 lpParms->rc.left = rc.left; 00269 lpParms->rc.top = rc.top; 00270 lpParms->rc.right = rc.right - rc.left; 00271 lpParms->rc.bottom = rc.bottom - rc.top; 00272 00273 LeaveCriticalSection(&wma->cs); 00274 return 0; 00275 } 00276 00277 /*************************************************************************** 00278 * MCIAVI_mciWindow [internal] 00279 */ 00280 DWORD MCIAVI_mciWindow(UINT wDevID, DWORD dwFlags, LPMCI_DGV_WINDOW_PARMSW lpParms) 00281 { 00282 WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID); 00283 00284 TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms); 00285 00286 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; 00287 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID; 00288 if (dwFlags & MCI_TEST) return 0; 00289 00290 EnterCriticalSection(&wma->cs); 00291 00292 if (dwFlags & MCI_DGV_WINDOW_HWND) { 00293 if (IsWindow(lpParms->hWnd)) 00294 { 00295 TRACE("Setting hWnd to %p\n", lpParms->hWnd); 00296 if (wma->hWnd) ShowWindow(wma->hWnd, SW_HIDE); 00297 wma->hWndPaint = (lpParms->hWnd == MCI_DGV_WINDOW_DEFAULT) ? wma->hWnd : lpParms->hWnd; 00298 } 00299 } 00300 if (dwFlags & MCI_DGV_WINDOW_STATE) { 00301 TRACE("Setting nCmdShow to %d\n", lpParms->nCmdShow); 00302 ShowWindow(wma->hWndPaint, lpParms->nCmdShow); 00303 } 00304 if (dwFlags & MCI_DGV_WINDOW_TEXT) { 00305 TRACE("Setting caption to %s\n", debugstr_w(lpParms->lpstrText)); 00306 SetWindowTextW(wma->hWndPaint, lpParms->lpstrText); 00307 } 00308 00309 LeaveCriticalSection(&wma->cs); 00310 return 0; 00311 } Generated on Fri May 25 2012 04:22:47 for ReactOS by
1.7.6.1
|