Autosyncing with Wine HEAD
authorThe Wine Synchronizer <winesync@svn.reactos.org>
Mon, 14 Jan 2008 12:43:19 +0000 (12:43 +0000)
committerThe Wine Synchronizer <winesync@svn.reactos.org>
Mon, 14 Jan 2008 12:43:19 +0000 (12:43 +0000)
svn path=/trunk/; revision=31774

reactos/dll/win32/comdlg32/colordlg.c
reactos/dll/win32/comdlg32/comdlg32.rbuild
reactos/dll/win32/comdlg32/filedlg.c
reactos/dll/win32/comdlg32/filedlg31.c
reactos/dll/win32/comdlg32/filedlgbrowser.c
reactos/dll/win32/comdlg32/finddlg32.c
reactos/dll/win32/comdlg32/fontdlg.c
reactos/dll/win32/comdlg32/printdlg.c

index a1cd5f6..777b0bd 100644 (file)
@@ -337,24 +337,29 @@ static int CC_MouseCheckColorGraph( HWND hDlg, int dlgitem, int *hori, int *vert
  ClientToScreen(hDlg, &point);
  hwnd = GetDlgItem( hDlg, dlgitem );
  GetWindowRect(hwnd, &rect);
- if (PtInRect(&rect, point))
- {
-  GetClientRect(hwnd, &rect);
-  ScreenToClient(hwnd, &point);
 
-  x = (long) point.x * MAXHORI;
-  x /= rect.right;
-  y = (long) (rect.bottom - point.y) * MAXVERT;
-  y /= rect.bottom;
-
-  if (hori)
-   *hori = x;
-  if (vert)
-   *vert = y;
-  return 1;
- }
- else
+ if (!PtInRect(&rect, point))
   return 0;
+
+ GetClientRect(hwnd, &rect);
+ ScreenToClient(hwnd, &point);
+
+ x = (long) point.x * MAXHORI;
+ x /= rect.right;
+ y = (long) (rect.bottom - point.y) * MAXVERT;
+ y /= rect.bottom;
+
+ if (x < 0) x = 0;
+ if (y < 0) y = 0;
+ if (x > MAXHORI) x = MAXHORI;
+ if (y > MAXVERT) y = MAXVERT;
+
+ if (hori)
+  *hori = x;
+ if (vert)
+  *vert = y;
+
+ return 1;
 }
 /***********************************************************************
  *                  CC_MouseCheckResultWindow                 [internal]
@@ -436,16 +441,8 @@ void CC_PaintSelectedColor( HWND hDlg, COLORREF cr )
   hBrush = CreateSolidBrush(cr);
   if (hBrush)
   {
-   hBrush = SelectObject(hdc, hBrush) ;
-   Rectangle(hdc, rect.left, rect.top, rect.right/2, rect.bottom);
-   DeleteObject ( SelectObject(hdc, hBrush) ) ;
-   hBrush = CreateSolidBrush( GetNearestColor(hdc, cr) );
-   if (hBrush)
-   {
-    hBrush = SelectObject(hdc, hBrush) ;
-    Rectangle(hdc, rect.right/2-1, rect.top, rect.right, rect.bottom);
-    DeleteObject(SelectObject(hdc, hBrush)) ;
-   }
+   FillRect(hdc, &rect, hBrush);
+   DrawEdge(hdc, &rect, BDR_SUNKENOUTER, BF_RECT);
   }
   ReleaseDC(hwnd, hdc);
  }
@@ -458,7 +455,7 @@ void CC_PaintTriangle( HWND hDlg, int y)
 {
  HDC hDC;
  long temp;
- int w = LOWORD(GetDialogBaseUnits());
+ int w = LOWORD(GetDialogBaseUnits()) / 2;
  POINT points[3];
  int height;
  int oben;
@@ -479,6 +476,7 @@ void CC_PaintTriangle( HWND hDlg, int y)
    oben = points[0].y;           /*  | \ |  */
                                  /*  |  \|  */
    temp = (long)height * (long)y;
+   points[0].x += 1;
    points[0].y = oben + height - temp / (long)MAXVERT;
    points[1].y = points[0].y + w;
    points[2].y = points[0].y - w;
@@ -491,7 +489,11 @@ void CC_PaintTriangle( HWND hDlg, int y)
    lpp->old3angle.right = points[1].x + 1;
    lpp->old3angle.top   = points[2].y - 1;
    lpp->old3angle.bottom= points[1].y + 1;
+
+   hbr = SelectObject(hDC, GetStockObject(BLACK_BRUSH));
    Polygon(hDC, points, 3);
+   SelectObject(hDC, hbr);
+
    ReleaseDC(hDlg, hDC);
  }
 }
