Index: AntiVirus.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/AntiVirus.cc,v
retrieving revision 2.3
diff -p -u -b -r2.3 AntiVirus.cc
--- AntiVirus.cc	25 Nov 2002 22:12:07 -0000	2.3
+++ AntiVirus.cc	2 Feb 2003 10:42:38 -0000
@@ -87,9 +87,16 @@ AntiVirusPage::Create ()
     return PropertyPage::Create (NULL, dialog_cmd, IDD_VIRUS);
 }
 
-void
+long
 AntiVirusPage::OnActivate ()
 {
+  // First check if there's an antivirus scanner to be disabled.
+  if(!KnownAVIsPresent)  // FIXME - Statics to communicate between classes?  Grady's spinning in his grave! ;-)
+  {
+    // Nope, skip this page by "not accepting" activation.
+    return -1;
+  }
+  
   load_dialog (GetHWND ());
   // Check to see if any radio buttons are selected. If not, select a default.
   if ((!SendMessage
@@ -101,7 +108,7 @@ AntiVirusPage::OnActivate ()
       SendMessage (GetDlgItem (IDC_LEAVE_AV), BM_SETCHECK,
 		   BST_CHECKED, 0);
     }
-
+  return 0;
 }
 
 long
@@ -111,7 +118,7 @@ AntiVirusPage::OnNext ()
 
   save_dialog (h);
   /* if disable, do so now */
-  return IDD_SOURCE;
+  return 0;
 }
 
 long
Index: AntiVirus.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/AntiVirus.h,v
retrieving revision 2.1
diff -p -u -b -r2.1 AntiVirus.h
--- AntiVirus.h	25 Nov 2002 00:41:24 -0000	2.1
+++ AntiVirus.h	2 Feb 2003 10:42:38 -0000
@@ -40,7 +40,7 @@ public:
 
   bool Create ();
 
-  virtual void OnActivate ();
+  virtual long OnActivate ();
   virtual void OnDeactivate ();
   virtual long OnNext ();
   virtual long OnBack ();
Index: desktop.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/desktop.cc,v
retrieving revision 2.34
diff -p -u -b -r2.34 desktop.cc
--- desktop.cc	25 Nov 2002 22:12:08 -0000	2.34
+++ desktop.cc	2 Feb 2003 10:42:39 -0000
@@ -380,6 +380,7 @@ DesktopSetupPage::OnInit ()
 
   load_dialog (GetHWND ());
 
+  PropertyPage::OnInit();
 }
 
 long
@@ -387,7 +388,6 @@ DesktopSetupPage::OnBack ()
 {
   HWND h = GetHWND ();
   save_dialog (h);
-  NEXT (IDD_CHOOSE);
   return IDD_CHOOSE;
 }
 
@@ -397,7 +397,6 @@ DesktopSetupPage::OnFinish ()
   HWND h = GetHWND ();
   save_dialog (h);
   do_desktop_setup ();
-  NEXT (IDD_S_POSTINSTALL);
   do_postinstall (GetInstance (), h);
 
   return true;
Index: localdir.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/localdir.cc,v
retrieving revision 2.12
diff -p -u -b -r2.12 localdir.cc
--- localdir.cc	9 Nov 2002 14:47:54 -0000	2.12
+++ localdir.cc	2 Feb 2003 10:42:51 -0000
@@ -174,10 +174,11 @@ LocalDirPage::OnInit ()
     }
 }
 
-void
+long
 LocalDirPage::OnActivate ()
 {
   load_dialog (GetHWND ());
+  return 0;
 }
 
 long
Index: localdir.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/localdir.h,v
retrieving revision 2.3
diff -p -u -b -r2.3 localdir.h
--- localdir.h	21 Sep 2002 09:36:46 -0000	2.3
+++ localdir.h	2 Feb 2003 10:42:51 -0000
@@ -34,7 +34,7 @@ public:
 
   bool Create ();
 
-  virtual void OnActivate ();
+  virtual long OnActivate ();
   virtual void OnInit ();
   virtual long OnNext ();
   virtual long OnBack ();
Index: LogFile.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/LogFile.cc,v
retrieving revision 2.6
diff -p -u -b -r2.6 LogFile.cc
--- LogFile.cc	25 Nov 2002 00:41:24 -0000	2.6
+++ LogFile.cc	2 Feb 2003 10:42:52 -0000
@@ -115,7 +115,18 @@ LogFile::exit (int const exit_code)
   been_here = 1;
   
   if (exit_msg)
+  {
+    // No final dialog box unless there was an error.
+    // FIXME: We really shouldn't be doing any UI stuff here at all.
+    if (exit_msg!=IDS_INSTALL_COMPLETE)
+    {
     note (NULL, exit_msg);
+    }
+    else
+    {
+	  note_nobox(exit_msg);
+    }
+  }
   
   log (LOG_TIMESTAMP) << "Ending cygwin install" << endLog;
 
Index: msg.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/msg.cc,v
retrieving revision 2.7
diff -p -u -b -r2.7 msg.cc
--- msg.cc	27 Jun 2002 11:01:10 -0000	2.7
+++ msg.cc	2 Feb 2003 10:42:52 -0000
@@ -59,6 +59,21 @@ note (HWND owner, int id, ...)
 }
 
 void
