time this method is called,
+we basically grab the size of the page, but calculate the top/left coords
+ourselves.
+ */
+
+ if (!psd.gotPage)
+{
+ psd.gotPage = true;
+
+ RECTWrapper pageRect = psd.pageRect;
+ ::GetWindowRect (page, pageRect);
+ // We want client coords.
+ ::ScreenToClient (page, (LPPOINT)pageRect.left);
+ ::ScreenToClient (page, (LPPOINT)pageRect.right);
+
+ LONG dialogBaseUnits = ::GetDialogBaseUnits ();
+ // The margins in DUs are a result of educated guesses and TE.
+ int marginX = MulDiv (5, LOWORD(dialogBaseUnits), 4);
+ int marginY = MulDiv (5, HIWORD(dialogBaseUnits), 8);
+
+ pageRect.move (marginX, marginY);
+}
+
+ SetWindowPos (page, 0, psd.pageRect.left, psd.pageRect.top,
+psd.pageRect.width (), psd.pageRect.height (),
+SWP_NOACTIVATE | SWP_NOZORDER);
}
void
--- /dev/null 2003-10-26 12:36:02.62800 +0100
+++ ControlAdjuster.cc 2003-10-16 22:39:39.68400 +0200
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2003, Frank Richter [EMAIL PROTECTED]
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * A copy of the GNU General Public License can be found at
+ * http://www.gnu.org/
+ *
+ * Written by Frank Richter.
+ *
+ */
+
+#include ControlAdjuster.h
+#include RECTWrapper.h
+
+void ControlAdjuster::AdjustControls (HWND dlg,
+ const ControlInfo controlInfo[],
+ int widthChange, int heightChange)
+{
+ const ControlInfo* ci = controlInfo;
+
+ while (ci-control 0)
+ {
+HWND ctl = GetDlgItem (dlg, ci-control);
+if (ctl != 0)
+{
+ RECTWrapper ctlRect;
+ GetWindowRect (ctl, ctlRect);
+ // We want client coords.
+ ScreenToClient (dlg, (LPPOINT)ctlRect.left);
+ ScreenToClient (dlg, (LPPOINT)ctlRect.right);
+
+ /*
+Now adjust the rectangle.
+ If an anchor is set, the resp. edge is 'sticky' with respect to the
+ opposite border.
+ */
+ if (!ci-anchorLeft)
+ctlRect.left += widthChange;
+ if (!ci-anchorTop)
+ctlRect.top += heightChange;
+ if (ci-anchorRight)
+ctlRect.right += widthChange;
+ if (ci-anchorBottom)
+ctlRect.bottom += heightChange;
+
+ SetWindowPos (ctl, 0, ctlRect.left, ctlRect.top,
+ ctlRect.width (), ctlRect.height (), SWP_NOACTIVATE | SWP_NOZORDER);
+ // If not done, weird visual glitches can occur.
+ InvalidateRect (ctl, 0, false);
+
+}
+ci++;
+ }
+}
+
+SizeProcessor::SizeProcessor ()
+{
+ rectValid = false;
+}
+
+void SizeProcessor::AddControlInfo (
+ const ControlAdjuster::ControlInfo* controlInfo)
+{
+ controlInfos.push_back (controlInfo);
+}
+
+void SizeProcessor::UpdateSize (HWND dlg)
+{
+ RECTWrapper clientRect;
+ ::GetClientRect (dlg, clientRect);
+
+ if (rectValid)
+{
+ const int dX = clientRect.width () - lastRect.width ();
+ const int dY = clientRect.height () - lastRect.height ();
+
+ for (size_t i = 0; i controlInfos.size (); i++)
+ ControlAdjuster::AdjustControls (dlg, controlInfos[i], dX, dY);
+}
+ else
+rectValid = true;
+
+ lastRect = clientRect;
+}
--- /dev/null 2003-10-26 12:36:42.14400 +0100
+++ ControlAdjuster.h 2003-10-16 17:11:44.538125000 +0200
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2003, Frank Richter [EMAIL PROTECTED]
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * A copy of the GNU General Public License can be found at
+ * http://www.gnu.org/
+ *
+ * Written by Frank Richter.
+ *
+ */
+
+#ifndef SETUP_CONTROLADJUSTER_H
+#define SETUP_CONTROLADJUSTER_H
+
+#include vector
+
+#include windows.h
+#include RECTWrapper.h
+
+/*
+ This is a helper class to move/resize controls of a dialog when it's size
+ is changed. It's no fancy layouting stuff, but rather just moving them
+ around - to, for example, keep controls at the bottom really at the bottom
+ when the size changes.
+ */
+
+class ControlAdjuster
+{
+public:
+ struct ControlInfo
+ {
+// Control ID
+int control;
+/*
+ Anchors. Basically, says which edge should be sticky.
+ */
+bool anchorLeft;
+bool anchorTop;
+bool anchorRight;
+bool anchorBottom;
+ };
+
+ /*
+Adjust all the controls.
+'controlInfo' an array with the moving information.
+The terminating item of the array should have an ID = 0.
+ */
+ static void AdjustControls (HWND dlg, const ControlInfo