Lei Zhang : comdlg32: Move file dialog resizing code into its own function.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Jun 14 07:47:05 CDT 2007


Module: wine
Branch: master
Commit: eef9e1ab882fe1f74f84c23b1d4a68b34b65d7fe
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=eef9e1ab882fe1f74f84c23b1d4a68b34b65d7fe

Author: Lei Zhang <thestig at google.com>
Date:   Thu Jun 14 01:29:16 2007 -0700

comdlg32: Move file dialog resizing code into its own function.

---

 dlls/comdlg32/filedlg.c |   99 +++++++++++++++++++++++++++--------------------
 1 files changed, 57 insertions(+), 42 deletions(-)

diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c
index 11c4502..e8e82f2 100644
--- a/dlls/comdlg32/filedlg.c
+++ b/dlls/comdlg32/filedlg.c
@@ -181,6 +181,7 @@ static const char LookInInfosStr[] = "LookInInfos"; /* LOOKIN combo box property
  */
 
 /* Internal functions used by the dialog */
+static LRESULT FILEDLG95_ResizeControls(HWND hwnd, WPARAM wParam, LPARAM lParam);
 static LRESULT FILEDLG95_FillControls(HWND hwnd, WPARAM wParam, LPARAM lParam);
 static LRESULT FILEDLG95_OnWMCommand(HWND hwnd, WPARAM wParam, LPARAM lParam);
 static LRESULT FILEDLG95_OnWMGetIShellBrowser(HWND hwnd);
@@ -1042,30 +1043,7 @@ INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
       	 fodInfos->DlgInfos.hwndCustomDlg =
      	   CreateTemplateDialog((FileOpenDlgInfos *)lParam, hwnd);
 
-         if (fodInfos->DlgInfos.hwndCustomDlg)
-         {
-             RECT rc;
-             UINT flags = SWP_NOACTIVATE;
-
-             ArrangeCtrlPositions(fodInfos->DlgInfos.hwndCustomDlg, hwnd,
-                 (fodInfos->ofnInfos->Flags & (OFN_HIDEREADONLY | OFN_SHOWHELP)) == OFN_HIDEREADONLY);
-
-             /* resize the custom dialog to the parent size */
-             if (fodInfos->ofnInfos->Flags & (OFN_ENABLETEMPLATE | OFN_ENABLETEMPLATEHANDLE))
-                 GetClientRect(hwnd, &rc);
-             else
-             {
-                 /* our own fake template is zero sized and doesn't have
-                  * children, so there is no need to resize it.
-                  * Picasa depends on it.
-                  */
-                 flags |= SWP_NOSIZE;
-                 SetRectEmpty(&rc);
-             }
-             SetWindowPos(fodInfos->DlgInfos.hwndCustomDlg, HWND_BOTTOM,
-                          0, 0, rc.right, rc.bottom, flags);
-         }
-
+         FILEDLG95_ResizeControls(hwnd, wParam, lParam);
       	 FILEDLG95_FillControls(hwnd, wParam, lParam);
 
          SendCustomDlgNotificationMessage(hwnd,CDN_INITDONE);
@@ -1440,24 +1418,6 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
     EnableWindow(GetDlgItem(hwnd, pshHelp), FALSE);
   }
 
-  /* Resize the height, if open as read only checkbox ad help button
-     are hidden and we are not using a custom template nor a customDialog
-     */
-  if ( (fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY) &&
-       (!(fodInfos->ofnInfos->Flags &
-         (OFN_SHOWHELP|OFN_ENABLETEMPLATE|OFN_ENABLETEMPLATEHANDLE))) && 
-       (!fodInfos->DlgInfos.hwndCustomDlg ))
-  {
-    RECT rectDlg, rectHelp, rectCancel;
-    GetWindowRect(hwnd, &rectDlg);
-    GetWindowRect(GetDlgItem(hwnd, pshHelp), &rectHelp);
-    GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rectCancel);
-    /* subtract the height of the help button plus the space between
-       the help button and the cancel button to the height of the dialog */
-    SetWindowPos(hwnd, 0, 0, 0, rectDlg.right-rectDlg.left,
-                 (rectDlg.bottom-rectDlg.top) - (rectHelp.bottom - rectCancel.bottom),
-                 SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
-  }
   /* change Open to Save */
   if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
   {
@@ -1471,6 +1431,61 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
 }
 
 /***********************************************************************
+ *      FILEDLG95_ResizeControls
+ *
+ * WM_INITDIALOG message handler (after hook notification)
+ */
+static LRESULT FILEDLG95_ResizeControls(HWND hwnd, WPARAM wParam, LPARAM lParam)
+{
+  FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) lParam;
+
+  if (fodInfos->DlgInfos.hwndCustomDlg)
+  {
+    RECT rc;
+    UINT flags = SWP_NOACTIVATE;
+
+    ArrangeCtrlPositions(fodInfos->DlgInfos.hwndCustomDlg, hwnd,
+        (fodInfos->ofnInfos->Flags & (OFN_HIDEREADONLY | OFN_SHOWHELP)) == OFN_HIDEREADONLY);
+
+    /* resize the custom dialog to the parent size */
+    if (fodInfos->ofnInfos->Flags & (OFN_ENABLETEMPLATE | OFN_ENABLETEMPLATEHANDLE))
+      GetClientRect(hwnd, &rc);
+    else
+    {
+      /* our own fake template is zero sized and doesn't have children, so
+       * there is no need to resize it. Picasa depends on it.
+       */
+      flags |= SWP_NOSIZE;
+      SetRectEmpty(&rc);
+    }
+      SetWindowPos(fodInfos->DlgInfos.hwndCustomDlg, HWND_BOTTOM,
+          0, 0, rc.right, rc.bottom, flags);
+  }
+  else
+  {
+    /* Resize the height, if open as read only checkbox ad help button are
+     * hidden and we are not using a custom template nor a customDialog
+     */
+    if ( (fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY) &&
+                (!(fodInfos->ofnInfos->Flags &
+                   (OFN_SHOWHELP|OFN_ENABLETEMPLATE|OFN_ENABLETEMPLATEHANDLE))))
+    {
+      RECT rectDlg, rectHelp, rectCancel;
+      GetWindowRect(hwnd, &rectDlg);
+      GetWindowRect(GetDlgItem(hwnd, pshHelp), &rectHelp);
+      GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rectCancel);
+      /* subtract the height of the help button plus the space between the help
+       * button and the cancel button to the height of the dialog
+       */
+      SetWindowPos(hwnd, 0, 0, 0, rectDlg.right-rectDlg.left,
+          (rectDlg.bottom-rectDlg.top) - (rectHelp.bottom - rectCancel.bottom),
+          SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
+    }
+  }
+  return TRUE;
+}
+
+/***********************************************************************
  *      FILEDLG95_FillControls
  *
  * WM_INITDIALOG message handler (after hook notification)




More information about the wine-cvs mailing list