@@ -503,7 +505,8 @@ void CC_PaintTriangle( HWND hDlg, int y)
 void CC_PaintCross( HWND hDlg, int x, int y)
 {
  HDC hDC;
- int w = GetDialogBaseUnits();
+ int w = GetDialogBaseUnits() - 1;
+ int wc = GetDialogBaseUnits() * 3 / 4;
  HWND hwnd = GetDlgItem(hDlg, 0x2c6);
  LPCCPRIV lpp = (LPCCPRIV) GetPropW( hDlg, szColourDialogProp );
  RECT rect;
@@ -515,8 +518,7 @@ void CC_PaintCross( HWND hDlg, int x, int y)
    GetClientRect(hwnd, &rect);
    hDC = GetDC(hwnd);
    SelectClipRgn( hDC, CreateRectRgnIndirect(&rect));
-   hPen = CreatePen(PS_SOLID, 2, 0xffffff); /* -white- color */
-   hPen = SelectObject(hDC, hPen);
+
    point.x = ((long)rect.right * (long)x) / (long)MAXHORI;
    point.y = rect.bottom - ((long)rect.bottom * (long)y) / (long)MAXVERT;
    if ( lpp->oldcross.left != lpp->oldcross.right )
@@ -529,11 +531,18 @@ void CC_PaintCross( HWND hDlg, int x, int y)
    lpp->oldcross.top    = point.y - w - 1;
    lpp->oldcross.bottom = point.y + w + 1;
 
+   hPen = CreatePen(PS_SOLID, 3, 0x000000); /* -black- color */
+   hPen = SelectObject(hDC, hPen);
    MoveToEx(hDC, point.x - w, point.y, &p);
+   LineTo(hDC, point.x - wc, point.y);
+   MoveToEx(hDC, point.x + wc, point.y, &p);
    LineTo(hDC, point.x + w, point.y);
    MoveToEx(hDC, point.x, point.y - w, &p);
+   LineTo(hDC, point.x, point.y - wc);
+   MoveToEx(hDC, point.x, point.y + wc, &p);
    LineTo(hDC, point.x, point.y + w);
-   DeleteObject( SelectObject(hDC, hPen)) ;
+   DeleteObject( SelectObject(hDC, hPen));
+
    ReleaseDC(hwnd, hDC);
  }
 }
@@ -642,7 +651,7 @@ static void CC_PaintLumBar( HWND hDlg, int hue, int sat )
    rect.bottom = rect.top;
   }
   GetClientRect(hwnd, &rect);
-  FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH) );
+  DrawEdge(hDC, &rect, BDR_SUNKENOUTER, BF_RECT);
   ReleaseDC(hwnd, hDC);
  }
 }
@@ -730,7 +739,7 @@ void CC_SwitchToFullSize( HWND hDlg, COLORREF result, LPCRECT lprect )
 static void CC_PaintPredefColorArray( HWND hDlg, int rows, int cols)
 {
  HWND hwnd = GetDlgItem(hDlg, 0x2d0);
- RECT rect;
+ RECT rect, blockrect;
  HDC  hdc;
  HBRUSH hBrush;
  int dx, dy, i, j, k;
@@ -753,14 +762,17 @@ static void CC_PaintPredefColorArray( HWND hDlg, int rows, int cols)
    hBrush = CreateSolidBrush(predefcolors[j][i]);
    if (hBrush)
    {
-    hBrush = SelectObject(hdc, hBrush);
-    Rectangle(hdc, rect.left, rect.top,
-                rect.left + dx - DISTANCE, rect.top + dy - DISTANCE);
-    rect.left = rect.left + dx;
-    DeleteObject(SelectObject(hdc, hBrush)) ;
+    blockrect.left = rect.left;
+    blockrect.top = rect.top;
+    blockrect.right = rect.left + dx - DISTANCE;
+    blockrect.bottom = rect.top + dy - DISTANCE;
+    FillRect(hdc, &blockrect, hBrush);
+    DrawEdge(hdc, &blockrect, BDR_SUNKEN, BF_RECT);
+    DeleteObject(hBrush);
    }
+   rect.left += dx;
   }
-  rect.top = rect.top + dy;
+  rect.top += dy;
   rect.left = k;
  }
  ReleaseDC(hwnd, hdc);
@@ -774,7 +786,7 @@ static void CC_PaintPredefColorArray( HWND hDlg, int rows, int cols)
 void CC_PaintUserColorArray( HWND hDlg, int rows, int cols, const COLORREF *lpcr )
 {
  HWND hwnd = GetDlgItem(hDlg, 0x2d1);
- RECT rect;
+ RECT rect, blockrect;
  HDC  hdc;
  HBRUSH hBrush;
  int dx, dy, i, j, k;
@@ -799,14 +811,17 @@ void CC_PaintUserColorArray( HWND hDlg, int rows, int cols, const COLORREF *lpcr
     hBrush = CreateSolidBrush(lpcr[i+j*cols]);
     if (hBrush)
     {
-     hBrush = SelectObject(hdc, hBrush) ;
-     Rectangle(hdc, rect.left, rect.top,
-                  rect.left + dx - DISTANCE, rect.top + dy - DISTANCE);
-     rect.left = rect.left + dx;
-     DeleteObject( SelectObject(hdc, hBrush) ) ;
+     blockrect.left = rect.left;
+     blockrect.top = rect.top;
+     blockrect.right = rect.left + dx - DISTANCE;
+     blockrect.bottom = rect.top + dy - DISTANCE;
+     FillRect(hdc, &blockrect, hBrush);
+     DrawEdge(hdc, &blockrect, BDR_SUNKEN, BF_RECT);
+     DeleteObject(hBrush);
     }
+    rect.left += dx;
    }
-   rect.top = rect.top + dy;
+   rect.top += dy;
    rect.left = k;
   }
   ReleaseDC(hwnd, hdc);
