comdlg32: move file dialog resizing code into its own function
Lei Zhang
thestig at google.com
Thu Jun 14 03:34:37 CDT 2007
Hi,
After commit 13f18ee7593364a2a685fed2bdfa814431906f0c,
FILEDLG95_InitControls() is accessing fodInfos->DlgInfos.hwndCustomDlg
before it can be initialized. This patch moves the window resizing
code from FILEDLG95_InitControls() and from FileOpenDlgProc95() into
an internal function that we call after
fodInfos->DlgInfos.hwndCustomDlg has been initialized.
-------------- next part --------------
From 14fb289f3654d6c19ad78d5070bdd373db740646 Mon Sep 17 00:00:00 2001
From: Lei Zhang <thestig at google.com>
Date: Thu, 14 Jun 2007 01:29:16 -0700
Subject: [PATCH] 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[] = "Lo
*/
/* 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 @@ #endif
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(HW
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(HW
}
/***********************************************************************
+ * 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)
--
1.4.2.1
More information about the wine-patches
mailing list