+note_nobox (int id, ...)
+{
+  char buf[1000], fmt[1000];
+  
+  va_list args;
+  va_start (args, id);
+
+  if (LoadString (hinstance, id, fmt, sizeof (fmt)) <= 0)
+    ExitProcess (0);
+
+  vsprintf (buf, fmt, args);
+  log (LOG_PLAIN, String ("mbox note: ") + buf);
+}
+
+void
 fatal (HWND owner, int id, ...)
 {
   va_list args;
Index: msg.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/msg.h,v
retrieving revision 2.2
diff -p -u -b -r2.2 msg.h
--- msg.h	23 Dec 2001 12:13:29 -0000	2.2
+++ msg.h	2 Feb 2003 10:42:52 -0000
@@ -31,3 +31,6 @@ void note (HWND owner, int id, ...);
 
 /* returns IDYES or IDNO, otherwise same as note() */
 int yesno (HWND owner, int id, ...);
+
+/* Same as note(), but no message box */
+void note_nobox (int id, ...);
Index: postinstall.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/postinstall.cc,v
retrieving revision 2.9
diff -p -u -b -r2.9 postinstall.cc
--- postinstall.cc	19 May 2002 03:07:51 -0000	2.9
+++ postinstall.cc	2 Feb 2003 10:42:52 -0000
@@ -44,7 +44,6 @@ protected:
 void
 do_postinstall (HINSTANCE h, HWND owner)
 {
-  next_dialog = 0;
   init_run_script ();
   SetCurrentDirectory (get_root_dir ().cstr_oneuse());
   RunFindVisitor myVisitor;
Index: proppage.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/proppage.cc,v
retrieving revision 2.4
diff -p -u -b -r2.4 proppage.cc
--- proppage.cc	21 Sep 2002 09:36:46 -0000	2.4
+++ proppage.cc	2 Feb 2003 10:42:52 -0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, Gary R. Van Sickle.
+ * Copyright (c) 2001, 2002, 2003 Gary R. Van Sickle.
  *
  *     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
@@ -24,8 +24,6 @@
 
 #include "getopt++/BoolOption.h"
 
-bool PropertyPage::DoOnceForSheet = true;
-
 PropertyPage::PropertyPage ()
 {
   proc = NULL;
@@ -49,21 +47,46 @@ bool PropertyPage::Create (DLGPROC dlgpr
 }
 
 bool
-  PropertyPage::Create (DLGPROC dlgproc,
+PropertyPage::Create (DLGPROC dlgproc,
 			BOOL (*cproc) (HWND h, int id, HWND hwndctl,
 				       UINT code), int TemplateID)
 {
+  HGLOBAL h;
+  DLGTEMPLATE* pt;
+  HRSRC hRsrc;
+  
+  hRsrc = FindResource(NULL, MAKEINTRESOURCE(TemplateID), RT_DIALOG);
+  h = LoadResource(NULL, hRsrc);
+  pt = (DLGTEMPLATE*)LockResource(h);
+  assert(pt!=NULL);
+  
+  // Get the original rect specified in the template,
+  // because we need it later in order to resize the sheet.
+  OriginalRECT.left = pt->x;
+  OriginalRECT.top = pt->y;
+  OriginalRECT.right = pt->x + (pt->cx - 1);
+  OriginalRECT.bottom = pt->y + (pt->cy - 1);
+  
+  FreeResource(h);
+  
+  // Another lesson learned the hard way about the freakshow that is Windows.
+  // While we had a perfectly good dialog template loaded up there, for some
+  // godforsaken reason we can't use it to init the PROPSHEETPAGE (via PSP_DLGINDIRECT),
+  // because if we do, the sheet behaves as if it has no idea what the dialog resource
+  // IDs are, so you can't for instance send a message to switch to a particular
+  // page.  Incredible.
   psp.dwSize = sizeof (PROPSHEETPAGE);
   psp.dwFlags = 0;
   psp.hInstance = GetInstance ();
   psp.pfnDlgProc = FirstDialogProcReflector;
-  psp.pszTemplate = (LPCSTR) TemplateID;
+  psp.pszTemplate = MAKEINTRESOURCE(TemplateID);
   psp.lParam = (LPARAM) this;
   psp.pfnCallback = NULL;
 
   proc = dlgproc;
   cmdproc = cproc;
 
+  
   return true;
 }
 
@@ -76,7 +99,7 @@ PropertyPage::FirstDialogProcReflector (
   if (message != WM_INITDIALOG)
     {
       // Don't handle anything until we get a WM_INITDIALOG message, which
-      // will have our this pointer with it.
+      // will have our 'this' pointer with it.
       return FALSE;
     }
 
@@ -114,12 +137,9 @@ PropertyPage::DialogProc (UINT message, 
     {
     case WM_INITDIALOG:
       {
+        // Do initialization stuff.
 	OnInit ();
 
-	// Set header title font of each internal page to MS Sans Serif, Bold, 8 Pt.
-	// This will just silently fail on the first and last pages.
-	SetDlgItemFont(IDC_STATIC_HEADER_TITLE, "MS Sans Serif", 8, FW_BOLD);
-
 	// TRUE = Set focus to default control (in wParam).
 	return TRUE;
 	break;
@@ -133,16 +153,9 @@ PropertyPage::DialogProc (UINT message, 
 	  break;
 	case PSN_SETACTIVE:
 	  {
-	    if (DoOnceForSheet)
-	      {
-		// Tell our parent PropSheet what its own HWND is.
-		GetOwner ()->SetHWNDFromPage (((NMHDR FAR *) lParam)->
-					      hwndFrom);
-		GetOwner ()->CenterWindow ();
-		DoOnceForSheet = false;
-	      }
-
-	    // Set the wizard buttons apropriately
+	    // Set the wizard buttons apropriately.  Do this before calling the
+	    // possibly-oveloaded OnActivate() so that it can do nothing for
+	    // default-button action or override the defaults.
 	    if (IsFirst)
 	      {
 		// Disable "Back" on first page.
@@ -159,7 +172,17 @@ PropertyPage::DialogProc (UINT message, 
 		GetOwner ()->SetButtons (PSWIZB_BACK | PSWIZB_NEXT);
 	      }
 
-	    OnActivate ();
+	    // Call the possibly-overloaded handler
+	    long retval;
+	    retval = OnActivate ();
+	    if(retval != 0)
+	    {
+	      // Activation was not accepted.
+		  ::SetWindowLong (GetHWND (), DWL_MSGRESULT, retval);
+	      return TRUE;
+	    }
+
+		GetOwner()->Resize(this);
 
 	    if (unattended_mode) 
 	      {
@@ -264,3 +287,16 @@ PropertyPage::DialogProc (UINT message, 
   // Wasn't handled
   return FALSE;
 }
+
+void
+PropertyPage::OnInit ()
+{
+  // Set header title font of each internal page to MS Sans Serif, Bold, 8 Pt.
+  // This will just silently fail on the first and last pages.
+  SetDlgItemFont(IDC_STATIC_HEADER_TITLE, "MS Sans Serif", 8, FW_BOLD);
+  
+  // Set the font for the IDC_STATIC_WELCOME_TITLE
+  // This will just silently fail on the middle pages.
+  SetDlgItemFont(IDC_STATIC_WELCOME_TITLE, "Ariel", 12, FW_BOLD);
+}
+
Index: proppage.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/proppage.h,v
retrieving revision 2.4
diff -p -u -b -r2.4 proppage.h
--- proppage.h	15 Jan 2003 22:29:16 -0000	2.4
+++ proppage.h	2 Feb 2003 10:42:53 -0000
@@ -2,7 +2,7 @@
 #define CINSTALL_PROPPAGE_H
 
 /*
- * Copyright (c) 2001, Gary R. Van Sickle.
+ * Copyright (c) 2001, 2002, 2003 Gary R. Van Sickle.
  *
  *     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
@@ -29,7 +29,6 @@ class PropSheet;
 
 class PropertyPage:public Window
 {
-  static bool DoOnceForSheet;
   PROPSHEETPAGE psp;
   DLGPROC proc;
     BOOL (*cmdproc) (HWND h, int id, HWND hwndctl, UINT code);
@@ -40,6 +39,9 @@ class PropertyPage:public Window
   // For setting the back/finish buttons properly.
   bool IsFirst, IsLast;
 
+  // Original rect from the template, in dialog units.
+  RECT OriginalRECT;
+
   static BOOL CALLBACK FirstDialogProcReflector (HWND hwnd, UINT message,
 						 WPARAM wParam,
 						 LPARAM lParam);
@@ -59,7 +61,8 @@ public:
     return &psp;
   };
 
-  // FIXME: These should be private and friended to PropSheet.
+  // FIXME: These should be private and friended to PropSheet,
+  // if there's some way to do that.
   void YouAreBeingAddedToASheet (PropSheet * ps)
   {
     OurSheet = ps;
@@ -79,6 +82,7 @@ public:
     IsFirst = false;
     IsLast = false;
   };
+  RECT GetPageRECT() const { return OriginalRECT; };
 
   virtual bool Create (int TemplateID);
   virtual bool Create (DLGPROC dlgproc, int TemplateID);
@@ -86,19 +90,32 @@ public:
 		       BOOL (*cmdproc) (HWND h, int id, HWND hwndctl,
 					UINT code), int TemplateID);
 
-  virtual void OnInit ()
-  {
-  };
-  virtual void OnActivate ()
+
+  virtual void OnInit ();
+  
+  // Overload this to perform any special processing just before the
+  // page is displayed.  Return:
+  // 0 == Accept activation.
+  // -1 == Go to the next/previous page (i.e. skip this page).
+  // Resouce ID == go to a specific page specified by the resource ID.
+  virtual long OnActivate ()
   {
+    return 0;
   };
   virtual void OnDeactivate ()
   {
   };
+  
+  // Overload this to perform special processing when the user
+  // hits "Next".  Return:
+  // 0 == Go to next page.
+  // -1 == Prevent wizard from going to next page.
+  // Resouce ID == go to a specific page specified by the resource ID.
   virtual long OnNext ()
   {
     return 0;
   };
+  
   virtual long OnBack ()
   {
     return 0;
Index: propsheet.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/propsheet.cc,v
retrieving revision 2.4
diff -p -u -b -r2.4 propsheet.cc
--- propsheet.cc	1 May 2002 11:13:16 -0000	2.4
+++ propsheet.cc	2 Feb 2003 10:42:54 -0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, Gary R. Van Sickle.
+ * Copyright (c) 2001, 2002, 2003 Gary R. Van Sickle.
  *
  *     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
@@ -20,6 +20,7 @@
 
 #include "propsheet.h"
 #include "proppage.h"
+#include "rectpp.h"
 
 //#include <shlwapi.h>
 // ...but since there is no shlwapi.h in mingw yet:
@@ -53,9 +54,20 @@ typedef struct DLGTEMPLATEEX
 DLGTEMPLATEEX, *LPDLGTEMPLATEEX;
 #include <poppack.h>
 
+#define WM_USER_RECALCPAGESIZES WM_USER+1
+
+#define ID_APPLY_NOW                    0x3021
+#define ID_WIZBACK                      0x3023
+#define ID_WIZNEXT                      0x3024
+#define ID_WIZFINISH                    0x3025
+#define ID_BUTTON_SEPARATOR				ID_WIZFINISH+1
+
+static const int button_ids[] = { IDOK, IDCANCEL, ID_APPLY_NOW, ID_WIZBACK, ID_WIZNEXT,
+                                  ID_WIZFINISH, ID_BUTTON_SEPARATOR };
+
 PropSheet::PropSheet ()
 {
-  NumPropPages = 0;
+  MarginsValid = false;
 }
 
 PropSheet::~PropSheet ()
@@ -68,15 +80,15 @@ PropSheet::CreatePages ()
   HPROPSHEETPAGE *retarray;
 
   // Create the return array
-  retarray = new HPROPSHEETPAGE[NumPropPages];
+  retarray = new HPROPSHEETPAGE[PropertyPages.size()];
 
   // Create the pages with CreatePropertySheetPage().
   // We do it here rather than in the PropertyPages themselves
   // because, for reasons known only to Microsoft, these handles will be
   // destroyed by the property sheet before the PropertySheet() call returns,
   // at least if it's modal (don't know about modeless).
-  int i;
-  for (i = 0; i < NumPropPages; i++)
+  unsigned int i;
+  for (i = 0; i < PropertyPages.size(); i++)
     {
       retarray[i] =
 	CreatePropertySheetPage (PropertyPages[i]->GetPROPSHEETPAGEPtr ());
@@ -86,7 +98,7 @@ PropSheet::CreatePages ()
 	{
 	  PropertyPages[i]->YouAreFirst ();
 	}
-      else if (i == NumPropPages - 1)
+      else if (i == PropertyPages.size() - 1)
 	{
 	  PropertyPages[i]->YouAreLast ();
 	}
@@ -107,13 +119,17 @@ PropSheetProc (HWND hwndDlg, UINT uMsg, 
     case PSCB_PRECREATE:
       {
 	// Add a minimize box to the sheet/wizard.
+	// Start up not visible, so that we have a chance to do the resizing
+	// logic before we're displayed.
 	if (((LPDLGTEMPLATEEX) lParam)->signature == 0xFFFF)
 	  {
 	    ((LPDLGTEMPLATEEX) lParam)->style |= WS_MINIMIZEBOX;
+	    ((LPDLGTEMPLATEEX) lParam)->style &= ~WS_VISIBLE;
 	  }
 	else
 	  {
 	    ((LPDLGTEMPLATE) lParam)->style |= WS_MINIMIZEBOX;
+	    ((LPDLGTEMPLATE) lParam)->style &= ~WS_VISIBLE;
 	  }
       }
       return TRUE;
@@ -168,12 +184,15 @@ bool
 PropSheet::Create (const Window * Parent, DWORD Style)
 {
   PROPSHEETHEADER p;
+  DWORD psize;
 
   PageHandles = CreatePages ();
 
-  p.dwSize = GetPROPSHEETHEADERSize ();
+  psize = GetPROPSHEETHEADERSize ();
+
+  p.dwSize = psize;
   p.dwFlags =
-    PSH_NOAPPLYNOW | PSH_WIZARD | PSH_USECALLBACK /*| PSH_MODELESS */ ;
+    PSH_NOAPPLYNOW | PSH_WIZARD | PSH_USECALLBACK | PSH_MODELESS ;
   if (Parent != NULL)
     {
       p.hwndParent = Parent->GetHWND ();
@@ -183,40 +202,37 @@ PropSheet::Create (const Window * Parent
       p.hwndParent = NULL;
     }
   p.hInstance = GetInstance ();
-  p.nPages = NumPropPages;
+  p.nPages = PropertyPages.size();
   p.nStartPage = 0;
   p.phpage = PageHandles;
   p.pfnCallback = PropSheetProc;
 
+  // Do a modeless property sheet...
+  SetHWND((HWND)PropertySheet(&p));
 
-  // The winmain event loop actually resides in here.
-  PropertySheet (&p);
+  SaveOriginalButtonPositions();
+  MarginsValid = true;
 
-  // Do a modeless property sheet...
-  //SetHWND((HWND)PropertySheet(&p));
-  /*Show(SW_SHOWNORMAL);
+  Resize(PropertyPages[0]);
+  CenterWindow();
+  
+  Show(SW_SHOWNORMAL);
 
      // ...but pretend it's modal
      MessageLoop();
-     MessageBox(NULL, "DONE", NULL, MB_OK);
 
-     // FIXME: Enable the parent before destroying this window to prevent another window
-     // from becoming the foreground window
-     // ala: EnableWindow(<parent_hwnd>, TRUE);
-     //DestroyWindow(WindowHandle);
-   */
-  SetHWND (NULL);
+  // Enable the parent before destroying this window to prevent another window
+  // from becoming the foreground window.
+  if(Parent != NULL)
+  {
+    EnableWindow(Parent->GetHWND(), TRUE);
+  }
 
+  DestroyWindow(GetHWND());
 
-  return true;
-}
+  SetHWND (NULL);
 
-void
-PropSheet::SetHWNDFromPage (HWND h)
-{
-  // If we're a modal dialog, there's no way for us to know our window handle unless
-  // one of our pages tells us through this function.
-  SetHWND (h);
+  return true;
 }
 
 void
@@ -224,8 +240,7 @@ PropSheet::AddPage (PropertyPage * p)
 {
   // Add a page to the property sheet.
   p->YouAreBeingAddedToASheet (this);
-  PropertyPages[NumPropPages] = p;
-  NumPropPages++;
+  PropertyPages.push_back(p);
 }
 
 bool
@@ -255,3 +270,155 @@ PropSheet::PressButton (int button)
 {
   ::PropSheet_PressButton (GetHWND (), button);
 }
+
+void
+PropSheet::SaveOriginalButtonPositions()
+{
+  unsigned int i;
+  RECT WindowRect;
+  RECT PageRect;
+
+  // Save sheet client rect.
+  OriginalClientRect = GetClientRect();
+  WindowRect = GetWindowRect();
+  
+  // Save button rects in client coords.
+  for(i=0; i<sizeof(button_ids)/sizeof(button_ids[0]); i++)
+  {
+    HWND di;
+    di = GetDlgItem(button_ids[i]);
+    if(di != NULL)
+    {
+      ::GetWindowRect(di, &OriginalButtonPositions[i]);
+      OriginalButtonPositions[i] = ScreenToClient(OriginalButtonPositions[i]);
+    }
+  }
+
+  // Get the margins, in screen coordinates units.
+  HWND tc = PropSheet_GetCurrentPageHwnd(GetHWND());
+  ::GetWindowRect(tc, &PageRect);
+  PageSideMargin = PageRect.left - WindowRect.left;
+  PageTopMargin = PageRect.top - WindowRect.top;
+  PageBottomMargin = WindowRect.bottom - PageRect.bottom;
+  
+  // Get the original tab control rect
+  /*HWND tc = PropSheet_GetTabControl(GetHWND());
+  ::GetWindowRect(tc, &OriginalTabControlRect);
+  OriginalTabControlRect = ScreenToClient(OriginalTabControlRect);
+  TabCtrlSideMargin = OriginalTabControlRect.left;
+  TabCtrlTopMargin = OriginalTabControlRect.top;
+  TabCtrlBottomMargin = OriginalRect.bottom - OriginalTabControlRect.bottom;*/
+}
+
+void
+PropSheet::RepositionButtons()
+{
+  RECTPP r;
+  unsigned int i;
+  long xo, yo;
+  
+  // Get the sheet's client rectangle.
+  r = GetClientRect();
+  
+  // Calculate the offsets from the original rect.
+  xo = r.width() - OriginalClientRect.width();
+  yo = r.height() - OriginalClientRect.height();  
+  
+  // Go through all the buttons and reposition them.
+  for(i=0; i<sizeof(button_ids)/sizeof(button_ids[0]); i++)
+  {
+    HWND di;
+    di = GetDlgItem(button_ids[i]);
+    if(di != NULL)
+    {
+      // Reposition the button.
+      RECTPP rb;
+      rb = OriginalButtonPositions[i];
+      rb.offset(xo, yo);
+      ::MoveWindow(di, rb.left, rb.top, rb.width(), rb.height(), TRUE);
+    }
+  }
+}
+
+void
+PropSheet::RecalcPageSizesAsync(PropertyPage *p)
+{
+  PostMessage(WM_USER_RECALCPAGESIZES, 0, (LPARAM)p);
+}
+
+void
+PropSheet::Resize(PropertyPage *p)
+{
+    // Resize sheet to the specified page's size.
+    // Called by the page itself in its PSN_SETACTIVE handler.
+    
+    if(MarginsValid)
+    {
+
+		RECTPP r, wr;
+		POINT c;
+
+		// Get the page's desired size in screen coords.
+		r = p->GetPageRECT();
+		MapDialogRect(p->GetHWND(), &r);
+		
+		// Get the center of the sheet's current rect in screen coords.
+		wr = GetWindowRect();
+		c = wr.center();
+		
+		// Resize the sheet.
+		// Maintain the sheet's center point if it won't cause the page to go off-screen.
+		wr.left = 0;
+		wr.top = 0;
+		wr.right = r.width() + 2 * PageSideMargin;
+		wr.bottom = r.height() + PageBottomMargin + PageTopMargin;
+		wr.offset(c.x-wr.width()/2, c.y-wr.height()/2);
+		/*MoveWindow(r.left, r.top,
+			r.width() + 2 * PageSideMargin,
+			r.height() + PageBottomMargin + PageTopMargin);*/
+		MoveWindow(wr);
+
+		// Resize the page.  The default Windows property sheet control will have changed its size.
+		r.offset(PageSideMargin+wr.left, PageTopMargin+wr.top);
+		r = ScreenToClient(r);
+		p->MoveWindow(r);
+
+		// Resize the tab control.
+		// FIXME - This doesn't appear necessary, but for completeness
+		// I suppose we should probably be doing it.
+		/*tcr = OriginalTabControlRect;
+		tcr.right = r.right -  OriginalTabControlRect.left;
+		::MoveWindow(PropSheet_GetTabControl(GetHWND()), tcr.left, tcr.top, tcr.width(), tcr.height(), FALSE);*/
+
+		RepositionButtons();
+	}
+}
+
+bool
+PropSheet::MessageLoop ()
+{
+  MSG msg;
+  BOOL bret;
+
+  while ((bret = GetMessage (&msg, NULL, 0, 0)) != 0)
+    {
+      if(bret == -1)
+      {
+        // Error
+        return false;
+      }
+      else if (PropSheet_GetCurrentPageHwnd(GetHWND()) == NULL)
+      {
+        // Close
+        return true;
+      }
+      else if(!IsWindow(GetHWND()) || !PropSheet_IsDialogMessage (GetHWND(), &msg))
+      {
+        TranslateMessage (&msg);
+        DispatchMessage (&msg);
+      }
+    }
+
+  return true;
+}
+
Index: propsheet.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/propsheet.h,v
retrieving revision 2.2
diff -p -u -b -r2.2 propsheet.h
--- propsheet.h	3 Jan 2002 11:27:11 -0000	2.2
+++ propsheet.h	2 Feb 2003 10:42:54 -0000
@@ -2,7 +2,7 @@
 #define CINSTALL_PROPSHEET_H
 
 /*
- * Copyright (c) 2001, Gary R. Van Sickle.
+ * Copyright (c) 2001, 2002, 2003 Gary R. Van Sickle.
  *
  *     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
@@ -22,27 +22,43 @@
 // the Windows function of the same name.
 
 
+#include <vector>
+
 #include <windows.h>
 #include <prsht.h>
 
 #include "window.h"
+#include "rectpp.h"
 
 class PropertyPage;
 
-class PropSheet:public Window
+class PropSheet : public Window
 {
-  PropertyPage *PropertyPages[MAXPROPPAGES];
-  int NumPropPages;
+  typedef std::vector< PropertyPage* > PAGE_CONTAINER;
+  PAGE_CONTAINER PropertyPages;
+  
+  RECTPP OriginalClientRect;
+  RECTPP OriginalTabControlRect;
+  RECTPP OriginalButtonPositions[10];
+  
+  bool MarginsValid;
+  
+  int PageSideMargin;
+  int PageTopMargin;
+  int PageBottomMargin;
+  
+  DLGPROC OldWndProc;
 
   HPROPSHEETPAGE *PageHandles;
   HPROPSHEETPAGE *CreatePages ();
 
+  void SaveOriginalButtonPositions();
+
 public:
     PropSheet ();
     virtual ~ PropSheet ();
 
-  // Should be private and friended to PropertyPage
-  void SetHWNDFromPage (HWND h);
+  virtual bool MessageLoop ();
 
   virtual bool Create (const Window * Parent = NULL,
 		       DWORD Style =
@@ -54,6 +70,10 @@ public:
   bool SetActivePageByID (int resource_id);
   void SetButtons (DWORD flags);
   void PressButton (int button);
+  
+  void RecalcPageSizesAsync(PropertyPage *p = NULL);
+  void Resize(PropertyPage *p = NULL);
+  void RepositionButtons();
 };
 
 #endif // CINSTALL_PROPSHEET_H
Index: res.rc
===================================================================
RCS file: /cvs/cygwin-apps/setup/res.rc,v
retrieving revision 2.45
diff -p -u -b -r2.45 res.rc
--- res.rc	19 Jan 2003 20:31:53 -0000	2.45
+++ res.rc	2 Feb 2003 10:42:55 -0000
@@ -233,8 +233,7 @@ STYLE DS_MODALFRAME | DS_3DLOOK | DS_CEN
 CAPTION "Cygwin Setup"
 FONT 8, "MS Sans Serif"
 BEGIN
-    ICON            IDI_CYGWIN,IDC_STATIC,113,112,21,20,WS_GROUP
-//    CONTROL         "",IDC_STATIC,"Static",SS_WHITERECT,0,0,95,178
+    ICON            IDI_CYGWIN,IDC_STATIC,113,112,20,20,WS_GROUP
     LTEXT           "Version (unknown)",IDC_VERSION,115,137,195,10
     LTEXT           "Cygwin Net Release Setup Program",
                     IDC_STATIC_WELCOME_TITLE,115,1,195,24
@@ -244,6 +243,8 @@ BEGIN
                     195,8
     LTEXT           "This wizard will guide you through the installation and updating of the Cygwin environment and a plethora of GNU packages.",
                     IDC_STATIC,115,33,195,54
+    CONTROL         "",IDC_STATIC,"Static",SS_BLACKFRAME | NOT WS_VISIBLE,0,
+                    0,20,20
 END
 
 IDD_DESKTOP DIALOG DISCARDABLE  0, 0, 317, 179
@@ -253,15 +254,13 @@ CAPTION "Create Icons"
 FONT 8, "MS Sans Serif"
 BEGIN
     CONTROL         "Create icon on &Desktop",IDC_ROOT_DESKTOP,"Button",
-                    BS_AUTOCHECKBOX,108,78,100,8
+                    BS_AUTOCHECKBOX,115,69,100,8
     CONTROL         "Add icon to &Start Menu",IDC_ROOT_MENU,"Button",
-                    BS_AUTOCHECKBOX,108,93,100,8
-    ICON            IDI_CYGWIN,IDC_STATIC,290,0,21,20
-    CONTROL         "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28,
-                    317,1
+                    BS_AUTOCHECKBOX,115,86,100,8
+    ICON            IDI_CYGWIN,IDC_STATIC,113,112,21,20
     LTEXT           "Tell setup if you want it to create a few icons for convenient access to the Cygwin environment.",
-                    IDC_STATIC,21,9,239,16,NOT WS_GROUP
-    LTEXT           "Create Icons",IDC_STATIC_HEADER_TITLE,7,0,258,8,NOT 
+                    IDC_STATIC,115,33,195,16,NOT WS_GROUP
+    LTEXT           "Finished",IDC_STATIC_WELCOME_TITLE,115,1,195,24,NOT 
                     WS_GROUP
 END
 
@@ -282,31 +281,32 @@ BEGIN
     PUSHBUTTON      "Cancel",IDCANCEL,165,75,45,15
 END
 
-IDD_CHOOSE DIALOG DISCARDABLE  0, 0, 317, 179
+IDD_CHOOSE DIALOG DISCARDABLE  0, 0, 402, 302
 STYLE DS_MODALFRAME | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_CAPTION | 
     WS_SYSMENU
 CAPTION "Select Packages"
 FONT 8, "MS Sans Serif"
 BEGIN
-    CONTROL         "&Keep",IDC_CHOOSE_KEEP,"Button",BS_AUTORADIOBUTTON | 
-                    WS_GROUP | WS_TABSTOP,115,30,30,10
-    CONTROL         "&Prev",IDC_CHOOSE_PREV,"Button",BS_AUTORADIOBUTTON , 
-                    150,30,27,10
-    CONTROL         "&Curr",IDC_CHOOSE_CURR,"Button",BS_AUTORADIOBUTTON , 
-                    185,30,25,10
-    CONTROL         "E&xp",IDC_CHOOSE_EXP,"Button",BS_AUTORADIOBUTTON , 
-                    220,30,25,10
-    PUSHBUTTON      "&View",IDC_CHOOSE_VIEW,255,30,20,10,WS_GROUP
+    CONTROL         "&Previous",IDC_CHOOSE_PREV,"Button",BS_AUTORADIOBUTTON | 
+                    WS_GROUP | WS_TABSTOP,5,35,60,10
+    CONTROL         "&Current",IDC_CHOOSE_CURR,"Button",BS_AUTORADIOBUTTON,
+                    70,35,60,10
+    CONTROL         "&Keep",IDC_CHOOSE_KEEP,"Button",BS_AUTORADIOBUTTON,135,
+                    35,60,10
+    CONTROL         "E&xperimental",IDC_CHOOSE_EXP,"Button",
+                    BS_AUTORADIOBUTTON,200,35,60,10
+    PUSHBUTTON      "Next &View",IDC_CHOOSE_VIEW,285,35,55,15,WS_GROUP
     CONTROL         "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28,
-                    317,1
+                    401,1
     CONTROL         "",IDC_LISTVIEW_POS,"Static",SS_BLACKFRAME | NOT 
-                    WS_VISIBLE,7,41,303,134
-    ICON            IDI_CYGWIN,IDC_STATIC,290,0,20,20
+                    WS_VISIBLE,5,55,390,240
+    ICON            IDI_CYGWIN,IDC_STATIC,375,0,20,20
     LTEXT           "Select the packages you want setup to install.",
                     IDC_STATIC,21,9,239,16,NOT WS_GROUP
     LTEXT           "Select Packages",IDC_STATIC_HEADER_TITLE,7,0,258,8,NOT 
                     WS_GROUP
-    LTEXT           "",IDC_CHOOSE_VIEWCAPTION,280,30,30,10
+    LTEXT           "",IDC_CHOOSE_VIEWCAPTION,340,35,56,15,0,
+                    WS_EX_STATICEDGE
 END
 
 
@@ -427,9 +427,9 @@ BEGIN
     IDD_CHOOSE, DIALOG
     BEGIN
         LEFTMARGIN, 7
-        RIGHTMARGIN, 310
+        RIGHTMARGIN, 395
         TOPMARGIN, 7
-        BOTTOMMARGIN, 172
+        BOTTOMMARGIN, 295
     END
 END
 #endif    // APSTUDIO_INVOKED
Index: root.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/root.h,v
retrieving revision 2.3
diff -p -u -b -r2.3 root.h
--- root.h	21 Sep 2002 09:36:46 -0000	2.3
+++ root.h	2 Feb 2003 10:42:55 -0000
@@ -22,3 +22,4 @@ public:
 };
 
 #endif // CINSTALL_ROOT_H
+
Index: site.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/site.cc,v
retrieving revision 2.24
diff -p -u -b -r2.24 site.cc
--- site.cc	9 Nov 2002 13:44:54 -0000	2.24
+++ site.cc	2 Feb 2003 10:42:57 -0000
@@ -366,7 +366,7 @@ SitePage::OnBack ()
   return 0;
 }
 
-void
+long
 SitePage::OnActivate ()
 {
   // Fill the list box with all known sites.
@@ -377,6 +377,8 @@ SitePage::OnActivate ()
 
   // Get the enabled/disabled states of the controls set accordingly.
   CheckControlsAndDisableAccordingly ();
+  
+  return 0;
 }
 
 long
Index: site.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/site.h,v
retrieving revision 2.9
diff -p -u -b -r2.9 site.h
--- site.h	10 Nov 2002 03:40:36 -0000	2.9
+++ site.h	2 Feb 2003 10:42:57 -0000
@@ -37,7 +37,7 @@ public:
   bool Create ();
 
   virtual void OnInit ();
-  virtual void OnActivate ();
+  virtual long OnActivate ();
   virtual long OnNext ();
   virtual long OnBack ();
   virtual long OnUnattended ();
Index: source.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/source.cc,v
retrieving revision 2.14
diff -p -u -b -r2.14 source.cc
--- source.cc	25 Nov 2002 00:41:25 -0000	2.14
+++ source.cc	2 Feb 2003 10:42:57 -0000
@@ -82,7 +82,7 @@ SourcePage::Create ()
   return PropertyPage::Create (NULL, dialog_cmd, IDD_SOURCE);
 }
 
-void
+long
 SourcePage::OnActivate ()
 {
   if (!source)
@@ -106,6 +106,7 @@ SourcePage::OnActivate ()
       SendMessage (GetDlgItem (IDC_SOURCE_NETINST), BM_SETCHECK,
 		   BST_CHECKED, 0);
     }
+    return 0;
 }
 
 long
Index: source.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/source.h,v
retrieving revision 2.3
diff -p -u -b -r2.3 source.h
--- source.h	21 Sep 2002 09:36:46 -0000	2.3
+++ source.h	2 Feb 2003 10:42:57 -0000
@@ -34,7 +34,7 @@ public:
 
   bool Create ();
 
-  virtual void OnActivate ();
+  virtual long OnActivate ();
   virtual void OnDeactivate ();
   virtual long OnNext ();
   virtual long OnBack ();
Index: splash.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/splash.cc,v
retrieving revision 2.10
diff -p -u -b -r2.10 splash.cc
--- splash.cc	25 Nov 2002 00:41:25 -0000	2.10
+++ splash.cc	2 Feb 2003 10:42:57 -0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, Gary R. Van Sickle.
+ * Copyright (c) 2001, 2002, 2003 Gary R. Van Sickle.
  *
  *     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
@@ -39,8 +39,7 @@ SplashPage::OnInit ()
 
   ::SetWindowText (GetDlgItem (IDC_VERSION), ver.c_str ());
 
-  // Set the font for the IDC_STATIC_WELCOME_TITLE
-  SetDlgItemFont(IDC_STATIC_WELCOME_TITLE, "Ariel", 12, FW_BOLD);
+  PropertyPage::OnInit();
 }
 
 long
Index: splash.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/splash.h,v
retrieving revision 2.4
diff -p -u -b -r2.4 splash.h
--- splash.h	25 Nov 2002 00:41:25 -0000	2.4
+++ splash.h	2 Feb 2003 10:42:57 -0000
@@ -2,7 +2,7 @@
 #define CINSTALL_SPLASH_H
 
 /*
- * Copyright (c) 2001, Gary R. Van Sickle.
+ * Copyright (c) 2001, 2002, 2003, Gary R. Van Sickle.
  *
  *     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
Index: threebar.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/threebar.cc,v
retrieving revision 2.4
diff -p -u -b -r2.4 threebar.cc
--- threebar.cc	26 Jun 2002 21:35:16 -0000	2.4
+++ threebar.cc	2 Feb 2003 10:42:57 -0000
@@ -107,7 +107,7 @@ ThreeBarProgressPage::EnableSingleBar (b
   ShowWindow (ins_diskfull, enable ? SW_HIDE : SW_SHOW);
 }
 
-void
+long
 ThreeBarProgressPage::OnActivate ()
 {
   // Disable back and next buttons
@@ -132,6 +132,7 @@ ThreeBarProgressPage::OnActivate ()
     }
 
   Window::PostMessage (task);
+  return 0;
 }
 
 bool
Index: threebar.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/threebar.h,v
retrieving revision 2.4
diff -p -u -b -r2.4 threebar.h
--- threebar.h	21 Sep 2002 09:36:46 -0000	2.4
+++ threebar.h	2 Feb 2003 10:42:57 -0000
@@ -61,7 +61,7 @@ public:
   bool Create ();
 
   virtual void OnInit ();
-  virtual void OnActivate ();
+  virtual long OnActivate ();
   virtual bool OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam);
   virtual long OnUnattended ()
   {
Index: window.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/window.cc,v
retrieving revision 2.5
diff -p -u -b -r2.5 window.cc
--- window.cc	26 Nov 2002 12:11:35 -0000	2.5
+++ window.cc	2 Feb 2003 10:42:58 -0000
@@ -20,6 +20,7 @@
 #include <windows.h>
 #include "window.h"
 #include "String++.h"
+#include "rectpp.h"
 
 ATOM Window::WindowClassAtom = 0;
 HINSTANCE Window::AppInstance = NULL;
@@ -202,6 +203,12 @@ bool
 Window::MoveWindow(long x, long y, long w, long h, bool Repaint)
 {
   return ::MoveWindow (WindowHandle, x, y, w, h, Repaint);
+}
+
+bool
+Window::MoveWindow(const RECTPP &r, bool Repaint)
+{
+  return ::MoveWindow (WindowHandle, r.left, r.top, r.width(), r.height(), Repaint);
 }
 
 void
Index: window.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/window.h,v
retrieving revision 2.5
diff -p -u -b -r2.5 window.h
--- window.h	26 Nov 2002 12:11:35 -0000	2.5
+++ window.h	2 Feb 2003 10:42:58 -0000
@@ -23,6 +23,7 @@
 #include <windows.h>
 
 class String;
+class RECTPP;
 
 class Window
 {
@@ -112,6 +113,7 @@ public:
 
   // Reposition the window
   bool MoveWindow(long x, long y, long w, long h, bool Repaint = true);
+  bool MoveWindow(const RECTPP &r, bool Repaint = true);
 
   // Set the title of the window.
   void SetWindowText (const String & s);