@@ -816,7 +831,6 @@ void CC_PaintUserColorArray( HWND hDlg, int rows, int cols, const COLORREF *lpcr
 }
 
 
-
 /***********************************************************************
  *                             CC_HookCallChk                 [internal]
  */
@@ -1075,10 +1089,10 @@ LRESULT CC_WMPaint( HWND hDlg, WPARAM wParam, LPARAM lParam )
     CC_PaintPredefColorArray(hDlg, 6, 8);
     CC_PaintUserColorArray(hDlg, 2, 8, lpp->lpcc->lpCustColors);
     CC_PaintLumBar(hDlg, lpp->h, lpp->s);
-    CC_PaintCross(hDlg, lpp->h, lpp->s);
     CC_PaintTriangle(hDlg, lpp->l);
     CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
     CC_PaintColorGraph(hDlg);
+    CC_PaintCross(hDlg, lpp->h, lpp->s);
     EndPaint(hDlg, &ps);
 
     return TRUE;
@@ -1346,7 +1360,7 @@ BOOL WINAPI ChooseColorA( LPCHOOSECOLORA lpChCol )
   lpcc->lpCustColors = lpChCol->lpCustColors;
   lpcc->Flags = lpChCol->Flags;
   lpcc->lCustData = lpChCol->lCustData;
-  lpcc->lpfnHook = (LPCCHOOKPROC) lpChCol->lpfnHook;
+  lpcc->lpfnHook = lpChCol->lpfnHook;
   if ((lpcc->Flags & CC_ENABLETEMPLATE) && (lpChCol->lpTemplateName)) {
       if (HIWORD(lpChCol->lpTemplateName)) {
          INT len = MultiByteToWideChar( CP_ACP, 0, lpChCol->lpTemplateName, -1, NULL, 0);
index 055d3eb..92f36a5 100644 (file)
@@ -1,5 +1,6 @@
 <?xml version="1.0"?>
 <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
+<group>
 <module name="comdlg32" type="win32dll" baseaddress="${BASEADDRESS_COMDLG32}" installbase="system32" installname="comdlg32.dll" allowwarnings="true">
        <importlibrary definition="comdlg32.spec.def" />
        <include base="comdlg32">.</include>
@@ -30,3 +31,4 @@
        <file>rsrc.rc</file>
        <file>comdlg32.spec</file>
 </module>
+</group>
index 67fefd1..3e9c692 100644 (file)
@@ -2140,7 +2140,6 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
         if(lstrlenW(lpstrPathAndFile) < fodInfos->ofnInfos->nMaxFile -
             ((fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT) ? 1 : 0))
         {
-          LPWSTR lpszTemp;
 
           /* fill destination buffer */
           if (fodInfos->ofnInfos->lpstrFile)
@@ -2164,13 +2163,31 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
              }
           }
 
-          /* set filename offset */
-          lpszTemp = PathFindFileNameW(lpstrPathAndFile);
-          fodInfos->ofnInfos->nFileOffset = (lpszTemp - lpstrPathAndFile);
+          if(fodInfos->unicode)
+          {
+              LPWSTR lpszTemp;
+
+              /* set filename offset */
+              lpszTemp = PathFindFileNameW(lpstrPathAndFile);
+              fodInfos->ofnInfos->nFileOffset = (lpszTemp - lpstrPathAndFile);
+
+              /* set extension offset */
+              lpszTemp = PathFindExtensionW(lpstrPathAndFile);
+              fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - lpstrPathAndFile) + 1 : 0;
+          }
+          else
+          {
+               LPSTR lpszTemp;
+               LPOPENFILENAMEA ofn = (LPOPENFILENAMEA)fodInfos->ofnInfos;
+
+              /* set filename offset */
+              lpszTemp = PathFindFileNameA(ofn->lpstrFile);
+              fodInfos->ofnInfos->nFileOffset = (lpszTemp - ofn->lpstrFile);
 
-          /* set extension offset */
-          lpszTemp = PathFindExtensionW(lpstrPathAndFile);
-          fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - lpstrPathAndFile) + 1 : 0;
+              /* set extension offset */
+              lpszTemp = PathFindExtensionA(ofn->lpstrFile);
+              fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - ofn->lpstrFile) + 1 : 0;
+          }
 
           /* set the lpstrFileTitle */
           if(fodInfos->ofnInfos->lpstrFileTitle)
@@ -3658,12 +3675,20 @@ static void CALLBACK FD32_UpdateResult(const FD31_DATA *lfs)
 
     if (priv->ofnA)
     {
+        LPSTR lpszTemp;
         if (ofnW->nMaxFile &&
             !WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
                                   priv->ofnA->lpstrFile, ofnW->nMaxFile, NULL, NULL ))
             priv->ofnA->lpstrFile[ofnW->nMaxFile-1] = 0;
