[MCIAVI32] Sync with Wine Staging 3.3. CORE-14434
[reactos.git] / dll / win32 / mciavi32 / wnd.c
index 43019eb..c9da9ec 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include <string.h>
 #include "private_mciavi.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(mciavi);
 
 static const WCHAR mciaviW[] = {'M','C','I','A','V','I',0};
 
@@ -105,7 +109,7 @@ BOOL MCIAVI_RegisterClass(void)
     return FALSE;
 }
 
-BOOL    MCIAVI_CreateWindow(WINE_MCIAVI* wma, DWORD dwFlags, LPMCI_DGV_OPEN_PARMSW lpOpenParms)
+BOOL    MCIAVI_CreateWindow(WINE_MCIAVI* wma, DWORD dwFlags, LPMCI_DGV_OPEN_PARMSW lpParms)
 {
     static const WCHAR captionW[] = {'W','i','n','e',' ','M','C','I','-','A','V','I',' ','p','l','a','y','e','r',0};
     HWND       hParent = 0;
@@ -115,12 +119,14 @@ BOOL    MCIAVI_CreateWindow(WINE_MCIAVI* wma, DWORD dwFlags, LPMCI_DGV_OPEN_PARM
     /* what should be done ? */
     if (wma->hWnd) return TRUE;
 
-    if (dwFlags & MCI_DGV_OPEN_PARENT) hParent = lpOpenParms->hWndParent;
-    if (dwFlags & MCI_DGV_OPEN_WS)     dwStyle = lpOpenParms->dwStyle;
+    if (dwFlags & MCI_DGV_OPEN_PARENT) hParent = lpParms->hWndParent;
+    if (dwFlags & MCI_DGV_OPEN_WS)     dwStyle = lpParms->dwStyle;
+
+    if (wma->hic)
+        SetRect(&rc, 0, 0, wma->outbih->biWidth, wma->outbih->biHeight);
+    else
+        SetRect(&rc, 0, 0, wma->inbih->biWidth, wma->inbih->biHeight);
 
-    rc.left = rc.top = 0;
-    rc.right = (wma->hic ? wma->outbih : wma->inbih)->biWidth;
-    rc.bottom = (wma->hic ? wma->outbih : wma->inbih)->biHeight;
     AdjustWindowRect(&rc, dwStyle, FALSE);
     if (!(dwStyle & (WS_CHILD|WS_POPUP))) /* overlapped window ? */
     {
@@ -135,6 +141,9 @@ BOOL    MCIAVI_CreateWindow(WINE_MCIAVI* wma, DWORD dwFlags, LPMCI_DGV_OPEN_PARM
                               hParent, 0, MCIAVI_hInstance,
                               ULongToPtr(wma->wDevID));
     wma->hWndPaint = wma->hWnd;
+
+    TRACE("(%04x, %08X, %p, style %x, parent %p, dimensions %dx%d, hwnd %p)\n", wma->wDevID,
+          dwFlags, lpParms, dwStyle, hParent, rc.right - rc.left, rc.bottom - rc.top, wma->hWnd);
     return wma->hWnd != 0;
 }
 
@@ -157,10 +166,8 @@ DWORD      MCIAVI_mciPut(UINT wDevID, DWORD dwFlags, LPMCI_DGV_PUT_PARMS lpParms)
     if (dwFlags & MCI_DGV_RECT) {
         /* In MCI, RECT structure is used differently: rc.right = width & rc.bottom = height
          * So convert input MCI RECT into a normal RECT */
-        rc.left = lpParms->rc.left;
-        rc.top = lpParms->rc.top;
-        rc.right = lpParms->rc.left + lpParms->rc.right;
-        rc.bottom = lpParms->rc.top + lpParms->rc.bottom;
+        SetRect(&rc, lpParms->rc.left, lpParms->rc.top, lpParms->rc.left + lpParms->rc.right,
+                lpParms->rc.top + lpParms->rc.bottom);
     } else {
         GetClientRect(wma->hWndPaint, &rc);
     }
@@ -231,10 +238,7 @@ DWORD      MCIAVI_mciWhere(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms)
     }
     if (dwFlags & MCI_DGV_WHERE_SOURCE) {
        if (dwFlags & MCI_DGV_WHERE_MAX) {
-           rc.left = 0;
-           rc.top = 0;
-           rc.right = wma->inbih->biWidth;
-           rc.bottom = wma->inbih->biHeight;
+            SetRect(&rc, 0, 0, wma->inbih->biWidth, wma->inbih->biHeight);
            TRACE("WHERE_SOURCE_MAX %s\n", wine_dbgstr_rect(&rc));
        } else {
            TRACE("WHERE_SOURCE %s\n", wine_dbgstr_rect(&wma->source));
@@ -261,10 +265,7 @@ DWORD      MCIAVI_mciWhere(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms)
 
     /* In MCI, RECT structure is used differently: rc.right = width & rc.bottom = height
      * So convert the normal RECT into a MCI RECT before returning */
-    lpParms->rc.left = rc.left;
-    lpParms->rc.top = rc.top;
-    lpParms->rc.right = rc.right - rc.left;
-    lpParms->rc.bottom = rc.bottom - rc.top;
+    SetRect(&lpParms->rc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
 
     LeaveCriticalSection(&wma->cs);
     return 0;