Fix for ArrangeCtrlPositions in commdlg

Maxime Bellengé maxime.bellenge at laposte.net
Wed Mar 12 16:54:55 CST 2003


This patch replaces my previous patches.
It fixes the computation of the file dialog box size and the component
placement.

Now WinHex open dialog box looks fine as well as VirtualDub, Winzip.

The new algorithm is partially based on information found at
http://www.bridgespublishing.com/articles/issues/0201/Custom_Open_dialogs__part_II.htm

ChangeLog:
- Fix how the size of the dialog is computed and the child component
placed.

-- 
Maxime Bellengé <maxime.bellenge at laposte.net>

PS : I don't manage to stop line wrapping , so I attach the patch and
put an inline version.


Index: dlls/commdlg/filedlg95.c
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/filedlg95.c,v
retrieving revision 1.90
diff -u -r1.90 filedlg95.c
--- dlls/commdlg/filedlg95.c	7 Mar 2003 20:29:31 -0000	1.90
+++ dlls/commdlg/filedlg95.c	12 Mar 2003 22:40:58 -0000
@@ -520,49 +520,32 @@
     {
       GetWindowRect(hwndStc32,&rectStc32);
       MapWindowPoints(0, hwndChildDlg,(LPPOINT)&rectStc32,2);
-      CopyRect(&rectTemp,&rectStc32);
+      CopyRect(&rectTemp,&rectStc32);      
 
-      SetRect(&rectStc32,rectStc32.left,rectStc32.top,rectStc32.left +
(rectParent.right-rectParent.left),rectStc32.top+(rectParent.bottom-rectParent.top));
-     
SetWindowPos(hwndStc32,0,rectStc32.left,rectStc32.top,rectStc32.right-rectStc32.left,rectStc32.bottom-rectStc32.top,SWP_NOMOVE|SWP_NOZORDER | SWP_NOACTIVATE);
-
-      ptParentClient.x =
max((rectParent.right-rectParent.left),(rectChild.right-rectChild.left));
-      if(rectStc32.right < rectTemp.right)
-        ptMoveCtl.x = 0;
-      else
-        ptMoveCtl.x = (rectStc32.right - rectTemp.right);
-
-      ptParentClient.y =
max((rectParent.bottom-rectParent.top),(rectChild.bottom-rectChild.top));
-      if(rectStc32.bottom < rectTemp.bottom)
-        ptMoveCtl.y = 0;
-      else
-        ptMoveCtl.y = (rectStc32.bottom - rectTemp.bottom);
+      ptParentClient.x =
(rectParent.right-rectParent.left)+(rectChild.right-rectChild.left)-(rectStc32.right-rectStc32.left);
+      ptMoveCtl.x = (rectParent.right-rectParent.left) ;
+  
+      ptParentClient.y =
(rectParent.bottom-rectParent.top)+(rectChild.bottom-rectChild.top)-(rectStc32.bottom-rectStc32.top) ;
+      ptMoveCtl.y = (rectParent.bottom-rectParent.top) ;
     }
     else
     {
-      if( (GetWindow(hwndChildDlg,GW_CHILD)) == NULL) return;
-
       SetRectEmpty(&rectTemp);
       ptParentClient.x =
max((rectParent.right-rectParent.left),(rectChild.right-rectChild.left));
       ptParentClient.y = (rectParent.bottom-rectParent.top) +
(rectChild.bottom-rectChild.top);
       ptMoveCtl.y = rectParent.bottom-rectParent.top;
-      ptMoveCtl.x=0;
+      ptMoveCtl.x = rectParent.right - rectParent.left;
+      SetRect(&rectTemp,0,0,ptParentClient.x,ptMoveCtl.y);
     }
    
SetRect(&rectParent,rectParent.left,rectParent.top,rectParent.left+ptParentClient.x,rectParent.top+ptParentClient.y);
     AdjustWindowRectEx(
&rectParent,GetWindowLongA(hwndParentDlg,GWL_STYLE),FALSE,GetWindowLongA(hwndParentDlg,GWL_EXSTYLE));
 
-    SetWindowPos(hwndChildDlg, 0, 0,0, ptParentClient.x +
ptMoveCtl.x,ptParentClient.y + ptMoveCtl.y, SWP_NOZORDER );
-    SetWindowPos(hwndParentDlg, 0, rectParent.left,rectParent.top,
(rectParent.right- rectParent.left) + ptMoveCtl.x,
-        (rectParent.bottom-rectParent.top) + ptMoveCtl.y,SWP_NOMOVE |
SWP_NOZORDER);
+    SetWindowPos(hwndChildDlg, 0, 0,0,
ptParentClient.x,ptParentClient.y, SWP_NOZORDER );
+    SetWindowPos(hwndParentDlg, 0, rectParent.left,rectParent.top,
(rectParent.right- rectParent.left),
+		 (rectParent.bottom-rectParent.top),SWP_NOMOVE | SWP_NOZORDER);
 
     hwndChild = GetWindow(hwndChildDlg,GW_CHILD);
-    if(hwndStc32)
-    {
-      GetWindowRect(hwndStc32,&rectStc32);
-      MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2);
-    }
-    else
-      SetRect(&rectStc32,0,0,0,0);
-
+  
     if (hwndChild )
     {
       do
@@ -578,22 +561,15 @@
             Check the initial position of the controls relative to the
initial
             position and size of stc32 (before it is expanded).
           */
-          if (rectCtrl.left >= rectTemp.right && rectCtrl.top >=
rectTemp.bottom)
-          {
-            rectCtrl.left += ptMoveCtl.x;
-            rectCtrl.top  += ptMoveCtl.y;
-          }
-          else if (rectCtrl.left >= rectTemp.right)
-	  {
-            rectCtrl.left += ptMoveCtl.x;
-            rectCtrl.right += ptMoveCtl.x;
+   	  if ((rectCtrl.left >= rectTemp.right) &&
((rectCtrl.left+ptMoveCtl.x)<rectParent.right)){
+	    rectCtrl.left += ptMoveCtl.x;
+	    rectCtrl.right +=ptMoveCtl.x; 
 	  }
-          else if (rectCtrl.top >= rectTemp.bottom)
-          {
+	  if ((rectCtrl.top > rectTemp.bottom) &&
((rectCtrl.top+ptMoveCtl.y)<rectParent.bottom)){
 	    rectCtrl.top  += ptMoveCtl.y;
-           rectCtrl.bottom  += ptMoveCtl.y;
+	    rectCtrl.bottom  += ptMoveCtl.y;
 	  }
-
+    
           SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top,
 				rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
 				SWP_NOSIZE | SWP_NOZORDER );
@@ -616,7 +592,7 @@
           {
             if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE)
               continue;
-            GetWindowRect(hwndChild,&rectCtrl);
+	    GetWindowRect(hwndChild,&rectCtrl);
             MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2);
 
             rectCtrl.left += ptMoveCtl.x;
@@ -684,7 +660,6 @@
         fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATEHANDLE)
     {
       HINSTANCE hinst;
-
       if (fodInfos->ofnInfos->Flags  & OFN_ENABLETEMPLATEHANDLE)
       {
         hinst = 0;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: filedlg95.patch
Type: text/x-patch
Size: 5079 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20030312/ed1dbb0d/filedlg95.bin


More information about the wine-patches mailing list