-        priv->ofnA->nFileOffset = ofnW->nFileOffset;
-        priv->ofnA->nFileExtension = ofnW->nFileExtension;
+
+        /* offsets are not guarenteed to be the same in WCHAR to MULTIBYTE conversion */
+        /* set filename offset */
+        lpszTemp = PathFindFileNameA(priv->ofnA->lpstrFile);
+        priv->ofnA->nFileOffset = (lpszTemp - priv->ofnA->lpstrFile);
+
+        /* set extension offset */
+        lpszTemp = PathFindExtensionA(priv->ofnA->lpstrFile);
+        priv->ofnA->nFileExtension = (*lpszTemp) ? (lpszTemp - priv->ofnA->lpstrFile) + 1 : 0;
     }
 }
 
index 0f697ed..10238de 100644 (file)
@@ -112,10 +112,36 @@ BOOL FD31_CallWindowProc(const FD31_DATA *lfs, UINT wMsg, WPARAM wParam,
     return lfs->callbacks->CWP(lfs, wMsg, wParam, lParam);
 }
 
+/***********************************************************************
+ *                             FD31_GetFileType                [internal]
+ */
+static LPCWSTR FD31_GetFileType(LPCWSTR cfptr, LPCWSTR fptr, const WORD index)
+{
+  int n, i;
+  i = 0;
+  if (cfptr)
+    for ( ;(n = lstrlenW(cfptr)) != 0; i++)
+      {
+       cfptr += n + 1;
+       if (i == index)
+         return cfptr;
+       cfptr += lstrlenW(cfptr) + 1;
+      }
+  if (fptr)
+    for ( ;(n = lstrlenW(fptr)) != 0; i++)
+      {
+       fptr += n + 1;
+       if (i == index)
+         return fptr;
+       fptr += lstrlenW(fptr) + 1;
+    }
+  return FILE_star; /* FIXME */
+}
+
 /***********************************************************************
  *                             FD31_ScanDir                 [internal]
  */
-static BOOL FD31_ScanDir(HWND hWnd, LPCWSTR newPath)
+static BOOL FD31_ScanDir(const OPENFILENAMEW *ofn, HWND hWnd, LPCWSTR newPath)
 {
     WCHAR              buffer[BUFFILE];
     HWND               hdlg, hdlgDir;
@@ -125,10 +151,10 @@ static BOOL FD31_ScanDir(HWND hWnd, LPCWSTR newPath)
     TRACE("Trying to change to %s\n", debugstr_w(newPath));
     if  ( newPath[0] && !SetCurrentDirectoryW( newPath ))
         return FALSE;
-    lstrcpynW(buffer, newPath, sizeof(buffer)/sizeof(WCHAR));
 
     /* get the list of spec files */
-    GetDlgItemTextW(hWnd, edt1, buffer, sizeof(buffer)/sizeof(WCHAR));
+    lstrcpynW(buffer, FD31_GetFileType(ofn->lpstrCustomFilter,
+              ofn->lpstrFilter, ofn->nFilterIndex - 1), BUFFILE);
 
     hCursorWait = LoadCursorA(0, (LPSTR)IDC_WAIT);
     oldCursor = SetCursor(hCursorWait);
@@ -145,8 +171,7 @@ static BOOL FD31_ScanDir(HWND hWnd, LPCWSTR newPath)
            if (scptr)  *scptr = 0;
             while (*filter == ' ') filter++;
            TRACE("Using file spec %s\n", debugstr_w(filter));
-           if (SendMessageW(hdlg, LB_DIR, 0, (LPARAM)filter) == LB_ERR)
-               return FALSE;
+           SendMessageW(hdlg, LB_DIR, 0, (LPARAM)filter);
            if (scptr) *scptr = ';';
                filter = (scptr) ? (scptr + 1) : 0;
         }
@@ -162,33 +187,6 @@ static BOOL FD31_ScanDir(HWND hWnd, LPCWSTR newPath)
     return lRet;
 }
 
-/***********************************************************************
- *                             FD31_GetFileType                [internal]
- */
-
-static LPCWSTR FD31_GetFileType(LPCWSTR cfptr, LPCWSTR fptr, const WORD index)
-{
-  int n, i;
-  i = 0;
-  if (cfptr)
-    for ( ;(n = lstrlenW(cfptr)) != 0; i++)
-      {
-       cfptr += n + 1;
-       if (i == index)
-         return cfptr;
-       cfptr += lstrlenW(cfptr) + 1;
-      }
-  if (fptr)
-    for ( ;(n = lstrlenW(fptr)) != 0; i++)
-      {
-       fptr += n + 1;
-       if (i == index)
-         return fptr;
-       fptr += lstrlenW(fptr) + 1;
-    }
-  return FILE_star; /* FIXME */
-}
-
 /***********************************************************************
  *                              FD31_WMDrawItem              [internal]
  */
@@ -375,7 +373,7 @@ static LRESULT FD31_DirListDblClick( const FD31_DATA *lfs )
     }
   strcatW(tmpstr, FILE_bslash);
 
