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 28 Mar 2003 06:17:43 -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) + { + // 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 28 Mar 2003 06:17:43 -0000 @@ -40,7 +40,7 @@ public: bool Create (); - virtual void OnActivate (); + virtual long OnActivate (); virtual void OnDeactivate (); virtual long OnNext (); virtual long OnBack (); @@ -48,3 +48,4 @@ public: }; #endif /* CINSTALL_ANTIVIRUS_H */ + Index: choose.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/choose.cc,v retrieving revision 2.113 diff -p -u -b -r2.113 choose.cc --- choose.cc 13 Mar 2003 21:21:14 -0000 2.113 +++ choose.cc 28 Mar 2003 06:17:45 -0000 @@ -63,8 +63,6 @@ using namespace std; extern ThreeBarProgressPage Progress; -static int initialized = 0; - static HWND lv, choose_inst_text; static PickView *chooser = NULL; @@ -544,6 +542,8 @@ ChooserPage::OnInit () HWND frame; RECT r; + PropertyPage::OnInit(); + register_windows (GetInstance ()); if (source == IDC_SOURCE_DOWNLOAD || source == IDC_SOURCE_CWD) @@ -564,10 +564,11 @@ ChooserPage::OnInit () create_listview (GetHWND (), &r); } -void +long ChooserPage::OnActivate() { set_view_mode (lv, chooser->get_view_mode ()); + return 0; } long @@ -629,7 +630,6 @@ ChooserPage::OnNext () long ChooserPage::OnBack () { - initialized = 0; if (source == IDC_SOURCE_CWD) return IDD_LOCAL_DIR; else Index: choose.h =================================================================== RCS file: /cvs/cygwin-apps/setup/choose.h,v retrieving revision 2.17 diff -p -u -b -r2.17 choose.h --- choose.h 10 Mar 2003 06:22:17 -0000 2.17 +++ choose.h 28 Mar 2003 06:17:45 -0000 @@ -39,7 +39,7 @@ public: virtual void OnInit (); virtual long OnNext (); virtual long OnBack (); - virtual void OnActivate (); + virtual long OnActivate (); virtual long OnUnattended () { return OnNext (); Index: desktop.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/desktop.cc,v retrieving revision 2.35 diff -p -u -b -r2.35 desktop.cc --- desktop.cc 25 Mar 2003 20:57:13 -0000 2.35 +++ desktop.cc 28 Mar 2003 06:17:46 -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; } Index: dialog.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/dialog.cc,v retrieving revision 2.7 diff -p -u -b -r2.7 dialog.cc --- dialog.cc 4 May 2002 12:15:56 -0000 2.7 +++ dialog.cc 28 Mar 2003 06:17:46 -0000 @@ -113,3 +113,4 @@ fatal (const char *msg) // Keep gcc happy - some sort of bug! exit (1); } + Index: IniDBBuilder.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/IniDBBuilder.cc,v retrieving revision 2.6 diff -p -u -b -r2.6 IniDBBuilder.cc --- IniDBBuilder.cc 15 Jul 2002 11:27:03 -0000 2.6 +++ IniDBBuilder.cc 28 Mar 2003 06:17:47 -0000 @@ -50,3 +50,4 @@ void IniDBBuilder::buildPackageListAndNo void IniDBBuilder::buildPackageListOrNode (String const &){} void IniDBBuilder::buildPackageListOperator (PackageSpecification::_operators const &){} void IniDBBuilder::buildPackageListOperatorVersion (String const &){} + 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 28 Mar 2003 06:18:01 -0000 @@ -156,6 +156,9 @@ void LocalDirPage::OnInit () { static int inited = 0; + + PropertyPage::OnInit(); + if (!inited) { io_stream *f = @@ -174,10 +177,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 28 Mar 2003 06:18:01 -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.8 diff -p -u -b -r2.8 LogFile.cc --- LogFile.cc 18 Mar 2003 14:53:09 -0000 2.8 +++ LogFile.cc 28 Mar 2003 06:18:02 -0000 @@ -127,7 +127,18 @@ LogFile::exit (int const exit_code) been_here = 1; if (exit_msg) - note (NULL, exit_msg, backslash(getFileName(LOG_BABBLE)).cstr_oneuse()); + { + // 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; @@ -136,7 +147,11 @@ LogFile::exit (int const exit_code) { log_save (i->level, i->key, i->append); } + + if(exit_code != 0) + { ::exit (exit_code); + } } void Index: LogFile.h =================================================================== RCS file: /cvs/cygwin-apps/setup/LogFile.h,v retrieving revision 2.4 diff -p -u -b -r2.4 LogFile.h --- LogFile.h 9 Mar 2003 01:22:43 -0000 2.4 +++ LogFile.h 28 Mar 2003 06:18:02 -0000 @@ -28,7 +28,7 @@ public: * which guarantees to flush any log data... * but doesn't call generic C++ destructors */ - virtual void exit (int const exit_code) __attribute__ ((noreturn)); + virtual void exit (int const exit_code); virtual ~LogFile(); // get a specific verbosity stream. virtual std::ostream &operator() (enum log_level level); @@ -41,3 +41,4 @@ protected: private: void log_save (int babble, String const &filename, bool append); }; + Index: LogSingleton.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/LogSingleton.cc,v retrieving revision 2.3 diff -p -u -b -r2.3 LogSingleton.cc --- LogSingleton.cc 9 Nov 2002 14:32:55 -0000 2.3 +++ LogSingleton.cc 28 Mar 2003 06:18:02 -0000 @@ -76,3 +76,4 @@ private: static LogSingleton *theInstance; }; #endif + Index: LogSingleton.h =================================================================== RCS file: /cvs/cygwin-apps/setup/LogSingleton.h,v retrieving revision 2.3 diff -p -u -b -r2.3 LogSingleton.h --- LogSingleton.h 9 Nov 2002 14:32:56 -0000 2.3 +++ LogSingleton.h 28 Mar 2003 06:18:02 -0000 @@ -37,7 +37,7 @@ public: * which guarantees to flush any log data... * but doesn't call generic C++ destructors */ - __attribute__ ((noreturn)) virtual void exit (int const exit_code) = 0; + virtual void exit (int const exit_code) = 0; virtual ~LogSingleton(); // get a specific verbosity stream. virtual std::ostream &operator() (enum log_level level) = 0; Index: main.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/main.cc,v retrieving revision 2.25 diff -p -u -b -r2.25 main.cc --- main.cc 28 Feb 2003 23:42:09 -0000 2.25 +++ main.cc 28 Mar 2003 06:18:03 -0000 @@ -369,7 +369,10 @@ main (int argc, char **argv) // Create the PropSheet main window MainWindow.Create (); + // Close the log theLog->exit (0); - /* Keep gcc happy :} */ + + // All is well return 0; } + Index: md5.h =================================================================== RCS file: /cvs/cygwin-apps/setup/md5.h,v retrieving revision 2.2 diff -p -u -b -r2.2 md5.h --- md5.h 14 May 2002 02:53:52 -0000 2.2 +++ md5.h 28 Mar 2003 06:18:03 -0000 @@ -89,3 +89,4 @@ void md5_finish(md5_state_t *pms, md5_by #endif #endif /* md5_INCLUDED */ + 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 28 Mar 2003 06:18:04 -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 28 Mar 2003 06:18:04 -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: net.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/net.cc,v retrieving revision 2.12 diff -p -u -b -r2.12 net.cc --- net.cc 21 Sep 2002 09:36:46 -0000 2.12 +++ net.cc 28 Mar 2003 06:18:04 -0000 @@ -94,6 +94,8 @@ NetPage::OnInit () { HWND h = GetHWND (); + PropertyPage::OnInit(); + net_method = IDC_NET_DIRECT; load_dialog (h); CheckIfEnableNext(); @@ -156,3 +158,4 @@ NetPage::OnMessageCmd (int id, HWND hwnd // Was handled since we never got to default above. return true; } + Index: postinstall.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/postinstall.cc,v retrieving revision 2.13 diff -p -u -b -r2.13 postinstall.cc --- postinstall.cc 25 Mar 2003 20:57:13 -0000 2.13 +++ postinstall.cc 28 Mar 2003 06:18:05 -0000 @@ -82,8 +82,6 @@ private: static void do_postinstall_thread (HINSTANCE h, HWND owner) { - next_dialog = IDD_DESKTOP; - Progress.SetText1 ("Running..."); Progress.SetText2 (""); Progress.SetText3 (""); 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 28 Mar 2003 06:18:05 -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; } @@ -103,6 +126,9 @@ PropertyPage::DialogProcReflector (HWND BOOL CALLBACK PropertyPage::DialogProc (UINT message, WPARAM wParam, LPARAM lParam) { + if (InSendMessage()) + ReplyMessage(TRUE); + if (proc != NULL) { proc (GetHWND (), message, wParam, lParam); @@ -114,12 +140,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 +156,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 +175,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) { @@ -200,10 +226,12 @@ PropertyPage::DialogProc (UINT message, } break; case PSN_KILLACTIVE: + { OnDeactivate (); // FALSE = Allow deactivation SetWindowLong (GetHWND (), DWL_MSGRESULT, FALSE); return TRUE; + } break; case PSN_WIZNEXT: { @@ -264,3 +292,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 28 Mar 2003 06:18:06 -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 28 Mar 2003 06:18:07 -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,8 @@ #include "propsheet.h" #include "proppage.h" +#include "rectpp.h" +#include "resource.h" //#include // ...but since there is no shlwapi.h in mingw yet: @@ -53,9 +55,20 @@ typedef struct DLGTEMPLATEEX DLGTEMPLATEEX, *LPDLGTEMPLATEEX; #include +#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::ThisPtrOfPropSheetBeingCreated = NULL; + PropSheet::PropSheet () { - NumPropPages = 0; + MarginsValid = false; } PropSheet::~PropSheet () @@ -68,15 +81,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 +99,7 @@ PropSheet::CreatePages () { PropertyPages[i]->YouAreFirst (); } - else if (i == NumPropPages - 1) + else if (i == PropertyPages.size() - 1) { PropertyPages[i]->YouAreLast (); } @@ -99,24 +112,39 @@ PropSheet::CreatePages () return retarray; } -static int CALLBACK -PropSheetProc (HWND hwndDlg, UINT uMsg, LPARAM lParam) +int CALLBACK +PropSheet::PropSheetProc (HWND hwndDlg, UINT uMsg, LPARAM lParam) { switch (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, otherwise we'll be gyrating all over + // the place. 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; + break; + } + case PSCB_INITIALIZED: + { + // Tell the PropSheet what its HWND is. + // PLEASE somebody find a better way to do this! + ThisPtrOfPropSheetBeingCreated->SetHWND(hwndDlg); + break; + } + default: + break; } return TRUE; } @@ -168,12 +196,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 | PSH_USEICONID; if (Parent != NULL) { p.hwndParent = Parent->GetHWND (); @@ -183,40 +214,48 @@ PropSheet::Create (const Window * Parent p.hwndParent = NULL; } p.hInstance = GetInstance (); - p.nPages = NumPropPages; + p.pszIcon = MAKEINTRESOURCE(IDI_CYGWIN); + p.nPages = PropertyPages.size(); p.nStartPage = 0; p.phpage = PageHandles; p.pfnCallback = PropSheetProc; + // Do a modeless property sheet... + ThisPtrOfPropSheetBeingCreated = this; + HWND h = (HWND)PropertySheet(&p); + // Somewhere during the call to PropertySheet, the first page will + // receive a SETACTIVE message, and try to call SetButtons(). Exactly what + // we'd want to happen, IF WE KNEW WHAT OUR HWND WAS. The only way I can come + // up with to do this for property sheets is via a static variable + // (ThisPtrOfPropSheetBeingCreated) which is used in our PSCB_INITIALIZED + // handler to set our HWND. A threadsafe stack would make this bulletproof + // I think, but still an abomination. + SetHWND(h); + ThisPtrOfPropSheetBeingCreated = NULL; - // 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(, 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 +263,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 +293,150 @@ 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; iGetPageRECT(); + 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. + // FIXME - add the "it won't cause the page to go off-screen" part. + 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(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(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; + } + + if(!PropSheet_IsDialogMessage (GetHWND(), &msg)) + { + TranslateMessage (&msg); + DispatchMessage (&msg); + } + + if (PropSheet_GetCurrentPageHwnd(GetHWND()) == NULL) + { + // No active page. This means the user hit "finish", + // so we're done here. Exit the loop. + return true; + } + } + 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 28 Mar 2003 06:18:07 -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,47 @@ // the Windows function of the same name. +#include + #include #include #include "window.h" +#include "rectpp.h" class PropertyPage; -class PropSheet:public Window +class PropSheet : public Window { - PropertyPage *PropertyPages[MAXPROPPAGES]; - int NumPropPages; + static PropSheet* ThisPtrOfPropSheetBeingCreated; + + 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); + static int CALLBACK PropSheetProc (HWND hwndDlg, UINT uMsg, LPARAM lParam); + + virtual bool MessageLoop (); virtual bool Create (const Window * Parent = NULL, DWORD Style = @@ -54,6 +74,9 @@ public: bool SetActivePageByID (int resource_id); void SetButtons (DWORD flags); void PressButton (int button); + + 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.48 diff -p -u -b -r2.48 res.rc --- res.rc 9 Mar 2003 01:39:42 -0000 2.48 +++ res.rc 28 Mar 2003 06:18:09 -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,105,30,30,10 - CONTROL "&Prev",IDC_CHOOSE_PREV,"Button",BS_AUTORADIOBUTTON , - 140,30,27,10 - CONTROL "&Curr",IDC_CHOOSE_CURR,"Button",BS_AUTORADIOBUTTON , - 175,30,25,10 - CONTROL "E&xp",IDC_CHOOSE_EXP,"Button",BS_AUTORADIOBUTTON , - 210,30,25,10 - PUSHBUTTON "&View",IDC_CHOOSE_VIEW,245,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,270,30,40,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: resource.h =================================================================== RCS file: /cvs/cygwin-apps/setup/resource.h,v retrieving revision 2.22 diff -p -u -b -r2.22 resource.h --- resource.h 9 Mar 2003 01:39:42 -0000 2.22 +++ resource.h 28 Mar 2003 06:18:09 -0000 @@ -136,3 +136,4 @@ #define _APS_NEXT_SYMED_VALUE 101 #endif #endif + Index: rfc1738.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/rfc1738.cc,v retrieving revision 2.4 diff -p -u -b -r2.4 rfc1738.cc --- rfc1738.cc 1 May 2002 11:13:16 -0000 2.4 +++ rfc1738.cc 28 Mar 2003 06:18:10 -0000 @@ -232,3 +232,4 @@ rfc1738_unescape_part (String const &url delete[] t; return rv; } + Index: root.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/root.cc,v retrieving revision 2.12 diff -p -u -b -r2.12 root.cc --- root.cc 9 Nov 2002 13:44:54 -0000 2.12 +++ root.cc 28 Mar 2003 06:18:10 -0000 @@ -170,6 +170,8 @@ RootPage::Create () void RootPage::OnInit () { + PropertyPage::OnInit(); + if (((string)RootOption).size()) set_root_dir((string)RootOption); if (!get_root_dir ().size()) 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 28 Mar 2003 06:18:10 -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.25 diff -p -u -b -r2.25 site.cc --- site.cc 10 Mar 2003 08:50:16 -0000 2.25 +++ site.cc 28 Mar 2003 06:18:12 -0000 @@ -332,6 +332,8 @@ bool SitePage::Create () void SitePage::OnInit () { + PropertyPage::OnInit(); + string SiteOptionString = SiteOption; if (SiteOptionString.size()) register_saved_site (SiteOptionString.c_str()); @@ -369,7 +371,7 @@ SitePage::OnBack () return 0; } -void +long SitePage::OnActivate () { // Fill the list box with all known sites. @@ -380,6 +382,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.10 diff -p -u -b -r2.10 site.h --- site.h 10 Mar 2003 08:50:16 -0000 2.10 +++ site.h 28 Mar 2003 06:18:12 -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 28 Mar 2003 06:18:12 -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 28 Mar 2003 06:18:12 -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 28 Mar 2003 06:18:12 -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 28 Mar 2003 06:18:12 -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.5 diff -p -u -b -r2.5 threebar.cc --- threebar.cc 25 Mar 2003 20:57:13 -0000 2.5 +++ threebar.cc 28 Mar 2003 06:18:12 -0000 @@ -35,6 +35,8 @@ bool ThreeBarProgressPage::Create () void ThreeBarProgressPage::OnInit () { + PropertyPage::OnInit(); + // Get HWNDs to the dialog controls ins_action = GetDlgItem (IDC_INS_ACTION); ins_pkgname = GetDlgItem (IDC_INS_PKG); @@ -107,7 +109,7 @@ ThreeBarProgressPage::EnableSingleBar (b ShowWindow (ins_diskfull, enable ? SW_HIDE : SW_SHOW); } -void +long ThreeBarProgressPage::OnActivate () { // Disable back and next buttons @@ -132,6 +134,7 @@ ThreeBarProgressPage::OnActivate () } Window::PostMessage (task); + return 0; } bool Index: threebar.h =================================================================== RCS file: /cvs/cygwin-apps/setup/threebar.h,v retrieving revision 2.5 diff -p -u -b -r2.5 threebar.h --- threebar.h 25 Mar 2003 20:57:13 -0000 2.5 +++ threebar.h 28 Mar 2003 06:18:13 -0000 @@ -63,7 +63,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 28 Mar 2003 06:18:14 -0000 @@ -20,6 +20,9 @@ #include #include "window.h" #include "String++.h" +#include "rectpp.h" + +#define PROP_ORIGINAL_PROC TEXT("Original_Proc") ATOM Window::WindowClassAtom = 0; HINSTANCE Window::AppInstance = NULL; @@ -61,7 +64,7 @@ Window::FirstWindowProcReflector (HWND h wnd = reinterpret_cast(((LPCREATESTRUCT)lParam)->lpCreateParams); // Set a backreference to this class instance in the HWND. - SetWindowLongPtr (hwnd, GWL_USERDATA, (LONG_PTR) wnd); + SetWindowLongPtr (hwnd, GWL_USERDATA, reinterpret_cast(wnd)); // Set a new WindowProc now that we have the peliminaries done. // We could instead simply do the contents of Window::WindowProcReflector @@ -85,7 +88,7 @@ Window::WindowProcReflector (HWND hwnd, Window *This; // Get our this pointer - This = (Window *) GetWindowLongPtr (hwnd, GWL_USERDATA); + This = reinterpret_cast(GetWindowLongPtr (hwnd, GWL_USERDATA)); return This->WindowProc (uMsg, wParam, lParam); } @@ -99,6 +102,7 @@ bool Window::Create (Window * parent, DW return false; } + // Save our parent, we'll probably need it eventually. Parent = parent; // Create the window instance @@ -204,6 +208,12 @@ Window::MoveWindow(long x, long y, long 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 Window::CenterWindow () { @@ -287,7 +297,7 @@ Window::PostMessage (UINT uMsg, WPARAM w UINT Window::IsButtonChecked (int nIDButton) const { - return::IsDlgButtonChecked (GetHWND (), nIDButton); + return ::IsDlgButtonChecked (GetHWND (), nIDButton); } bool @@ -322,7 +332,7 @@ bool return false; } - // Set the new fint, and redraw any text which was already in the item. + // Set the new font, and redraw any text which was already in the item. SendMessage (ctrl, WM_SETFONT, (WPARAM) hfnt, TRUE); // Save it for later. @@ -359,5 +369,17 @@ Window::ScreenToClient(const RECT &r) co ret.right = br.x; return ret; +} + +bool +Window::Subclass(HWND hwndctl) +{ + // Subclass the given window + // FIXME - Just stubbed in for now. + WNDPROC pfnOrigProc = (WNDPROC) GetWindowLong(hwndctl, GWL_WNDPROC); + SetProp(hwndctl, PROP_ORIGINAL_PROC, (HANDLE) pfnOrigProc); + SetWindowLong(hwndctl, GWL_WNDPROC, (LONG) (WNDPROC) WindowProcReflector); + + return true; } 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 28 Mar 2003 06:18:14 -0000 @@ -23,6 +23,7 @@ #include class String; +class RECTPP; class Window { @@ -36,6 +37,7 @@ class Window static LRESULT CALLBACK WindowProcReflector (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + // Our Windows(tm) window handle. HWND WindowHandle; Window *Parent; @@ -55,21 +57,27 @@ public: Window (); virtual ~ Window (); + virtual bool Create (Window * Parent = NULL, + DWORD Style = + WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN); + bool Subclass(HWND hwndctl); + static void SetAppInstance (HINSTANCE h) { + // This only has to be called once in the entire app, before + // any Windows are created. AppInstance = h; }; virtual LRESULT WindowProc (UINT uMsg, WPARAM wParam, LPARAM lParam); virtual bool MessageLoop (); - virtual bool Create (Window * Parent = NULL, - DWORD Style = - WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN); void Show (int State); HWND GetHWND () const { + // Ideally this could be hidden from the user completely. + // And people in Hell want icewater. return WindowHandle; }; HINSTANCE GetInstance () const @@ -112,11 +120,14 @@ 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); RECT ScreenToClient(const RECT &r) const; + + };