-  FD31_ScanDir(hWnd, tmpstr);
+  FD31_ScanDir(lfs->ofnW, hWnd, tmpstr);
   /* notify the app */
   if (lfs->hook)
     {
@@ -450,7 +448,7 @@ static LRESULT FD31_TestPath( const FD31_DATA *lfs, LPWSTR path )
 
         TRACE("path=%s, tmpstr2=%s\n", debugstr_w(path), debugstr_w(tmpstr2));
         SetDlgItemTextW( hWnd, edt1, tmpstr2 );
-        FD31_ScanDir(hWnd, path);
+        FD31_ScanDir(lfs->ofnW, hWnd, path);
         return (lfs->ofnW->Flags & OFN_NOVALIDATE) ? TRUE : FALSE;
     }
 
@@ -462,7 +460,7 @@ static LRESULT FD31_TestPath( const FD31_DATA *lfs, LPWSTR path )
         strcatW(path, FILE_bslash);
 
     /* if ScanDir succeeds, we have changed the directory */
-    if (FD31_ScanDir(hWnd, path))
+    if (FD31_ScanDir(lfs->ofnW, hWnd, path))
         return FALSE; /* and path is not a valid file name */
 
     /* if not, this must be a filename */
@@ -477,7 +475,7 @@ static LRESULT FD31_TestPath( const FD31_DATA *lfs, LPWSTR path )
 
         lstrcpynW(tmpstr2, pBeginFileName + 1, sizeof(tmpstr2)/sizeof(WCHAR) );
         /* Should we MessageBox() if this fails? */
-        if (!FD31_ScanDir(hWnd, path))
+        if (!FD31_ScanDir(lfs->ofnW, hWnd, path))
         {
             return FALSE;
         }
@@ -531,7 +529,7 @@ static LRESULT FD31_Validate( const FD31_DATA *lfs, LPCWSTR path, UINT control,
     FD31_UpdateFileTitle(lfs);
     if (lfs->hook)
     {
-        lRet = (BOOL)FD31_CallWindowProc(lfs, lfs->fileokstring,
+        lRet = FD31_CallWindowProc(lfs, lfs->fileokstring,
                   0, lfs->lParam );
         if (lRet)
         {
@@ -543,7 +541,7 @@ static LRESULT FD31_Validate( const FD31_DATA *lfs, LPCWSTR path, UINT control,
     {
         if (ofnW->lpstrFile)
         {
-            LPWSTR str = (LPWSTR)ofnW->lpstrFile;
+            LPWSTR str = ofnW->lpstrFile;
             LPWSTR ptr = strrchrW(str, '\\');
            str[lstrlenW(str) + 1] = '\0';
            *ptr = 0;
@@ -590,7 +588,6 @@ static LRESULT FD31_FileTypeChange( const FD31_DATA *lfs )
         return TRUE;
     pstr = (LPWSTR)SendDlgItemMessageW(lfs->hwnd, cmb1, CB_GETITEMDATA, lRet, 0);
     TRACE("Selected filter : %s\n", debugstr_w(pstr));
-    SetDlgItemTextW( lfs->hwnd, edt1, pstr );
 
     return FD31_Validate( lfs, NULL, cmb1, lRet, TRUE );
 }
@@ -871,11 +868,19 @@ LONG FD31_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
   if (ofn->nFilterIndex == 0 && ofn->lpstrCustomFilter == NULL)
        ofn->nFilterIndex = 1;
   SendDlgItemMessageW(hWnd, cmb1, CB_SETCURSEL, ofn->nFilterIndex - 1, 0);
-  lstrcpynW(tmpstr, FD31_GetFileType(ofn->lpstrCustomFilter,
+  if (ofn->lpstrFile && ofn->lpstrFile[0])
+  {
+    TRACE( "SetText of edt1 to %s\n", debugstr_w(ofn->lpstrFile) );
+    SetDlgItemTextW( hWnd, edt1, ofn->lpstrFile );
+  }
+  else
+  {
+    lstrcpynW(tmpstr, FD31_GetFileType(ofn->lpstrCustomFilter,
             ofn->lpstrFilter, ofn->nFilterIndex - 1),BUFFILE);
-  TRACE("nFilterIndex = %d, SetText of edt1 to %s\n",
+    TRACE("nFilterIndex = %d, SetText of edt1 to %s\n",
                        ofn->nFilterIndex, debugstr_w(tmpstr));
-  SetDlgItemTextW( hWnd, edt1, tmpstr );
+    SetDlgItemTextW( hWnd, edt1, tmpstr );
+  }
   /* get drive list */
   *tmpstr = 0;
   DlgDirListComboBoxW(hWnd, tmpstr, cmb2, 0, DDL_DRIVES | DDL_EXCLUSIVE);
@@ -896,9 +901,9 @@ LONG FD31_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
     }
   else
     *tmpstr = 0;
-  if (!FD31_ScanDir(hWnd, tmpstr)) {
+  if (!FD31_ScanDir(ofn, hWnd, tmpstr)) {
     *tmpstr = 0;
-    if (!FD31_ScanDir(hWnd, tmpstr))
+    if (!FD31_ScanDir(ofn, hWnd, tmpstr))
       WARN("Couldn't read initial directory %s!\n", debugstr_w(tmpstr));
   }
   /* select current drive in combo 2, omit missing drives */
@@ -919,7 +924,7 @@ LONG FD31_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
   if (ofn->Flags & OFN_HIDEREADONLY)
     ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
   if (lfs->hook)
-      return (BOOL) FD31_CallWindowProc(lfs, WM_INITDIALOG, wParam, lfs->lParam);
+      return FD31_CallWindowProc(lfs, WM_INITDIALOG, wParam, lfs->lParam);
   return TRUE;
 }
 
index 55ef65b..2015a49 100644 (file)
@@ -117,11 +117,11 @@ static void COMDLG32_DumpSBSPFlags(UINT uflags)
             FE(SBSP_INITIATEDBYHLINKFRAME),
         };
 #undef FE
-        DPRINTF("SBSP Flags: %08x =", uflags);
+        TRACE("SBSP Flags: %08x =", uflags);
        for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
            if (flags[i].mask & uflags)
-               DPRINTF("%s ", flags[i].name);
-       DPRINTF("\n");
+               TRACE("%s ", flags[i].name);
+       TRACE("\n");
     }
 }
 
@@ -375,8 +375,7 @@ static HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
            return hRes;
         }
         /* create an absolute pidl */
-        pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent,
-                                                        (LPCITEMIDLIST)pidl);
+        pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent, pidl);
     }
     else if(wFlags & SBSP_PARENT)
     {
@@ -388,7 +387,7 @@ static HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
     else /* SBSP_ABSOLUTE is 0x0000 */
     {
         /* An absolute pidl (relative from the desktop) */
-        pidlTmp =  COMDLG32_PIDL_ILClone((LPCITEMIDLIST)pidl);
+        pidlTmp =  COMDLG32_PIDL_ILClone(pidl);
         psfTmp = GetShellFolderFromPidl(pidlTmp);
     }
 
index 5485804..353da90 100644 (file)
@@ -382,7 +382,7 @@ static HWND COMDLG32_FR_DoFindReplace(
                HRSRC htemplate;
                if(pdata->fr.Flags & FR_ENABLETEMPLATE)
                {
-                       hmod = (HMODULE)pdata->fr.hInstance;
+                       hmod = pdata->fr.hInstance;
                         if(pdata->fr.Flags & FR_WINE_UNICODE)
                         {
                                htemplate = FindResourceW(hmod, (LPCWSTR)pdata->fr.lpTemplateName, (LPWSTR)RT_DIALOG);
index 4afb222..f25d17d 100644 (file)
@@ -223,7 +223,7 @@ BOOL WINAPI ChooseFontW(LPCHOOSEFONTW lpChFont)
 /***********************************************************************
  *           ChooseFontA   (COMDLG32.@)
  *
- * See ChosseFontW.
+ * See ChooseFontW.
  */
 BOOL WINAPI ChooseFontA(LPCHOOSEFONTA lpChFont)
 {
index 39ac750..95f4dac 100644 (file)
@@ -2340,6 +2340,7 @@ typedef struct {
 typedef struct {
     LPPAGESETUPDLGW    dlga;
     PRINTDLGW          pdlg;
+    PAGESETUPDLGW      curdlg; /* Current dialog state */
 } PageSetupDataW;
 
 
@@ -2683,6 +2684,46 @@ PRINTDLG_PS_ChangePrinterA(HWND hDlg, PageSetupDataA *pda) {
     return TRUE;
 }
 
+static void PRINTDLG_PS_SetOrientationW(HWND hDlg, PageSetupDataW* pda)
+{
+    WCHAR PaperName[64];
+
+    GetDlgItemTextW(hDlg, cmb2, PaperName, sizeof(PaperName)/sizeof(WCHAR));
+    PRINTDLG_PaperSizeW(&pda->pdlg, PaperName, &pda->curdlg.ptPaperSize);
+    pda->curdlg.ptPaperSize.x = _c_10mm2size((LPPAGESETUPDLGA)pda->dlga, pda->curdlg.ptPaperSize.x);
+    pda->curdlg.ptPaperSize.y = _c_10mm2size((LPPAGESETUPDLGA)pda->dlga, pda->curdlg.ptPaperSize.y);
+
+    if(IsDlgButtonChecked(hDlg, rad2))
+    {
+        DWORD tmp = pda->curdlg.ptPaperSize.x;
+        pda->curdlg.ptPaperSize.x = pda->curdlg.ptPaperSize.y;
+        pda->curdlg.ptPaperSize.y = tmp;
+    }
+}
+
+static void PRINTDLG_PS_UpdatePrintDlgW(PageSetupDataW* pda, HWND hDlg)
+{
+    DEVMODEW* dm;
+    DWORD sel;
+
+    dm = GlobalLock(pda->pdlg.hDevMode);
+
+    if(!dm)
+        return;
+
+    if(pda->curdlg.ptPaperSize.y > pda->curdlg.ptPaperSize.x)
+        dm->u1.s1.dmOrientation = DMORIENT_PORTRAIT;
+    else
+        dm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE;
+
+    sel = SendDlgItemMessageW(hDlg, cmb2, CB_GETCURSEL, 0, 0);
+
+    if(sel != CB_ERR)
+        dm->u1.s1.dmPaperSize = SendDlgItemMessageW(hDlg, cmb2, CB_GETITEMDATA, sel, 0);
+
+    GlobalUnlock(pda->pdlg.hDevMode);
+}
+
 static BOOL
 PRINTDLG_PS_ChangePrinterW(HWND hDlg, PageSetupDataW *pda) {
     DEVNAMES   *dn;
@@ -2695,8 +2736,18 @@ PRINTDLG_PS_ChangePrinterW(HWND hDlg, PageSetupDataW *pda) {
     portname   = ((WCHAR*)dn)+dn->wOutputOffset;
     PRINTDLG_SetUpPaperComboBoxW(hDlg,cmb2,devname,portname,dm);
     PRINTDLG_SetUpPaperComboBoxW(hDlg,cmb3,devname,portname,dm);
+
+    /* Landscape orientation */
+    if (dm->u1.s1.dmOrientation == DMORIENT_LANDSCAPE)
+        CheckRadioButton(hDlg, rad1, rad2, rad2);
+    else /* this is default if papersize is not set */
+        CheckRadioButton(hDlg, rad1, rad2, rad1);
+
     GlobalUnlock(pda->pdlg.hDevNames);
     GlobalUnlock(pda->pdlg.hDevMode);
+
+    PRINTDLG_PS_SetOrientationW(hDlg, pda);
+
     return TRUE;
 }
 
@@ -2791,21 +2842,30 @@ PRINTDLG_PS_WMCommandA(
         }
        return TRUE;
     case rad1:
-           if (pda->curdlg.ptPaperSize.x > pda->curdlg.ptPaperSize.y){
-               DWORD tmp = pda->curdlg.ptPaperSize.x;
-               pda->curdlg.ptPaperSize.x = pda->curdlg.ptPaperSize.y;
-               pda->curdlg.ptPaperSize.y = tmp;
-           }
-           PRINTDLG_PS_ChangePaperPrev(pda);
-       break;
     case rad2:
-           if (pda->curdlg.ptPaperSize.y > pda->curdlg.ptPaperSize.x){
-               DWORD tmp = pda->curdlg.ptPaperSize.x;
-               pda->curdlg.ptPaperSize.x = pda->curdlg.ptPaperSize.y;
-               pda->curdlg.ptPaperSize.y = tmp;
-           }
+       if((id == rad1 && pda->curdlg.ptPaperSize.x > pda->curdlg.ptPaperSize.y) ||
+          (id == rad2 && pda->curdlg.ptPaperSize.y > pda->curdlg.ptPaperSize.x))
+       {
+           char TmpText[25];
+           char TmpText2[25];
+           DWORD tmp = pda->curdlg.ptPaperSize.x;
+
+           pda->curdlg.ptPaperSize.x = pda->curdlg.ptPaperSize.y;
+           pda->curdlg.ptPaperSize.y = tmp;
+
+           GetDlgItemTextA(hDlg, edt4, TmpText, sizeof(TmpText));
+           GetDlgItemTextA(hDlg, edt5, TmpText2, sizeof(TmpText2));
+           SetDlgItemTextA(hDlg, edt5, TmpText);
+           SetDlgItemTextA(hDlg, edt4, TmpText2);
+
+           GetDlgItemTextA(hDlg, edt6, TmpText, sizeof(TmpText));
+           GetDlgItemTextA(hDlg, edt7, TmpText2, sizeof(TmpText2));
+           SetDlgItemTextA(hDlg, edt7, TmpText);
+           SetDlgItemTextA(hDlg, edt6, TmpText2);
+
            PRINTDLG_PS_ChangePaperPrev(pda);
-           break;
+       }
+       break;
     case cmb1: /* Printer combo */
            if(msg == CBN_SELCHANGE){
                char crPrinterName[256];
@@ -2890,10 +2950,10 @@ PRINTDLG_PS_WMCommandA(
        GETVAL(id, pda->curdlg.rtMargin.left);
        break;
     case edt5:
-       GETVAL(id, pda->curdlg.rtMargin.right);
+       GETVAL(id, pda->curdlg.rtMargin.top);
        break;
     case edt6:
-       GETVAL(id, pda->curdlg.rtMargin.top);
+       GETVAL(id, pda->curdlg.rtMargin.right);
        break;
     case edt7:
        GETVAL(id, pda->curdlg.rtMargin.bottom);
@@ -2921,9 +2981,34 @@ PRINTDLG_PS_WMCommandW(
         EndDialog(hDlg, FALSE);
        return FALSE ;
 
+    case rad1:
+    case rad2:
+       if((LOWORD(wParam) == rad1 && pda->curdlg.ptPaperSize.x > pda->curdlg.ptPaperSize.y) ||
+          (LOWORD(wParam) == rad2 && pda->curdlg.ptPaperSize.y > pda->curdlg.ptPaperSize.x))
+       {
+           WCHAR tmpText[25];
+           WCHAR tmpText2[25];
+           DWORD tmp = pda->curdlg.ptPaperSize.y;
+
+           pda->curdlg.ptPaperSize.y = pda->curdlg.ptPaperSize.x;
+           pda->curdlg.ptPaperSize.x = tmp;
+
+           GetDlgItemTextW(hDlg, edt4, tmpText, sizeof(tmpText)/sizeof(WCHAR));
+           GetDlgItemTextW(hDlg, edt5, tmpText2, sizeof(tmpText2)/sizeof(WCHAR));
+           SetDlgItemTextW(hDlg, edt5, tmpText);
+           SetDlgItemTextW(hDlg, edt4, tmpText2);
+
+           GetDlgItemTextW(hDlg, edt6, tmpText, sizeof(tmpText)/sizeof(WCHAR));
+           GetDlgItemTextW(hDlg, edt7, tmpText2, sizeof(tmpText2)/sizeof(WCHAR));
+           SetDlgItemTextW(hDlg, edt7, tmpText);
+           SetDlgItemTextW(hDlg, edt6, tmpText2);
+       }
+       break;
+
     case psh3: {
        pda->pdlg.Flags         = 0;
        pda->pdlg.hwndOwner     = hDlg;
+        PRINTDLG_PS_UpdatePrintDlgW(pda, hDlg);
        if (PrintDlgW(&(pda->pdlg)))
            PRINTDLG_PS_ChangePrinterW(hDlg,pda);
        return TRUE;
@@ -3069,12 +3154,12 @@ PRINTDLG_PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     scalx = rcClient.right  / (double)pda->curdlg.ptPaperSize.x;
     scaly = rcClient.bottom / (double)pda->curdlg.ptPaperSize.y; 
     rcMargin = rcClient;
-    rcMargin.left   += (LONG)pda->curdlg.rtMargin.left   * scalx;
-    rcMargin.top    += (LONG)pda->curdlg.rtMargin.top    * scalx;
-    rcMargin.right  -= (LONG)pda->curdlg.rtMargin.right  * scaly;
-    rcMargin.bottom -= (LONG)pda->curdlg.rtMargin.bottom * scaly;
-    
+
+    rcMargin.left   += pda->curdlg.rtMargin.left   * scalx;
+    rcMargin.top    += pda->curdlg.rtMargin.top    * scalx;
+    rcMargin.right  -= pda->curdlg.rtMargin.right  * scaly;
+    rcMargin.bottom -= pda->curdlg.rtMargin.bottom * scaly;
+
     /* if the space is too small then we make sure to not draw anything */
     rcMargin.left = min(rcMargin.left, rcMargin.right);
     rcMargin.top = min(rcMargin.top, rcMargin.bottom);
@@ -3268,12 +3353,12 @@ PageDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
        { '_', '_', 'W', 'I', 'N', 'E', '_', 'P', 'A', 'G', 'E', 
          'S', 'E', 'T', 'U', 'P', 'D', 'L', 'G', 'D', 'A', 'T', 'A', 0 };
     PageSetupDataW     *pda;
-    LPDEVMODEW          dm;
     BOOL               res = FALSE;
 
     if (uMsg==WM_INITDIALOG) {
        res = TRUE;
         pda = (PageSetupDataW*)lParam;
+       memcpy(&pda->curdlg, pda, sizeof(pda->curdlg));
        SetPropW(hDlg, __WINE_PAGESETUPDLGDATA, pda);
        if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) {
            res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,(LPARAM)pda->dlga);
@@ -3295,16 +3380,7 @@ PageDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
             EnableWindow(GetDlgItem(hDlg, edt7), FALSE);
        }
 
-        if(pda->dlga->hDevMode)
-        {
-            dm = GlobalLock(pda->dlga->hDevMode);
-            /* Landscape orientation */
-            if (dm->u1.s1.dmOrientation == DMORIENT_LANDSCAPE)
-                CheckRadioButton(hDlg, rad1, rad2, rad2);
-            else /* this is default if papersize is not set */
-                CheckRadioButton(hDlg, rad1, rad2, rad1);
-            GlobalUnlock(pda->dlga->hDevMode);
-        }
+        PRINTDLG_PS_ChangePrinterW(hDlg,pda);
 
        if (pda->dlga->Flags & PSD_DISABLEORIENTATION) {
            EnableWindow(GetDlgItem(hDlg,rad1),FALSE);
@@ -3331,7 +3407,7 @@ PageDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
            SetDlgItemTextW(hDlg,edt6,str);
            SetDlgItemTextW(hDlg,edt7,str);
        }
-       PRINTDLG_PS_ChangePrinterW(hDlg,pda);
+
        if (pda->dlga->Flags & PSD_DISABLEPAPER) {
            EnableWindow(GetDlgItem(hDlg,cmb2),FALSE);
            EnableWindow(GetDlgItem(hDlg,cmb3),FALSE);