Back to index

lightning-sunbird  0.9+nobinonly
dialogs.c
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code, released
00016  * March 31, 1998.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1998
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Sean Su <ssu@netscape.com>
00025  *   Curt Patrick <curt@netscape.com>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either of the GNU General Public License Version 2 or later (the "GPL"),
00029  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 
00041 #include "extern.h"
00042 #include "extra.h"
00043 #include "dialogs.h"
00044 #include "ifuncns.h"
00045 #include "xpistub.h"
00046 #include "xpi.h"
00047 #include "logging.h"
00048 #include <shlobj.h>
00049 #include <logkeys.h>
00050 
00051 // commdlg.h is needed to build with WIN32_LEAN_AND_MEAN
00052 #include <commdlg.h>
00053 
00054 static WNDPROC OldListBoxWndProc = NULL;
00055 static WNDPROC OldBrowseWndProc  = NULL;
00056 static BOOL    gbProcessingXpnstallFiles;
00057 static DWORD   gdwACFlag;
00058 static DWORD   gdwIndexLastSelected;
00059 
00060 /* List of Dialog Item IDs from the Download dialog
00061  * that need to be repositioned (up) when the banner
00062  * in the dialog is hidden.
00063  */
00064 const int DownloadDlgItemList[] = {IDPAUSE,
00065                                    IDRESUME,
00066                                    IDCANCEL,
00067                                    IDC_MESSAGE0,
00068                                    IDC_STATIC3,
00069                                    IDC_STATUS_URL,
00070                                    IDC_STATIC1,
00071                                    IDC_STATUS_STATUS,
00072                                    IDC_STATIC2,
00073                                    IDC_STATUS_FILE,
00074                                    IDC_GAUGE_FILE,
00075                                    IDC_PERCENTAGE,
00076                                    IDC_STATIC4,
00077                                    IDC_STATUS_TO,
00078                                    -2};  /* -1 is used by IDC_STATIC.  Even though
00079                                           * there shouldn't be any IDC_STATIC in
00080                                           * list, we shouldn't use it.
00081                                           */
00082 
00083 /* List of Dialog Item IDs from the Install Progress dialog
00084  * that need to be repositioned (up) when the banner
00085  * in the dialog is hidden.
00086 */
00087 const int InstallProgressDlgItemList[] = {IDC_STATUS0,
00088                                           IDC_GAUGE_ARCHIVE,
00089                                           IDC_STATUS3,
00090                                           IDC_GAUGE_FILE,
00091                                           -2};  /* -1 is used by IDC_STATIC.  Even though
00092                                                  * there shouldn't be any IDC_STATIC in
00093                                                  * list, we shouldn't use it.
00094                                                  */
00095 
00096 void ClosePreviousDialog()
00097 {
00098   if(!sgProduct.lastDialog)
00099     return;
00100 
00101   DestroyWindow(sgProduct.lastDialog);
00102   sgProduct.lastDialog = NULL;
00103 }
00104  
00105 void UnSubclassWindow(HWND aHwnd, WNDPROC *aWndProc)
00106 {
00107   // Un-subclass the window.
00108   if(aHwnd && *aWndProc)
00109   {
00110     SubclassWindow(aHwnd, *aWndProc);
00111     *aWndProc = NULL;
00112   }
00113 }
00114 
00115 BOOL AskCancelDlg(HWND hDlg)
00116 {
00117   char szDlgQuitTitle[MAX_BUF];
00118   char szDlgQuitMsg[MAX_BUF];
00119   char szMsg[MAX_BUF];
00120   BOOL bRv = FALSE;
00121 
00122   if((sgProduct.mode != SILENT) && (sgProduct.mode != AUTO))
00123   {
00124     if(!GetPrivateProfileString("Messages", "DLGQUITTITLE", "", szDlgQuitTitle, sizeof(szDlgQuitTitle), szFileIniInstall))
00125       PostQuitMessage(1);
00126     else if(!GetPrivateProfileString("Messages", "DLGQUITMSG", "", szDlgQuitMsg, sizeof(szDlgQuitMsg), szFileIniInstall))
00127       PostQuitMessage(1);
00128     else if(MessageBox(hDlg, szDlgQuitMsg, szDlgQuitTitle, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2 | MB_APPLMODAL | MB_SETFOREGROUND) == IDYES)
00129     {
00130       DestroyWindow(hDlg);
00131       PostQuitMessage(0);
00132       bRv = TRUE;
00133     }
00134   }
00135   else
00136   {
00137     GetPrivateProfileString("Strings", "Message Cancel Setup AUTO mode", "", szMsg, sizeof(szMsg), szFileIniConfig);
00138     ShowMessage(szMsg, TRUE);
00139     Delay(5);
00140     bRv = TRUE;
00141   }
00142 
00143   return(bRv);
00144 } 
00145 
00146 void DisableSystemMenuItems(HWND hWnd, BOOL bDisableClose)
00147 {
00148   EnableMenuItem(GetSystemMenu(hWnd, FALSE), SC_RESTORE,  MF_BYCOMMAND | MF_GRAYED);
00149   EnableMenuItem(GetSystemMenu(hWnd, FALSE), SC_SIZE,     MF_BYCOMMAND | MF_GRAYED);
00150   EnableMenuItem(GetSystemMenu(hWnd, FALSE), SC_MAXIMIZE, MF_BYCOMMAND | MF_GRAYED);
00151 
00152   if(bDisableClose)
00153     EnableMenuItem(GetSystemMenu(hWnd, FALSE), SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
00154 }
00155 
00156 /* Function: MoveDlgItem()
00157  *
00158  *       in: HWND  aWndDlg     : handle to a dialog containing items in aIDList.
00159  *           const int *aIDList: list of dlg item IDs that require moving.
00160  *           DWORD aWidth      : width to move the dlg items by (+/-).
00161  *           DWORD aHeight     : height to move the dlg items by (+/-).
00162  *           
00163  *  purpose: To move dialog items (given a list of item ids) +aWidth/+aHeight from
00164  *           its current position.
00165  *           This is for when the banner logo in the download/install process
00166  *           dialogs are not to be displayed, it leaves an empty area above
00167  *           the dialog items/controls.  So this helps move them up by the
00168  *           height of the banner.
00169  *           The resizing of the window given the lack of the banner is done
00170  *           RepositionWindow().
00171  */
00172 void MoveDlgItem(HWND aWndDlg, const int *aIDList, DWORD aWidth, DWORD aHeight)
00173 {
00174   RECT rect;
00175   HWND hDlgItem;
00176   int i;
00177   int id;
00178 
00179   i  = 0;
00180   id = aIDList[i];
00181   while(id != -2)
00182   {
00183     hDlgItem = GetDlgItem(aWndDlg, id);
00184     if(hDlgItem)
00185     {
00186       GetWindowRect(hDlgItem, &rect);
00187       SetWindowPos(hDlgItem, NULL, rect.left + aWidth, rect.top + aHeight,
00188                    -1, -1, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
00189     }
00190     id = aIDList[++i];
00191   }
00192 }
00193 
00194 /* Function: RepositionWindow()
00195  *
00196  *       in: HWND  aHwndDlg    : Window handle to reposition.
00197  *           DWORD aBannerImage: Integer indicating which dialog needs to have
00198  *                               it's dlg items moved.
00199  *                               There are only 3 types:
00200  *                                 NO_BANNER_IMAGE
00201  *                                 BANNER_IMAGE_DOWNLOAD
00202  *                                 BANNER_IMAGE_INSTALLING
00203  *
00204  *  purpose: To reposition a window given the screen position of the previous
00205  *           window.  The previous window position is saved in:
00206  *             gSystemInfo.lastWindowPosCenterX
00207  *             gSystemInfo.lastWindowPosCenterY
00208  *
00209  *           aHwndDlg is the window handle to the dialog to reposition.
00210  *           aBannerImage is a DWORD value that indicates which dialog
00211  *           the banner is displayed in.  There are only two possible dialogs:
00212  *             Download dialog
00213  *             Install dialog
00214  *
00215  *           This function also hides the banner image normally displayed in
00216  *           the Download and Install Process dialgs.  Once hidden, it also
00217  *           moves all of their dialog items up by the height of the hidden
00218  *           banner image and resizes the dialogs so it'll look nice.
00219  */
00220 void RepositionWindow(HWND aHwndDlg, DWORD aBannerImage)
00221 {
00222   RECT  rect;
00223   int   iLeft, iTop;
00224   DWORD width = -1;
00225   DWORD height = -1;
00226   DWORD windowFlags = SWP_NOSIZE | SWP_NOACTIVATE;
00227   HWND  insertAfterHwnd;
00228 
00229   GetWindowRect(aHwndDlg, &rect);
00230   if(aBannerImage && !gShowBannerImage)
00231   {
00232     RECT  rLogo;
00233     HWND  hwndBanner;
00234 
00235     hwndBanner = GetDlgItem(aHwndDlg, IDB_BITMAP_BANNER);
00236     GetWindowRect(hwndBanner, &rLogo);
00237     ShowWindow(hwndBanner, SW_HIDE);
00238     width = rect.right;
00239     height = rect.bottom - rLogo.bottom + rLogo.top;
00240     windowFlags = SWP_NOACTIVATE;
00241 
00242     /* aBannerImage indicates which dialog we need to move it's dlg items
00243      * up to fit the resized window.
00244      */
00245     switch(aBannerImage)
00246     {
00247       case BANNER_IMAGE_DOWNLOAD:
00248         MoveDlgItem(aHwndDlg, DownloadDlgItemList, 0, -rLogo.bottom);
00249         break;
00250 
00251       case BANNER_IMAGE_INSTALLING:
00252         MoveDlgItem(aHwndDlg, InstallProgressDlgItemList, 0, -rLogo.bottom);
00253         break;
00254 
00255       default:
00256         break;
00257     }
00258   }
00259 
00260   if(gSystemInfo.lastWindowIsTopWindow)
00261     insertAfterHwnd = HWND_TOP;
00262   else
00263     insertAfterHwnd = HWND_BOTTOM;
00264 
00265   iLeft = (gSystemInfo.lastWindowPosCenterX - ((rect.right - rect.left) / 2));
00266   iTop  = (gSystemInfo.lastWindowPosCenterY - ((rect.bottom - rect.top) / 2));
00267   SetWindowPos(aHwndDlg, insertAfterHwnd, iLeft, iTop, width, height, windowFlags);
00268 
00269   if(gSystemInfo.lastWindowMinimized)
00270     ShowWindow(aHwndDlg, SW_SHOWMINNOACTIVE);
00271   else if(!gSystemInfo.lastWindowIsTopWindow)
00272     ShowWindow(aHwndDlg, SW_SHOWNOACTIVATE);
00273   else
00274     ShowWindow(aHwndDlg, SW_SHOW);
00275 }
00276 
00277 /* Function: SaveWindowPosition()
00278  *
00279  *       in: HWND aDlg: Window handle to remember the position of.
00280  *
00281  *  purpose: Saves the current window's position so that it can be
00282  *           used to position the next window created.
00283  */
00284 void SaveWindowPosition(HWND aDlg)
00285 {
00286   WINDOWPLACEMENT wndPlacement;
00287   HWND            hwndForegroundWindow;
00288   HWND            hwndTopWindow;
00289   HWND            hwndParent = NULL;
00290   HWND            hwndWindow = NULL;
00291 
00292   if(GetWindowPlacement(aDlg, &wndPlacement))
00293   {
00294     RECT rectDesktop;
00295     if (SystemParametersInfo(SPI_GETWORKAREA, 0, &rectDesktop, SPIF_SENDWININICHANGE))
00296     {
00297       wndPlacement.rcNormalPosition.left   += rectDesktop.left;
00298       wndPlacement.rcNormalPosition.right  += rectDesktop.left;
00299       wndPlacement.rcNormalPosition.top    += rectDesktop.top;
00300       wndPlacement.rcNormalPosition.bottom += rectDesktop.top;
00301     }
00302     gSystemInfo.lastWindowPosCenterX = ((wndPlacement.rcNormalPosition.right - wndPlacement.rcNormalPosition.left) / 2) + wndPlacement.rcNormalPosition.left;
00303     gSystemInfo.lastWindowPosCenterY = ((wndPlacement.rcNormalPosition.bottom - wndPlacement.rcNormalPosition.top) / 2) + wndPlacement.rcNormalPosition.top;
00304     gSystemInfo.lastWindowMinimized  = (wndPlacement.showCmd & SW_MINIMIZE)?TRUE:FALSE;
00305   }
00306 
00307   hwndForegroundWindow = GetForegroundWindow();
00308   hwndTopWindow        = GetTopWindow(NULL);
00309   hwndWindow           = NULL;
00310   hwndParent           = GetParent(aDlg);
00311   while(hwndParent != NULL)
00312   {
00313     hwndWindow = hwndParent;
00314     hwndParent = GetParent(hwndWindow);
00315   }
00316 
00317   if(hwndParent == aDlg)
00318     gSystemInfo.lastWindowIsTopWindow = TRUE;
00319   else if((hwndParent == NULL) && (hwndWindow == aDlg))
00320     gSystemInfo.lastWindowIsTopWindow = TRUE;
00321   else if(hwndForegroundWindow == aDlg)
00322     gSystemInfo.lastWindowIsTopWindow = TRUE;
00323   else
00324     gSystemInfo.lastWindowIsTopWindow = FALSE;
00325 }
00326 
00327 LRESULT CALLBACK DlgProcWelcome(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
00328 {
00329   char szBuf[MAX_BUF];
00330 
00331   switch(msg)
00332   {
00333     case WM_INITDIALOG:
00334       DisableSystemMenuItems(hDlg, FALSE);
00335       SetWindowText(hDlg, diWelcome.szTitle);
00336 
00337       wsprintf(szBuf, diWelcome.szMessage0, sgProduct.szProductName, sgProduct.szProductName);
00338       SetDlgItemText(hDlg, IDC_STATIC0, szBuf);
00339       SetDlgItemText(hDlg, IDC_STATIC1, diWelcome.szMessage1);
00340       SetDlgItemText(hDlg, IDC_STATIC2, diWelcome.szMessage2);
00341 
00342       RepositionWindow(hDlg, NO_BANNER_IMAGE);
00343 
00344       SetDlgItemText(hDlg, IDWIZNEXT, sgInstallGui.szNext_);
00345       SetDlgItemText(hDlg, IDCANCEL, sgInstallGui.szCancel_);
00346       SendDlgItemMessage (hDlg, IDC_STATIC0, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
00347       SendDlgItemMessage (hDlg, IDC_STATIC1, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
00348       SendDlgItemMessage (hDlg, IDC_STATIC2, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
00349       SendDlgItemMessage (hDlg, IDWIZNEXT, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
00350       SendDlgItemMessage (hDlg, IDCANCEL, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
00351       ClosePreviousDialog();
00352       break;
00353 
00354     case WM_COMMAND:
00355       switch(LOWORD(wParam))
00356       {
00357         case IDWIZNEXT:
00358           SaveWindowPosition(hDlg);
00359           sgProduct.lastDialog = hDlg;
00360           DlgSequence(NEXT_DLG);
00361           break;
00362 
00363         case IDCANCEL:
00364           AskCancelDlg(hDlg);
00365           break;
00366 
00367         default:
00368           break;
00369       }
00370       break;
00371   }
00372   return(0);
00373 }
00374 
00375 LRESULT CALLBACK DlgProcLicense(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
00376 {
00377   char            szBuf[MAX_BUF];
00378   LPSTR           szLicenseFilenameBuf = NULL;
00379   WIN32_FIND_DATA wfdFindFileData;
00380   DWORD           dwFileSize;
00381   DWORD           dwBytesRead;
00382   HANDLE          hFLicense;
00383   FILE            *fLicense;
00384 
00385   switch(msg)
00386   {
00387     case WM_INITDIALOG:
00388       DisableSystemMenuItems(hDlg, FALSE);
00389       SetWindowText(hDlg, diLicense.szTitle);
00390       SetDlgItemText(hDlg, IDC_MESSAGE0, diLicense.szMessage0);
00391       SetDlgItemText(hDlg, IDC_MESSAGE1, diLicense.szMessage1);
00392 
00393       lstrcpy(szBuf, szSetupDir);
00394       AppendBackSlash(szBuf, sizeof(szBuf));
00395       lstrcat(szBuf, diLicense.szLicenseFilename);
00396 
00397       if((hFLicense = FindFirstFile(szBuf, &wfdFindFileData)) != INVALID_HANDLE_VALUE)
00398       {
00399         dwFileSize = (wfdFindFileData.nFileSizeHigh * MAXDWORD) + wfdFindFileData.nFileSizeLow + 1;
00400         FindClose(hFLicense);
00401         if((szLicenseFilenameBuf = NS_GlobalAlloc(dwFileSize)) != NULL)
00402         {
00403           if((fLicense = fopen(szBuf, "rb")) != NULL)
00404           {
00405             dwBytesRead = fread(szLicenseFilenameBuf, sizeof(char), dwFileSize, fLicense);
00406             fclose(fLicense);
00407             SetDlgItemText(hDlg, IDC_EDIT_LICENSE, szLicenseFilenameBuf);
00408           }
00409 
00410           FreeMemory(&szLicenseFilenameBuf);
00411         }
00412       }
00413 
00414       RepositionWindow(hDlg, NO_BANNER_IMAGE);
00415 
00416       SetDlgItemText(hDlg, IDWIZBACK, sgInstallGui.szBack_);
00417       SetDlgItemText(hDlg, IDWIZNEXT, sgInstallGui.szAccept_);
00418       SetDlgItemText(hDlg, IDCANCEL, sgInstallGui.szDecline_);
00419       SendDlgItemMessage (hDlg, IDC_MESSAGE0, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00420       SendDlgItemMessage (hDlg, IDC_MESSAGE1, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00421       SendDlgItemMessage (hDlg, IDC_EDIT_LICENSE, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00422       SendDlgItemMessage (hDlg, IDWIZBACK, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00423       SendDlgItemMessage (hDlg, IDWIZNEXT, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00424       SendDlgItemMessage (hDlg, IDCANCEL, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00425       ClosePreviousDialog();
00426       break;
00427 
00428     case WM_COMMAND:
00429       switch(LOWORD(wParam))
00430       {
00431         case IDWIZNEXT:
00432           SaveWindowPosition(hDlg);
00433           sgProduct.lastDialog = hDlg;
00434           DlgSequence(NEXT_DLG);
00435           break;
00436 
00437         case IDWIZBACK:
00438           SaveWindowPosition(hDlg);
00439           sgProduct.lastDialog = hDlg;
00440           DlgSequence(PREV_DLG);
00441           break;
00442 
00443         case IDCANCEL:
00444           AskCancelDlg(hDlg);
00445           break;
00446 
00447         default:
00448           break;
00449       }
00450       break;
00451   }
00452   return(0);
00453 }
00454 
00455 LRESULT CALLBACK ListBoxBrowseWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00456 {
00457   switch(uMsg)
00458   {
00459     case LB_SETCURSEL:
00460       gdwIndexLastSelected = (DWORD)wParam;
00461       break;
00462   }
00463 
00464   return(CallWindowProc(OldBrowseWndProc, hWnd, uMsg, wParam, lParam));
00465 }
00466 
00467 LRESULT CALLBACK BrowseHookProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
00468 {
00469   DWORD dwIndex;
00470   DWORD dwLoop;
00471   char  szBuf[MAX_BUF];
00472   char  szBufIndex[MAX_BUF];
00473   char  szPath[MAX_BUF];
00474   HWND  hwndLBFolders;
00475 
00476   hwndLBFolders = GetDlgItem(hDlg, 1121);
00477   switch(message)
00478   {
00479     case WM_INITDIALOG:
00480       SetDlgItemText(hDlg, IDC_EDIT_DESTINATION, szTempSetupPath);
00481 
00482       RepositionWindow(hDlg, NO_BANNER_IMAGE);
00483 
00484       OldBrowseWndProc     = SubclassWindow(hwndLBFolders, (WNDPROC)ListBoxBrowseWndProc);
00485       gdwIndexLastSelected = SendDlgItemMessage(hDlg, 1121, LB_GETCURSEL, 0, (LPARAM)0);
00486 
00487       SetWindowText(hDlg, sgInstallGui.szSelectDirectory);
00488       SetDlgItemText(hDlg, 1092, sgInstallGui.szDirectories_);
00489       SetDlgItemText(hDlg, 1091, sgInstallGui.szDrives_);
00490       SetDlgItemText(hDlg, 1, sgInstallGui.szOk);
00491       SetDlgItemText(hDlg, IDCANCEL, sgInstallGui.szCancel);
00492       SendDlgItemMessage (hDlg, DLG_BROWSE_DIR, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
00493       SendDlgItemMessage (hDlg, 1092, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
00494       SendDlgItemMessage (hDlg, 1091, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
00495       SendDlgItemMessage (hDlg, 1, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
00496       SendDlgItemMessage (hDlg, IDCANCEL, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
00497       SendDlgItemMessage (hDlg, IDC_EDIT_DESTINATION, WM_SETFONT, (WPARAM)sgInstallGui.systemFont, 0L); 
00498       SendDlgItemMessage (hDlg, 1121, WM_SETFONT, (WPARAM)sgInstallGui.systemFont, 0L); 
00499       SendDlgItemMessage (hDlg, 1137, WM_SETFONT, (WPARAM)sgInstallGui.systemFont, 0L); 
00500       break;
00501 
00502     case WM_COMMAND:
00503       switch(LOWORD(wParam))
00504       {
00505         case 1121:
00506           if(HIWORD(wParam) == LBN_DBLCLK)
00507           {
00508             dwIndex = SendDlgItemMessage(hDlg, 1121, LB_GETCURSEL, 0, (LPARAM)0);
00509             SendDlgItemMessage(hDlg, 1121, LB_GETTEXT, 0, (LPARAM)szPath);
00510 
00511             if(gdwIndexLastSelected < dwIndex)
00512             {
00513               for(dwLoop = 1; dwLoop <= gdwIndexLastSelected; dwLoop++)
00514               {
00515                 SendDlgItemMessage(hDlg, 1121, LB_GETTEXT, dwLoop, (LPARAM)szBufIndex);
00516                 AppendBackSlash(szPath, sizeof(szPath));
00517                 lstrcat(szPath, szBufIndex);
00518               }
00519 
00520               SendDlgItemMessage(hDlg, 1121, LB_GETTEXT, dwIndex, (LPARAM)szBufIndex);
00521               AppendBackSlash(szPath, sizeof(szPath));
00522               lstrcat(szPath, szBufIndex);
00523             }
00524             else
00525             {
00526               for(dwLoop = 1; dwLoop <= dwIndex; dwLoop++)
00527               {
00528                 SendDlgItemMessage(hDlg, 1121, LB_GETTEXT, dwLoop, (LPARAM)szBufIndex);
00529                 AppendBackSlash(szPath, sizeof(szPath));
00530                 lstrcat(szPath, szBufIndex);
00531               }
00532             }
00533             SetDlgItemText(hDlg, IDC_EDIT_DESTINATION, szPath);
00534           }
00535           break;
00536 
00537         case IDOK:
00538           SaveWindowPosition(hDlg);
00539           GetDlgItemText(hDlg, IDC_EDIT_DESTINATION, szBuf, MAX_BUF);
00540           if(*szBuf == '\0')
00541           {
00542             char szEDestinationPath[MAX_BUF];
00543 
00544             GetPrivateProfileString("Messages", "ERROR_DESTINATION_PATH", "", szEDestinationPath, sizeof(szEDestinationPath), szFileIniInstall);
00545             MessageBox(hDlg, szEDestinationPath, NULL, MB_OK | MB_ICONEXCLAMATION);
00546             break;
00547           }
00548 
00549           AppendBackSlash(szBuf, sizeof(szBuf));
00550 
00551           /* Make sure that the path is not within the windows dir */
00552           if(IsPathWithinWindir(szBuf))
00553           {
00554               char errorMsg[MAX_BUF];
00555               char errorMsgTitle[MAX_BUF];
00556 
00557               GetPrivateProfileString("Messages", "ERROR_PATH_WITHIN_WINDIR",
00558                   "", errorMsg, sizeof(errorMsg), szFileIniInstall);
00559               GetPrivateProfileString("Messages", "ERROR_MESSAGE_TITLE", "",
00560                   errorMsgTitle, sizeof(errorMsgTitle), szFileIniInstall);
00561               MessageBox(hDlg, errorMsg, errorMsgTitle, MB_OK | MB_ICONERROR);
00562               break;
00563           }
00564 
00565           /* Create the path if it does not exist */
00566           if(FileExists(szBuf) == FALSE)
00567           {
00568             char szBufTemp[MAX_BUF];
00569             char szBuf2[MAX_PATH];
00570 
00571             if(CreateDirectoriesAll(szBuf, ADD_TO_UNINSTALL_LOG) != WIZ_OK)
00572             {
00573               char szECreateDirectory[MAX_BUF];
00574               char szEMessageTitle[MAX_BUF];
00575 
00576               lstrcpy(szBufTemp, "\n\n");
00577               lstrcat(szBufTemp, sgProduct.szPath);
00578               RemoveBackSlash(szBufTemp);
00579               lstrcat(szBufTemp, "\n\n");
00580 
00581               if(GetPrivateProfileString("Messages", "ERROR_CREATE_DIRECTORY", "", szECreateDirectory, sizeof(szECreateDirectory), szFileIniInstall))
00582                 wsprintf(szBuf, szECreateDirectory, szBufTemp);
00583 
00584               GetPrivateProfileString("Messages", "ERROR_MESSAGE_TITLE", "", szEMessageTitle, sizeof(szEMessageTitle), szFileIniInstall);
00585 
00586               MessageBox(hDlg, szBuf, szEMessageTitle, MB_OK | MB_ICONERROR);
00587               break;
00588             }
00589 
00590             if(*sgProduct.szSubPath != '\0')
00591             {
00592                /* log the subpath for uninstallation.  This subpath does not normally get logged
00593                 * for uninstallation due to a chicken and egg problem with creating the log file
00594                 * and the directory its in */
00595               lstrcpy(szBuf2, szBuf);
00596               AppendBackSlash(szBuf2, sizeof(szBuf2));
00597               lstrcat(szBuf2, sgProduct.szSubPath);
00598               UpdateInstallLog(KEY_CREATE_FOLDER, szBuf2, FALSE);
00599             }
00600 
00601             bCreateDestinationDir = TRUE;
00602           }
00603 
00604           lstrcpy(szTempSetupPath, szBuf);
00605           RemoveBackSlash(szTempSetupPath);
00606           UnSubclassWindow(hwndLBFolders, &OldBrowseWndProc);
00607           EndDialog(hDlg, 0);
00608           break;
00609       }
00610       break;
00611   }
00612   return(0);
00613 }
00614 
00615 BOOL BrowseForDirectory(HWND hDlg, char *szCurrDir)
00616 { 
00617   OPENFILENAME   of;
00618   char           ftitle[MAX_PATH];
00619   char           fname[MAX_PATH];
00620   char           szCDir[MAX_BUF];
00621   char           szBuf[MAX_BUF];
00622   char           szSearchPathBuf[MAX_BUF];
00623   char           szDlgBrowseTitle[MAX_BUF];
00624   BOOL           bRet;
00625 
00626   /* save the current directory */
00627   GetCurrentDirectory(MAX_BUF, szCDir);
00628 
00629   ZeroMemory(szDlgBrowseTitle, sizeof(szDlgBrowseTitle));
00630   GetPrivateProfileString("Messages", "DLGBROWSETITLE", "", szDlgBrowseTitle, sizeof(szDlgBrowseTitle), szFileIniInstall);
00631 
00632   lstrcpy(szSearchPathBuf, szCurrDir);
00633   if((*szSearchPathBuf != '\0') && ((lstrlen(szSearchPathBuf) != 1) || (*szSearchPathBuf != '\\')))
00634   {
00635     RemoveBackSlash(szSearchPathBuf);
00636     while(FileExists(szSearchPathBuf) == FALSE)
00637     {
00638       RemoveBackSlash(szSearchPathBuf);
00639       ParsePath(szSearchPathBuf, szBuf, sizeof(szBuf), FALSE, PP_PATH_ONLY);
00640       lstrcpy(szSearchPathBuf, szBuf);
00641     }
00642   }
00643 
00644   ZeroMemory(ftitle, sizeof(ftitle));
00645   strcpy(fname, "*.*");
00646   of.lStructSize        = sizeof(OPENFILENAME);
00647   of.hwndOwner          = hDlg;
00648   of.hInstance          = hSetupRscInst;
00649   of.lpstrFilter        = NULL;
00650   of.lpstrCustomFilter  = NULL;
00651   of.nMaxCustFilter     = 0;
00652   of.nFilterIndex       = 0;
00653   of.lpstrFile          = fname;
00654   of.nMaxFile           = MAX_PATH;
00655   of.lpstrFileTitle     = ftitle;
00656   of.nMaxFileTitle      = MAX_PATH;
00657   of.lpstrInitialDir    = szSearchPathBuf;
00658   of.lpstrTitle         = szDlgBrowseTitle;
00659   of.Flags              = OFN_NONETWORKBUTTON |
00660                           OFN_ENABLEHOOK      |
00661                           OFN_NOCHANGEDIR  |
00662                           OFN_ENABLETEMPLATE;
00663   of.nFileOffset        = 0;
00664   of.nFileExtension     = 0;
00665   of.lpstrDefExt        = NULL;
00666   of.lCustData          = 0;
00667   of.lpfnHook           = BrowseHookProc;
00668   of.lpTemplateName     = MAKEINTRESOURCE(DLG_BROWSE_DIR);
00669 
00670   if(GetOpenFileName(&of))
00671     bRet = TRUE;
00672   else
00673     bRet = FALSE;
00674 
00675   /* restore the current directory */
00676   SetCurrentDirectory(szCDir);
00677   return(bRet);
00678 }
00679 
00680 void TruncateString(HWND hWnd, LPSTR szInURL, LPSTR szOutString, DWORD dwOutStringBufSize)
00681 {
00682   HDC           hdcWnd;
00683   LOGFONT       logFont;
00684   HFONT         hfontNew;
00685   HFONT         hfontOld;
00686   RECT          rWndRect;
00687   SIZE          sizeString;
00688   char          *ptr = NULL;
00689   int           iHalfLen;
00690   int           iOutStringLen;
00691 
00692   if((DWORD)lstrlen(szInURL) > dwOutStringBufSize)
00693     return;
00694 
00695   ZeroMemory(szOutString, dwOutStringBufSize);
00696   lstrcpy(szOutString, szInURL);
00697   iOutStringLen = lstrlen(szOutString);
00698   hdcWnd        = GetWindowDC(hWnd);
00699   GetClientRect(hWnd, &rWndRect);
00700   SystemParametersInfo(SPI_GETICONTITLELOGFONT,
00701                        sizeof(logFont),
00702                        (PVOID)&logFont,
00703                        0);
00704 
00705   hfontNew = CreateFontIndirect(&logFont);
00706   if(hfontNew)
00707   {
00708     hfontOld = (HFONT)SelectObject(hdcWnd, hfontNew);
00709 
00710     GetTextExtentPoint32(hdcWnd, szOutString, iOutStringLen, &sizeString);
00711     while(sizeString.cx > rWndRect.right)
00712     {
00713       iHalfLen = iOutStringLen / 2;
00714       if(iHalfLen == 2)
00715         break;
00716 
00717       ptr = szOutString + iHalfLen;
00718       memmove(ptr - 1, ptr, lstrlen(ptr) + 1);
00719       szOutString[iHalfLen - 2] = '.';
00720       szOutString[iHalfLen - 1] = '.';
00721       szOutString[iHalfLen]     = '.';
00722       iOutStringLen = lstrlen(szOutString);
00723       GetTextExtentPoint32(hdcWnd, szOutString, iOutStringLen, &sizeString);
00724     }
00725   }
00726 
00727   SelectObject(hdcWnd, hfontOld);
00728   DeleteObject(hfontNew);
00729   ReleaseDC(hWnd, hdcWnd);
00730 }
00731 
00732 LRESULT CALLBACK DlgProcSetupType(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
00733 {
00734   HWND          hRadioSt0;
00735   HWND          hStaticSt0;
00736   HWND          hRadioSt1;
00737   HWND          hStaticSt1;
00738   HWND          hRadioSt2;
00739   HWND          hStaticSt2;
00740   HWND          hRadioSt3;
00741   HWND          hStaticSt3;
00742   HWND          hReadme;
00743   HWND          hDestinationPath;
00744   char          szBuf[MAX_BUF];
00745   char          szBufTemp[MAX_BUF];
00746 
00747   hRadioSt0   = GetDlgItem(hDlg, IDC_RADIO_ST0);
00748   hStaticSt0  = GetDlgItem(hDlg, IDC_STATIC_ST0_DESCRIPTION);
00749   hRadioSt1   = GetDlgItem(hDlg, IDC_RADIO_ST1);
00750   hStaticSt1  = GetDlgItem(hDlg, IDC_STATIC_ST1_DESCRIPTION);
00751   hRadioSt2   = GetDlgItem(hDlg, IDC_RADIO_ST2);
00752   hStaticSt2  = GetDlgItem(hDlg, IDC_STATIC_ST2_DESCRIPTION);
00753   hRadioSt3   = GetDlgItem(hDlg, IDC_RADIO_ST3);
00754   hStaticSt3  = GetDlgItem(hDlg, IDC_STATIC_ST3_DESCRIPTION);
00755   hReadme     = GetDlgItem(hDlg, IDC_README);
00756 
00757   switch(msg)
00758   {
00759     case WM_INITDIALOG:
00760       DisableSystemMenuItems(hDlg, FALSE);
00761       SetWindowText(hDlg, diSetupType.szTitle);
00762 
00763       hDestinationPath = GetDlgItem(hDlg, IDC_EDIT_DESTINATION); /* handle to the static destination path text window */
00764       TruncateString(hDestinationPath, szTempSetupPath, szBuf, sizeof(szBuf));
00765 
00766       SetDlgItemText(hDlg, IDC_EDIT_DESTINATION, szBuf);
00767       SetDlgItemText(hDlg, IDC_STATIC_MSG0, diSetupType.szMessage0);
00768 
00769       if(diSetupType.stSetupType0.bVisible)
00770       {
00771         SetDlgItemText(hDlg, IDC_RADIO_ST0, diSetupType.stSetupType0.szDescriptionShort);
00772         SetDlgItemText(hDlg, IDC_STATIC_ST0_DESCRIPTION, diSetupType.stSetupType0.szDescriptionLong);
00773         ShowWindow(hRadioSt0, SW_SHOW);
00774         ShowWindow(hStaticSt0, SW_SHOW);
00775       }
00776       else
00777       {
00778         ShowWindow(hRadioSt0, SW_HIDE);
00779         ShowWindow(hStaticSt0, SW_HIDE);
00780       }
00781 
00782       if(diSetupType.stSetupType1.bVisible)
00783       {
00784         SetDlgItemText(hDlg, IDC_RADIO_ST1, diSetupType.stSetupType1.szDescriptionShort);
00785         SetDlgItemText(hDlg, IDC_STATIC_ST1_DESCRIPTION, diSetupType.stSetupType1.szDescriptionLong);
00786         ShowWindow(hRadioSt1, SW_SHOW);
00787         ShowWindow(hStaticSt1, SW_SHOW);
00788       }
00789       else
00790       {
00791         ShowWindow(hRadioSt1, SW_HIDE);
00792         ShowWindow(hStaticSt1, SW_HIDE);
00793       }
00794 
00795       if(diSetupType.stSetupType2.bVisible)
00796       {
00797         SetDlgItemText(hDlg, IDC_RADIO_ST2, diSetupType.stSetupType2.szDescriptionShort);
00798         SetDlgItemText(hDlg, IDC_STATIC_ST2_DESCRIPTION, diSetupType.stSetupType2.szDescriptionLong);
00799         ShowWindow(hRadioSt2, SW_SHOW);
00800         ShowWindow(hStaticSt2, SW_SHOW);
00801       }
00802       else
00803       {
00804         ShowWindow(hRadioSt2, SW_HIDE);
00805         ShowWindow(hStaticSt2, SW_HIDE);
00806       }
00807 
00808       if(diSetupType.stSetupType3.bVisible)
00809       {
00810         SetDlgItemText(hDlg, IDC_RADIO_ST3, diSetupType.stSetupType3.szDescriptionShort);
00811         SetDlgItemText(hDlg, IDC_STATIC_ST3_DESCRIPTION, diSetupType.stSetupType3.szDescriptionLong);
00812         ShowWindow(hRadioSt3, SW_SHOW);
00813         ShowWindow(hStaticSt3, SW_SHOW);
00814       }
00815       else
00816       {
00817         ShowWindow(hRadioSt3, SW_HIDE);
00818         ShowWindow(hStaticSt3, SW_HIDE);
00819       }
00820 
00821       /* enable the appropriate radio button */
00822       switch(dwTempSetupType)
00823       {
00824         case ST_RADIO0:
00825           CheckDlgButton(hDlg, IDC_RADIO_ST0, BST_CHECKED);
00826           SetFocus(hRadioSt0);
00827           break;
00828 
00829         case ST_RADIO1:
00830           CheckDlgButton(hDlg, IDC_RADIO_ST1, BST_CHECKED);
00831           SetFocus(hRadioSt1);
00832           break;
00833 
00834         case ST_RADIO2:
00835           CheckDlgButton(hDlg, IDC_RADIO_ST2, BST_CHECKED);
00836           SetFocus(hRadioSt2);
00837           break;
00838 
00839         case ST_RADIO3:
00840           CheckDlgButton(hDlg, IDC_RADIO_ST3, BST_CHECKED);
00841           SetFocus(hRadioSt3);
00842           break;
00843       }
00844 
00845       RepositionWindow(hDlg, NO_BANNER_IMAGE);
00846 
00847       if((*diSetupType.szReadmeFilename == '\0') || (FileExists(diSetupType.szReadmeFilename) == FALSE))
00848         ShowWindow(hReadme, SW_HIDE);
00849       else
00850         ShowWindow(hReadme, SW_SHOW);
00851 
00852       SetDlgItemText(hDlg, IDC_DESTINATION, sgInstallGui.szDestinationDirectory);
00853       SetDlgItemText(hDlg, IDC_BUTTON_BROWSE, sgInstallGui.szBrowse_);
00854       SetDlgItemText(hDlg, IDWIZBACK, sgInstallGui.szBack_);
00855       SetDlgItemText(hDlg, IDWIZNEXT, sgInstallGui.szNext_);
00856       SetDlgItemText(hDlg, IDCANCEL, sgInstallGui.szCancel_);
00857       SetDlgItemText(hDlg, IDC_README, sgInstallGui.szReadme_);
00858       SendDlgItemMessage (hDlg, IDC_STATIC_MSG0, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00859       SendDlgItemMessage (hDlg, IDC_RADIO_ST0, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00860       SendDlgItemMessage (hDlg, IDC_RADIO_ST1, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00861       SendDlgItemMessage (hDlg, IDC_RADIO_ST2, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00862       SendDlgItemMessage (hDlg, IDC_RADIO_ST3, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00863       SendDlgItemMessage (hDlg, IDC_STATIC_ST0_DESCRIPTION, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00864       SendDlgItemMessage (hDlg, IDC_STATIC_ST1_DESCRIPTION, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00865       SendDlgItemMessage (hDlg, IDC_STATIC_ST2_DESCRIPTION, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00866       SendDlgItemMessage (hDlg, IDC_STATIC_ST3_DESCRIPTION, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00867       SendDlgItemMessage (hDlg, IDC_STATIC, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00868       SendDlgItemMessage (hDlg, IDC_DESTINATION, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00869       SendDlgItemMessage (hDlg, IDC_EDIT_DESTINATION, WM_SETFONT, (WPARAM)sgInstallGui.systemFont, 0L);
00870       SendDlgItemMessage (hDlg, IDC_BUTTON_BROWSE, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00871       SendDlgItemMessage (hDlg, IDWIZBACK, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00872       SendDlgItemMessage (hDlg, IDWIZNEXT, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00873       SendDlgItemMessage (hDlg, IDCANCEL, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00874       SendDlgItemMessage (hDlg, IDC_README, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
00875 
00876       if(sgProduct.bLockPath)
00877         EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_BROWSE), FALSE);
00878       else
00879         EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_BROWSE), TRUE);
00880 
00881       ClosePreviousDialog();
00882       break;
00883 
00884     case WM_COMMAND:
00885       switch(LOWORD(wParam))
00886       {
00887         case IDC_BUTTON_BROWSE:
00888           SaveWindowPosition(hDlg);
00889           if(IsDlgButtonChecked(hDlg, IDC_RADIO_ST0)      == BST_CHECKED)
00890             dwTempSetupType = ST_RADIO0;
00891           else if(IsDlgButtonChecked(hDlg, IDC_RADIO_ST1) == BST_CHECKED)
00892             dwTempSetupType = ST_RADIO1;
00893           else if(IsDlgButtonChecked(hDlg, IDC_RADIO_ST2) == BST_CHECKED)
00894             dwTempSetupType = ST_RADIO2;
00895           else if(IsDlgButtonChecked(hDlg, IDC_RADIO_ST3) == BST_CHECKED)
00896             dwTempSetupType = ST_RADIO3;
00897 
00898           BrowseForDirectory(hDlg, szTempSetupPath);
00899 
00900           hDestinationPath = GetDlgItem(hDlg, IDC_EDIT_DESTINATION); /* handle to the static destination path text window */
00901           TruncateString(hDestinationPath, szTempSetupPath, szBuf, sizeof(szBuf));
00902           SetDlgItemText(hDlg, IDC_EDIT_DESTINATION, szBuf);
00903           break;
00904 
00905         case IDC_README:
00906           if(*diSetupType.szReadmeApp == '\0')
00907             WinSpawn(diSetupType.szReadmeFilename, NULL, szSetupDir, SW_SHOWNORMAL, FALSE);
00908           else
00909             WinSpawn(diSetupType.szReadmeApp, diSetupType.szReadmeFilename, szSetupDir, SW_SHOWNORMAL, FALSE);
00910           break;
00911 
00912         case IDWIZNEXT:
00913           SaveWindowPosition(hDlg);
00914           lstrcpy(sgProduct.szPath, szTempSetupPath);
00915 
00916           /* append a backslash to the path because CreateDirectoriesAll()
00917              uses a backslash to determine directories */
00918           lstrcpy(szBuf, sgProduct.szPath);
00919           AppendBackSlash(szBuf, sizeof(szBuf));
00920 
00921           /* Make sure that the path is not within the windows dir */
00922           if(IsPathWithinWindir(szBuf))
00923           {
00924               char errorMsg[MAX_BUF];
00925               char errorMsgTitle[MAX_BUF];
00926 
00927               GetPrivateProfileString("Messages", "ERROR_PATH_WITHIN_WINDIR",
00928                   "", errorMsg, sizeof(errorMsg), szFileIniInstall);
00929               GetPrivateProfileString("Messages", "ERROR_MESSAGE_TITLE", "",
00930                   errorMsgTitle, sizeof(errorMsgTitle), szFileIniInstall);
00931               MessageBox(hDlg, errorMsg, errorMsgTitle, MB_OK | MB_ICONERROR);
00932               break;
00933           }
00934 
00935           /* Create the path if it does not exist */
00936           if(FileExists(szBuf) == FALSE)
00937           {
00938             char szBuf2[MAX_PATH];
00939 
00940             if(CreateDirectoriesAll(szBuf, ADD_TO_UNINSTALL_LOG) != WIZ_OK)
00941             {
00942               char szECreateDirectory[MAX_BUF];
00943               char szEMessageTitle[MAX_BUF];
00944 
00945               lstrcpy(szBufTemp, "\n\n");
00946               lstrcat(szBufTemp, sgProduct.szPath);
00947               RemoveBackSlash(szBufTemp);
00948               lstrcat(szBufTemp, "\n\n");
00949 
00950               if(GetPrivateProfileString("Messages", "ERROR_CREATE_DIRECTORY", "", szECreateDirectory, sizeof(szECreateDirectory), szFileIniInstall))
00951                 wsprintf(szBuf, szECreateDirectory, szBufTemp);
00952 
00953               GetPrivateProfileString("Messages", "ERROR_MESSAGE_TITLE", "", szEMessageTitle, sizeof(szEMessageTitle), szFileIniInstall);
00954 
00955               MessageBox(hDlg, szBuf, szEMessageTitle, MB_OK | MB_ICONERROR);
00956               break;
00957             }
00958 
00959             if(*sgProduct.szSubPath != '\0')
00960             {
00961                /* log the subpath for uninstallation.  This subpath does not normally get logged
00962                 * for uninstallation due to a chicken and egg problem with creating the log file
00963                 * and the directory its in */
00964               lstrcpy(szBuf2, szBuf);
00965               AppendBackSlash(szBuf2, sizeof(szBuf2));
00966               lstrcat(szBuf2, sgProduct.szSubPath);
00967               UpdateInstallLog(KEY_CREATE_FOLDER, szBuf2, FALSE);
00968             }
00969 
00970             bCreateDestinationDir = TRUE;
00971           }
00972 
00973           /* retrieve and save the state of the selected radio button */
00974           if(IsDlgButtonChecked(hDlg, IDC_RADIO_ST0)      == BST_CHECKED)
00975             dwSetupType     = ST_RADIO0;
00976           else if(IsDlgButtonChecked(hDlg, IDC_RADIO_ST1) == BST_CHECKED)
00977             dwSetupType     = ST_RADIO1;
00978           else if(IsDlgButtonChecked(hDlg, IDC_RADIO_ST2) == BST_CHECKED)
00979             dwSetupType     = ST_RADIO2;
00980           else if(IsDlgButtonChecked(hDlg, IDC_RADIO_ST3) == BST_CHECKED)
00981             dwSetupType     = ST_RADIO3;
00982 
00983           dwTempSetupType = dwSetupType;
00984           SiCNodeSetItemsSelected(dwSetupType);
00985           sgProduct.lastDialog = hDlg;
00986           DlgSequence(NEXT_DLG);
00987           break;
00988 
00989         case IDWIZBACK:
00990           SaveWindowPosition(hDlg);
00991           dwTempSetupType = dwSetupType;
00992           lstrcpy(szTempSetupPath, sgProduct.szPath);
00993           sgProduct.lastDialog = hDlg;
00994           DlgSequence(PREV_DLG);
00995           break;
00996 
00997         case IDCANCEL:
00998           lstrcpy(sgProduct.szPath, szTempSetupPath);
00999           AskCancelDlg(hDlg);
01000           break;
01001 
01002         default:
01003           break;
01004       }
01005       break;
01006   }
01007   return(0);
01008 }
01009 
01010 LRESULT CALLBACK DlgProcUpgrade(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
01011 {
01012   char buf[MAX_BUF];
01013 
01014   switch(msg)
01015   {
01016     case WM_INITDIALOG:
01017       DisableSystemMenuItems(hDlg, FALSE);
01018 
01019       GetPrivateProfileString("Messages", "MB_WARNING_STR", "",
01020           buf, sizeof(buf), szFileIniInstall);
01021       SetWindowText(hDlg, buf);
01022 
01023       GetPrivateProfileString("Strings", "Message Cleanup On Upgrade", "",
01024           buf, sizeof(buf), szFileIniConfig);
01025       ReplacePrivateProfileStrCR(buf);
01026       SetDlgItemText(hDlg, IDC_MESSAGE0, buf);
01027 
01028       GetPrivateProfileString("Strings", "Cleanup On Upgrade Path Box String", "",
01029           buf, sizeof(buf), szFileIniConfig);
01030       SetDlgItemText(hDlg, IDC_STATIC, buf);
01031 
01032       MozCopyStr(sgProduct.szPath, buf, sizeof(buf));
01033       RemoveBackSlash(buf);
01034       SetDlgItemText(hDlg, IDC_DELETE_PATH, buf);
01035 
01036       RepositionWindow(hDlg, NO_BANNER_IMAGE);
01037 
01038       SetDlgItemText(hDlg, IDCONTINUE, sgInstallGui.szContinue_);
01039       SetDlgItemText(hDlg, IDSKIP, sgInstallGui.szSkip_);
01040       SetDlgItemText(hDlg, IDWIZBACK, sgInstallGui.szBack_);
01041       SendDlgItemMessage (hDlg, IDC_STATIC, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
01042       SendDlgItemMessage (hDlg, IDC_MESSAGE0, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
01043       SendDlgItemMessage (hDlg, IDC_DELETE_PATH, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
01044       SendDlgItemMessage (hDlg, IDCONTINUE, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
01045       SendDlgItemMessage (hDlg, IDSKIP, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
01046       SendDlgItemMessage (hDlg, IDWIZBACK, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L); 
01047       ClosePreviousDialog();
01048       break;
01049 
01050     case WM_COMMAND:
01051       switch(LOWORD(wParam))
01052       {
01053         case IDCONTINUE:
01054           /* If the installation path happens to be within the %windir%, then
01055            * show error message and continue without removing the previous
01056            * installation path. */
01057           if(IsPathWithinWindir(sgProduct.szPath))
01058           {
01059             GetPrivateProfileString("Strings", "Message Cleanup On Upgrade Windir", "",
01060                 buf, sizeof(buf), szFileIniConfig);
01061             MessageBox(hWndMain, buf, NULL, MB_ICONEXCLAMATION);
01062           }
01063           else
01064             /* set the var to delete target path here */
01065             sgProduct.doCleanupOnUpgrade = TRUE;
01066 
01067           SiCNodeSetItemsSelected(dwSetupType);
01068           SaveWindowPosition(hDlg);
01069           sgProduct.lastDialog = hDlg;
01070           DlgSequence(NEXT_DLG);
01071           break;
01072 
01073         case IDSKIP:
01074           sgProduct.doCleanupOnUpgrade = FALSE;
01075           SiCNodeSetItemsSelected(dwSetupType);
01076           SaveWindowPosition(hDlg);
01077           sgProduct.lastDialog = hDlg;
01078           DlgSequence(NEXT_DLG);
01079           break;
01080 
01081         case IDWIZBACK:
01082           SaveWindowPosition(hDlg);
01083           sgProduct.lastDialog = hDlg;
01084           DlgSequence(PREV_DLG);
01085           break;
01086 
01087         default:
01088           break;
01089       }
01090       break;
01091   }
01092   return(0);
01093 }
01094 
01095 void DrawLBText(LPDRAWITEMSTRUCT lpdis, DWORD dwACFlag)
01096 {
01097   siC     *siCTemp  = NULL;
01098   TCHAR   tchBuffer[MAX_BUF];
01099   TEXTMETRIC tm;
01100   DWORD      y;
01101 
01102   siCTemp = SiCNodeGetObject(lpdis->itemID, FALSE, dwACFlag);
01103   if(siCTemp != NULL)
01104   {
01105     SendMessage(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, (LPARAM)tchBuffer);
01106 
01107     if((lpdis->itemAction & ODA_FOCUS) && (lpdis->itemState & ODS_SELECTED))
01108     {
01109       // remove the focus rect on the previous selected item
01110       DrawFocusRect(lpdis->hDC, &(lpdis->rcItem));
01111     }
01112 
01113     siCTemp = SiCNodeGetObject(lpdis->itemID, FALSE, dwACFlag);
01114     if(lpdis->itemAction & ODA_FOCUS)
01115     {
01116       if((lpdis->itemState & ODS_SELECTED) &&
01117         !(lpdis->itemState & ODS_FOCUS))
01118       {
01119         if(siCTemp->dwAttributes & SIC_DISABLED)
01120           SetTextColor(lpdis->hDC,        GetSysColor(COLOR_GRAYTEXT));
01121         else
01122         {
01123           SetTextColor(lpdis->hDC,        GetSysColor(COLOR_WINDOWTEXT));
01124           SetBkColor(lpdis->hDC,          GetSysColor(COLOR_WINDOW));
01125         }
01126       }
01127       else
01128       {
01129         if(siCTemp->dwAttributes & SIC_DISABLED)
01130           SetTextColor(lpdis->hDC,        GetSysColor(COLOR_GRAYTEXT));
01131         else
01132         {
01133           SetTextColor(lpdis->hDC,        GetSysColor(COLOR_HIGHLIGHTTEXT));
01134           SetBkColor(lpdis->hDC,          GetSysColor(COLOR_HIGHLIGHT));
01135         }
01136       }
01137     }
01138     else if(lpdis->itemAction & ODA_DRAWENTIRE)
01139     {
01140       if(siCTemp->dwAttributes & SIC_DISABLED)
01141         SetTextColor(lpdis->hDC, GetSysColor(COLOR_GRAYTEXT));
01142       else
01143         SetTextColor(lpdis->hDC, GetSysColor(COLOR_WINDOWTEXT));
01144     }
01145 
01146     // If a screen reader is being used we want to redraw the text whether
01147     //   it has focus or not because the text changes whenever the checkbox
01148     //   changes.
01149     if( gSystemInfo.bScreenReader || (lpdis->itemAction & (ODA_DRAWENTIRE | ODA_FOCUS)) )
01150     {
01151       // Display the text associated with the item.
01152       GetTextMetrics(lpdis->hDC, &tm);
01153       y = (lpdis->rcItem.bottom + lpdis->rcItem.top - tm.tmHeight) / 2;
01154 
01155       ExtTextOut(lpdis->hDC,
01156                  CX_CHECKBOX + 5,
01157                  y,
01158                  ETO_OPAQUE | ETO_CLIPPED,
01159                  &(lpdis->rcItem),
01160                  tchBuffer,
01161                  strlen(tchBuffer),
01162                  NULL);
01163     }
01164   }
01165 }
01166 
01167 void DrawCheck(LPDRAWITEMSTRUCT lpdis, DWORD dwACFlag)
01168 {
01169   siC     *siCTemp  = NULL;
01170   HDC     hdcMem;
01171   HBITMAP hbmpCheckBox;
01172 
01173   siCTemp = SiCNodeGetObject(lpdis->itemID, FALSE, dwACFlag);
01174   if(siCTemp != NULL)
01175   {
01176     if(!(siCTemp->dwAttributes & SIC_SELECTED))
01177       /* Component is not selected.  Use the unchecked bitmap regardless if the 
01178        * component is disabled or not.  The unchecked bitmap looks the same if
01179        * it's disabled or enabled. */
01180       hbmpCheckBox = hbmpBoxUnChecked;
01181     else if(siCTemp->dwAttributes & SIC_DISABLED)
01182       /* Component is checked and disabled */
01183       hbmpCheckBox = hbmpBoxCheckedDisabled;
01184     else
01185       /* Component is checked and enabled */
01186       hbmpCheckBox = hbmpBoxChecked;
01187 
01188     SendMessage(lpdis->hwndItem, LB_SETITEMDATA, lpdis->itemID, (LPARAM)hbmpCheckBox);
01189     if((hdcMem = CreateCompatibleDC(lpdis->hDC)) != NULL)
01190     {
01191       SelectObject(hdcMem, hbmpCheckBox);
01192 
01193       // BitBlt() is used to prepare the checkbox icon into the list box item's device context.
01194       // The SendMessage() function using LB_SETITEMDATA performs the drawing.
01195       BitBlt(lpdis->hDC,
01196              lpdis->rcItem.left + 2,
01197              lpdis->rcItem.top + 2,
01198              lpdis->rcItem.right - lpdis->rcItem.left,
01199              lpdis->rcItem.bottom - lpdis->rcItem.top,
01200              hdcMem,
01201              0,
01202              0,
01203              SRCCOPY);
01204 
01205       DeleteDC(hdcMem);
01206     }
01207   }
01208 }
01209 
01210 void lbAddItem(HWND hList, siC *siCComponent)
01211 {
01212   DWORD dwItem;
01213   TCHAR tchBuffer[MAX_BUF];
01214 
01215   lstrcpy(tchBuffer, siCComponent->szDescriptionShort);
01216   if(gSystemInfo.bScreenReader)
01217   {
01218     lstrcat(tchBuffer, " - ");
01219     if(!(siCComponent->dwAttributes & SIC_SELECTED))
01220       lstrcat(tchBuffer, sgInstallGui.szUnchecked);
01221     else
01222       lstrcat(tchBuffer, sgInstallGui.szChecked);
01223   }
01224   dwItem = SendMessage(hList, LB_ADDSTRING, 0, (LPARAM)tchBuffer);
01225 
01226   if(siCComponent->dwAttributes & SIC_DISABLED)
01227     SendMessage(hList, LB_SETITEMDATA, dwItem, (LPARAM)hbmpBoxCheckedDisabled);
01228   else if(siCComponent->dwAttributes & SIC_SELECTED)
01229     SendMessage(hList, LB_SETITEMDATA, dwItem, (LPARAM)hbmpBoxChecked);
01230   else
01231     SendMessage(hList, LB_SETITEMDATA, dwItem, (LPARAM)hbmpBoxUnChecked);
01232 } 
01233 
01234 void InvalidateLBCheckbox(HWND hwndListBox)
01235 {
01236   RECT rcCheckArea;
01237 
01238   // retrieve the rectangle of all list items to update.
01239   GetClientRect(hwndListBox, &rcCheckArea);
01240 
01241   // Set the right coordinate of the rectangle to be the same
01242   //   as the right edge of the bitmap drawn.
01243   // But if a screen reader is being used we want to redraw the text
01244   //   as well as the checkbox so we do not set the right coordinate.
01245   if(!gSystemInfo.bScreenReader)
01246     rcCheckArea.right = CX_CHECKBOX;
01247 
01248   // It then invalidates the checkbox region to be redrawn.
01249   // Invalidating the region sends a WM_DRAWITEM message to
01250   // the dialog, which redraws the region given the
01251   // node attirbute, in this case it is a bitmap of a
01252   // checked/unchecked checkbox.
01253   InvalidateRect(hwndListBox, &rcCheckArea, TRUE);
01254 }
01255   
01256 void ToggleCheck(HWND hwndListBox, DWORD dwIndex, DWORD dwACFlag)
01257 {
01258   BOOL  bMoreToResolve;
01259   LPSTR szToggledReferenceName = NULL;
01260   DWORD dwAttributes;
01261 
01262   // Checks to see if the checkbox is checked or not checked, and
01263   // toggles the node attributes appropriately.
01264   dwAttributes = SiCNodeGetAttributes(dwIndex, FALSE, dwACFlag);
01265   if(!(dwAttributes & SIC_DISABLED))
01266   {
01267     if(dwAttributes & SIC_SELECTED)
01268     {
01269       SiCNodeSetAttributes(dwIndex, SIC_SELECTED, FALSE, FALSE, dwACFlag, hwndListBox);
01270 
01271       szToggledReferenceName = SiCNodeGetReferenceName(dwIndex, FALSE, dwACFlag);
01272       ResolveDependees(szToggledReferenceName, hwndListBox);
01273     }
01274     else
01275     {
01276       SiCNodeSetAttributes(dwIndex, SIC_SELECTED, TRUE, FALSE, dwACFlag, hwndListBox);
01277       bMoreToResolve = ResolveDependencies(dwIndex, hwndListBox);
01278 
01279       while(bMoreToResolve)
01280         bMoreToResolve = ResolveDependencies(-1, hwndListBox);
01281 
01282       szToggledReferenceName = SiCNodeGetReferenceName(dwIndex, FALSE, dwACFlag);
01283       ResolveDependees(szToggledReferenceName, hwndListBox);
01284     }
01285 
01286     InvalidateLBCheckbox(hwndListBox);
01287   }
01288 }
01289 
01290 // ************************************************************************
01291 // FUNCTION : SubclassWindow( HWND, WNDPROC )
01292 // PURPOSE  : Subclasses a window procedure
01293 // COMMENTS : Returns the old window procedure
01294 // ************************************************************************
01295 WNDPROC SubclassWindow( HWND hWnd, WNDPROC NewWndProc)
01296 {
01297   WNDPROC OldWndProc;
01298 
01299   OldWndProc = (WNDPROC)GetWindowLong(hWnd, GWL_WNDPROC);
01300   SetWindowLong(hWnd, GWL_WNDPROC, (LONG) NewWndProc);
01301 
01302   return OldWndProc;
01303 }
01304 
01305 // ************************************************************************
01306 // FUNCTION : NewListBoxWndProc( HWND, UINT, WPARAM, LPARAM )
01307 // PURPOSE  : Processes messages for "LISTBOX" class.
01308 // COMMENTS : Prevents the user from moving the window
01309 //            by dragging the titlebar.
01310 // ************************************************************************
01311 LRESULT CALLBACK NewListBoxWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
01312 {
01313   DWORD   dwPosX;
01314   DWORD   dwPosY;
01315   DWORD   dwIndex;
01316   
01317   switch(uMsg)
01318   {
01319     case WM_CHAR:
01320       /* check for the space key */
01321       if((TCHAR)wParam == 32)
01322       {
01323         dwIndex = SendMessage(hWnd,
01324                               LB_GETCURSEL,
01325                               0,
01326                               0);
01327         ToggleCheck(hWnd, dwIndex, gdwACFlag);
01328       }
01329       break;
01330 
01331     case WM_LBUTTONDOWN:
01332       if(wParam == MK_LBUTTON)
01333       {
01334         dwPosX = LOWORD(lParam); // x pos
01335         dwPosY = HIWORD(lParam); // y pos
01336 
01337         if((dwPosX > 1) && (dwPosX <= CX_CHECKBOX))
01338         {
01339           dwIndex = LOWORD(SendMessage(hWnd,
01340                                        LB_ITEMFROMPOINT,
01341                                        0,
01342                                        (LPARAM)MAKELPARAM(dwPosX, dwPosY)));
01343           ToggleCheck(hWnd, dwIndex, gdwACFlag);
01344         }
01345       }
01346       break;
01347   }
01348 
01349   return(CallWindowProc(OldListBoxWndProc, hWnd, uMsg, wParam, lParam));
01350 }
01351 
01352 LRESULT CALLBACK DlgProcSelectComponents(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
01353 {
01354   BOOL                bReturn = FALSE;
01355   siC                 *siCTemp;
01356   DWORD               dwIndex;
01357   DWORD               dwItems = MAX_BUF;
01358   HWND                hwndLBComponents;
01359   TCHAR               tchBuffer[MAX_BUF];
01360   LPDRAWITEMSTRUCT    lpdis;
01361   ULONGLONG           ullDSBuf;
01362   char                szBuf[MAX_BUF];
01363 
01364   hwndLBComponents = GetDlgItem(hDlg, IDC_LIST_COMPONENTS);
01365 
01366   switch(msg)
01367   {
01368     case WM_INITDIALOG:
01369       DisableSystemMenuItems(hDlg, FALSE);
01370       SetWindowText(hDlg, diSelectComponents.szTitle);
01371       SetDlgItemText(hDlg, IDC_MESSAGE0, diSelectComponents.szMessage0);
01372 
01373       siCTemp = siComponents;
01374       if(siCTemp != NULL)
01375       {
01376         if((!(siCTemp->dwAttributes & SIC_INVISIBLE)) && (!(siCTemp->dwAttributes & SIC_ADDITIONAL)))
01377           lbAddItem(hwndLBComponents, siCTemp);
01378 
01379         siCTemp = siCTemp->Next;
01380         while((siCTemp != siComponents) && (siCTemp != NULL))
01381         {
01382           if((!(siCTemp->dwAttributes & SIC_INVISIBLE)) && (!(siCTemp->dwAttributes & SIC_ADDITIONAL)))
01383             lbAddItem(hwndLBComponents, siCTemp);
01384 
01385           siCTemp = siCTemp->Next;
01386         }
01387         SetFocus(hwndLBComponents);
01388         SendMessage(hwndLBComponents, LB_SETCURSEL, 0, 0);
01389         SetDlgItemText(hDlg, IDC_STATIC_DESCRIPTION, SiCNodeGetDescriptionLong(0, FALSE, AC_COMPONENTS));
01390       }
01391 
01392       RepositionWindow(hDlg, NO_BANNER_IMAGE);
01393 
01394       /* update the disk space available info in the dialog.  GetDiskSpaceAvailable()
01395          returns value in kbytes */
01396       ullDSBuf = GetDiskSpaceAvailable(sgProduct.szPath);
01397       _ui64toa(ullDSBuf, tchBuffer, 10);
01398       ParsePath(sgProduct.szPath, szBuf, sizeof(szBuf), FALSE, PP_ROOT_ONLY);
01399       RemoveBackSlash(szBuf);
01400       lstrcat(szBuf, "   ");
01401       lstrcat(szBuf, tchBuffer);
01402       lstrcat(szBuf, " KB");
01403       SetDlgItemText(hDlg, IDC_SPACE_AVAILABLE, szBuf);
01404 
01405       SetDlgItemText(hDlg, IDC_STATIC1, sgInstallGui.szComponents_);
01406       SetDlgItemText(hDlg, IDC_STATIC2, sgInstallGui.szDescription);
01407       SetDlgItemText(hDlg, IDC_STATIC3, sgInstallGui.szTotalDownloadSize);
01408       SetDlgItemText(hDlg, IDC_STATIC4, sgInstallGui.szSpaceAvailable);
01409       SetDlgItemText(hDlg, IDWIZBACK, sgInstallGui.szBack_);
01410       SetDlgItemText(hDlg, IDWIZNEXT, sgInstallGui.szNext_);
01411       SetDlgItemText(hDlg, IDCANCEL, sgInstallGui.szCancel_);
01412       SendDlgItemMessage (hDlg, IDC_STATIC1, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01413       SendDlgItemMessage (hDlg, IDC_STATIC2, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01414       SendDlgItemMessage (hDlg, IDC_STATIC3, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01415       SendDlgItemMessage (hDlg, IDC_STATIC4, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01416       SendDlgItemMessage (hDlg, IDWIZBACK, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01417       SendDlgItemMessage (hDlg, IDWIZNEXT, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01418       SendDlgItemMessage (hDlg, IDCANCEL, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01419       SendDlgItemMessage (hDlg, IDC_MESSAGE0, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01420       SendDlgItemMessage (hDlg, IDC_LIST_COMPONENTS, WM_SETFONT, (WPARAM)sgInstallGui.systemFont, 0L);
01421       SendDlgItemMessage (hDlg, IDC_STATIC_DESCRIPTION, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01422       SendDlgItemMessage (hDlg, IDC_DOWNLOAD_SIZE, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01423       SendDlgItemMessage (hDlg, IDC_SPACE_AVAILABLE, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01424 
01425       gdwACFlag = AC_COMPONENTS;
01426       OldListBoxWndProc = SubclassWindow(hwndLBComponents, (WNDPROC)NewListBoxWndProc);
01427       ClosePreviousDialog();
01428       break;
01429 
01430     case WM_DRAWITEM:
01431       lpdis = (LPDRAWITEMSTRUCT)lParam;
01432 
01433       // If there are no list box items, skip this message.
01434       if(lpdis->itemID == -1)
01435         break;
01436 
01437       DrawLBText(lpdis, AC_COMPONENTS);
01438       DrawCheck(lpdis, AC_COMPONENTS);
01439 
01440       // draw the focus rect on the selected item
01441       if((lpdis->itemAction & ODA_FOCUS) &&
01442          (lpdis->itemState & ODS_FOCUS))
01443       {
01444         DrawFocusRect(lpdis->hDC, &(lpdis->rcItem));
01445       }
01446 
01447       bReturn = TRUE;
01448 
01449       /* update the disk space required info in the dialog.  It is already
01450          in Kilobytes */
01451       ullDSBuf = GetDiskSpaceRequired(DSR_DOWNLOAD_SIZE);
01452       _ui64toa(ullDSBuf, tchBuffer, 10);
01453       lstrcpy(szBuf, tchBuffer);
01454       lstrcat(szBuf, " KB");
01455       
01456       SetDlgItemText(hDlg, IDC_DOWNLOAD_SIZE, szBuf);
01457       break;
01458 
01459     case WM_COMMAND:
01460       switch(LOWORD(wParam))
01461       {
01462         case IDC_LIST_COMPONENTS:
01463           /* to update the long description for each component the user selected */
01464           if((dwIndex = SendMessage(hwndLBComponents, LB_GETCURSEL, 0, 0)) != LB_ERR)
01465             SetDlgItemText(hDlg, IDC_STATIC_DESCRIPTION, SiCNodeGetDescriptionLong(dwIndex, FALSE, AC_COMPONENTS));
01466           break;
01467 
01468         case IDWIZNEXT:
01469           SaveWindowPosition(hDlg);
01470           sgProduct.lastDialog = hDlg;
01471           UnSubclassWindow(hwndLBComponents, &OldListBoxWndProc);
01472           DlgSequence(NEXT_DLG);
01473           break;
01474 
01475         case IDWIZBACK:
01476           SaveWindowPosition(hDlg);
01477           sgProduct.lastDialog = hDlg;
01478           UnSubclassWindow(hwndLBComponents, &OldListBoxWndProc);
01479           DlgSequence(PREV_DLG);
01480           break;
01481 
01482         case IDCANCEL:
01483           // AskCancelDlg() will return TRUE if the user
01484           // chose to really cancel
01485           if(AskCancelDlg(hDlg))
01486             UnSubclassWindow(hwndLBComponents, &OldListBoxWndProc);
01487           break;
01488 
01489         default:
01490           break;
01491       }
01492       break;
01493   }
01494 
01495   return(bReturn);
01496 }
01497 
01498 LRESULT CALLBACK DlgProcSelectAdditionalComponents(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
01499 {
01500   BOOL                bReturn = FALSE;
01501   siC                 *siCTemp;
01502   DWORD               dwIndex;
01503   DWORD               dwItems = MAX_BUF;
01504   HWND                hwndLBComponents;
01505   TCHAR               tchBuffer[MAX_BUF];
01506   LPDRAWITEMSTRUCT    lpdis;
01507   ULONGLONG           ullDSBuf;
01508   char                szBuf[MAX_BUF];
01509 
01510   hwndLBComponents = GetDlgItem(hDlg, IDC_LIST_COMPONENTS);
01511 
01512   switch(msg)
01513   {
01514     case WM_INITDIALOG:
01515       DisableSystemMenuItems(hDlg, FALSE);
01516       SetWindowText(hDlg, diSelectAdditionalComponents.szTitle);
01517       SetDlgItemText(hDlg, IDC_MESSAGE0, diSelectAdditionalComponents.szMessage0);
01518 
01519       siCTemp = siComponents;
01520       if(siCTemp != NULL)
01521       {
01522         if((!(siCTemp->dwAttributes & SIC_INVISIBLE)) && (siCTemp->dwAttributes & SIC_ADDITIONAL))
01523           lbAddItem(hwndLBComponents, siCTemp);
01524 
01525         siCTemp = siCTemp->Next;
01526         while((siCTemp != siComponents) && (siCTemp != NULL))
01527         {
01528           if((!(siCTemp->dwAttributes & SIC_INVISIBLE)) && (siCTemp->dwAttributes & SIC_ADDITIONAL))
01529             lbAddItem(hwndLBComponents, siCTemp);
01530 
01531           siCTemp = siCTemp->Next;
01532         }
01533         SetFocus(hwndLBComponents);
01534         SendMessage(hwndLBComponents, LB_SETCURSEL, 0, 0);
01535         SetDlgItemText(hDlg, IDC_STATIC_DESCRIPTION, SiCNodeGetDescriptionLong(0, FALSE, AC_ADDITIONAL_COMPONENTS));
01536       }
01537 
01538       RepositionWindow(hDlg, NO_BANNER_IMAGE);
01539 
01540       /* update the disk space available info in the dialog.  GetDiskSpaceAvailable()
01541          returns value in kbytes */
01542       ullDSBuf = GetDiskSpaceAvailable(sgProduct.szPath);
01543       _ui64toa(ullDSBuf, tchBuffer, 10);
01544       ParsePath(sgProduct.szPath, szBuf, sizeof(szBuf), FALSE, PP_ROOT_ONLY);
01545       RemoveBackSlash(szBuf);
01546       lstrcat(szBuf, "   ");
01547       lstrcat(szBuf, tchBuffer);
01548       lstrcat(szBuf, " KB");
01549       SetDlgItemText(hDlg, IDC_SPACE_AVAILABLE, szBuf);
01550 
01551       SetDlgItemText(hDlg, IDC_STATIC1, sgInstallGui.szAdditionalComponents_);
01552       SetDlgItemText(hDlg, IDC_STATIC2, sgInstallGui.szDescription);
01553       SetDlgItemText(hDlg, IDC_STATIC3, sgInstallGui.szTotalDownloadSize);
01554       SetDlgItemText(hDlg, IDC_STATIC4, sgInstallGui.szSpaceAvailable);
01555       SetDlgItemText(hDlg, IDWIZBACK, sgInstallGui.szBack_);
01556       SetDlgItemText(hDlg, IDWIZNEXT, sgInstallGui.szNext_);
01557       SetDlgItemText(hDlg, IDCANCEL, sgInstallGui.szCancel_);
01558       SendDlgItemMessage (hDlg, IDC_STATIC1, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01559       SendDlgItemMessage (hDlg, IDC_STATIC2, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01560       SendDlgItemMessage (hDlg, IDC_STATIC3, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01561       SendDlgItemMessage (hDlg, IDC_STATIC4, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01562       SendDlgItemMessage (hDlg, IDWIZBACK, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01563       SendDlgItemMessage (hDlg, IDWIZNEXT, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01564       SendDlgItemMessage (hDlg, IDCANCEL, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01565       SendDlgItemMessage (hDlg, IDC_MESSAGE0, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01566       SendDlgItemMessage (hDlg, IDC_LIST_COMPONENTS, WM_SETFONT, (WPARAM)sgInstallGui.systemFont, 0L);
01567       SendDlgItemMessage (hDlg, IDC_STATIC_DESCRIPTION, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01568       SendDlgItemMessage (hDlg, IDC_DOWNLOAD_SIZE, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01569       SendDlgItemMessage (hDlg, IDC_SPACE_AVAILABLE, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01570 
01571       gdwACFlag = AC_ADDITIONAL_COMPONENTS;
01572       OldListBoxWndProc = SubclassWindow(hwndLBComponents, (WNDPROC)NewListBoxWndProc);
01573       ClosePreviousDialog();
01574       break;
01575 
01576     case WM_DRAWITEM:
01577       lpdis = (LPDRAWITEMSTRUCT)lParam;
01578 
01579       // If there are no list box items, skip this message.
01580       if(lpdis->itemID == -1)
01581         break;
01582 
01583       DrawLBText(lpdis, AC_ADDITIONAL_COMPONENTS);
01584       DrawCheck(lpdis, AC_ADDITIONAL_COMPONENTS);
01585 
01586       // draw the focus rect on the selected item
01587       if((lpdis->itemAction & ODA_FOCUS) &&
01588          (lpdis->itemState & ODS_FOCUS))
01589       {
01590         DrawFocusRect(lpdis->hDC, &(lpdis->rcItem));
01591       }
01592 
01593       bReturn = TRUE;
01594 
01595       /* update the disk space required info in the dialog.  It is already
01596          in Kilobytes */
01597       ullDSBuf = GetDiskSpaceRequired(DSR_DOWNLOAD_SIZE);
01598       _ui64toa(ullDSBuf, tchBuffer, 10);
01599       lstrcpy(szBuf, tchBuffer);
01600       lstrcat(szBuf, " KB");
01601       
01602       SetDlgItemText(hDlg, IDC_DOWNLOAD_SIZE, szBuf);
01603       break;
01604 
01605     case WM_COMMAND:
01606       switch(LOWORD(wParam))
01607       {
01608         case IDC_LIST_COMPONENTS:
01609           /* to update the long description for each component the user selected */
01610           if((dwIndex = SendMessage(hwndLBComponents, LB_GETCURSEL, 0, 0)) != LB_ERR)
01611             SetDlgItemText(hDlg, IDC_STATIC_DESCRIPTION, SiCNodeGetDescriptionLong(dwIndex, FALSE, AC_ADDITIONAL_COMPONENTS));
01612           break;
01613 
01614         case IDWIZNEXT:
01615           SaveWindowPosition(hDlg);
01616           sgProduct.lastDialog = hDlg;
01617           UnSubclassWindow(hwndLBComponents, &OldListBoxWndProc);
01618           DlgSequence(NEXT_DLG);
01619           break;
01620 
01621         case IDWIZBACK:
01622           SaveWindowPosition(hDlg);
01623           sgProduct.lastDialog = hDlg;
01624           UnSubclassWindow(hwndLBComponents, &OldListBoxWndProc);
01625           DlgSequence(PREV_DLG);
01626           break;
01627 
01628         case IDCANCEL:
01629           // AskCancelDlg() will return TRUE if the user
01630           // chose to really cancel
01631           if(AskCancelDlg(hDlg))
01632             UnSubclassWindow(hwndLBComponents, &OldListBoxWndProc);
01633           break;
01634 
01635         default:
01636           break;
01637       }
01638       break;
01639   }
01640 
01641   return(bReturn);
01642 }
01643 
01644 LRESULT CALLBACK DlgProcWindowsIntegration(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
01645 {
01646   HWND hcbCheck0;
01647   HWND hcbCheck1;
01648   HWND hcbCheck2;
01649   HWND hcbCheck3;
01650 
01651   hcbCheck0 = GetDlgItem(hDlg, IDC_CHECK0);
01652   hcbCheck1 = GetDlgItem(hDlg, IDC_CHECK1);
01653   hcbCheck2 = GetDlgItem(hDlg, IDC_CHECK2);
01654   hcbCheck3 = GetDlgItem(hDlg, IDC_CHECK3);
01655 
01656   switch(msg)
01657   {
01658     case WM_INITDIALOG:
01659       DisableSystemMenuItems(hDlg, FALSE);
01660       SetWindowText(hDlg, diWindowsIntegration.szTitle);
01661       SetDlgItemText(hDlg, IDC_MESSAGE0, diWindowsIntegration.szMessage0);
01662       SetDlgItemText(hDlg, IDC_MESSAGE1, diWindowsIntegration.szMessage1);
01663 
01664       if(diWindowsIntegration.wiCB0.bEnabled)
01665       {
01666         ShowWindow(hcbCheck0, SW_SHOW);
01667         CheckDlgButton(hDlg, IDC_CHECK0, diWindowsIntegration.wiCB0.bCheckBoxState);
01668         SetDlgItemText(hDlg, IDC_CHECK0, diWindowsIntegration.wiCB0.szDescription);
01669       }
01670       else
01671         ShowWindow(hcbCheck0, SW_HIDE);
01672 
01673       if(diWindowsIntegration.wiCB1.bEnabled)
01674       {
01675         ShowWindow(hcbCheck1, SW_SHOW);
01676         CheckDlgButton(hDlg, IDC_CHECK1, diWindowsIntegration.wiCB1.bCheckBoxState);
01677         SetDlgItemText(hDlg, IDC_CHECK1, diWindowsIntegration.wiCB1.szDescription);
01678       }
01679       else
01680         ShowWindow(hcbCheck1, SW_HIDE);
01681 
01682       if(diWindowsIntegration.wiCB2.bEnabled)
01683       {
01684         ShowWindow(hcbCheck2, SW_SHOW);
01685         CheckDlgButton(hDlg, IDC_CHECK2, diWindowsIntegration.wiCB2.bCheckBoxState);
01686         SetDlgItemText(hDlg, IDC_CHECK2, diWindowsIntegration.wiCB2.szDescription);
01687       }
01688       else
01689         ShowWindow(hcbCheck2, SW_HIDE);
01690 
01691       if(diWindowsIntegration.wiCB3.bEnabled)
01692       {
01693         ShowWindow(hcbCheck3, SW_SHOW);
01694         CheckDlgButton(hDlg, IDC_CHECK3, diWindowsIntegration.wiCB3.bCheckBoxState);
01695         SetDlgItemText(hDlg, IDC_CHECK3, diWindowsIntegration.wiCB3.szDescription);
01696       }
01697       else
01698         ShowWindow(hcbCheck3, SW_HIDE);
01699 
01700       RepositionWindow(hDlg, NO_BANNER_IMAGE);
01701 
01702       SetDlgItemText(hDlg, IDWIZBACK, sgInstallGui.szBack_);
01703       SetDlgItemText(hDlg, IDWIZNEXT, sgInstallGui.szNext_);
01704       SetDlgItemText(hDlg, IDCANCEL, sgInstallGui.szCancel_);
01705       SendDlgItemMessage (hDlg, IDWIZBACK, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01706       SendDlgItemMessage (hDlg, IDWIZNEXT, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01707       SendDlgItemMessage (hDlg, IDCANCEL, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01708       SendDlgItemMessage (hDlg, IDC_MESSAGE0, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01709       SendDlgItemMessage (hDlg, IDC_CHECK0, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01710       SendDlgItemMessage (hDlg, IDC_CHECK1, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01711       SendDlgItemMessage (hDlg, IDC_CHECK2, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01712       SendDlgItemMessage (hDlg, IDC_CHECK3, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01713       SendDlgItemMessage (hDlg, IDC_MESSAGE1, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01714       ClosePreviousDialog();
01715       break;
01716 
01717     case WM_COMMAND:
01718       switch(LOWORD(wParam))
01719       {
01720         case IDWIZNEXT:
01721           SaveWindowPosition(hDlg);
01722           if(IsDlgButtonChecked(hDlg, IDC_CHECK0) == BST_CHECKED)
01723           {
01724           }
01725 
01726           if(diWindowsIntegration.wiCB0.bEnabled)
01727           {
01728             if(IsDlgButtonChecked(hDlg, IDC_CHECK0) == BST_CHECKED)
01729               diWindowsIntegration.wiCB0.bCheckBoxState = TRUE;
01730             else
01731               diWindowsIntegration.wiCB0.bCheckBoxState = FALSE;
01732           }
01733 
01734           if(diWindowsIntegration.wiCB1.bEnabled)
01735           {
01736             if(IsDlgButtonChecked(hDlg, IDC_CHECK1) == BST_CHECKED)
01737               diWindowsIntegration.wiCB1.bCheckBoxState = TRUE;
01738             else
01739               diWindowsIntegration.wiCB1.bCheckBoxState = FALSE;
01740           }
01741 
01742           if(diWindowsIntegration.wiCB2.bEnabled)
01743           {
01744             if(IsDlgButtonChecked(hDlg, IDC_CHECK2) == BST_CHECKED)
01745               diWindowsIntegration.wiCB2.bCheckBoxState = TRUE;
01746             else
01747               diWindowsIntegration.wiCB2.bCheckBoxState = FALSE;
01748           }
01749 
01750           if(diWindowsIntegration.wiCB3.bEnabled)
01751           {
01752             if(IsDlgButtonChecked(hDlg, IDC_CHECK3) == BST_CHECKED)
01753               diWindowsIntegration.wiCB3.bCheckBoxState = TRUE;
01754             else
01755               diWindowsIntegration.wiCB3.bCheckBoxState = FALSE;
01756           }
01757 
01758           sgProduct.lastDialog = hDlg;
01759           DlgSequence(NEXT_DLG);
01760           break;
01761 
01762         case IDWIZBACK:
01763           SaveWindowPosition(hDlg);
01764           sgProduct.lastDialog = hDlg;
01765           DlgSequence(PREV_DLG);
01766           break;
01767 
01768         case IDCANCEL:
01769           AskCancelDlg(hDlg);
01770           break;
01771 
01772         default:
01773           break;
01774       }
01775       break;
01776   }
01777   return(0);
01778 }
01779 
01780 LRESULT CALLBACK DlgProcProgramFolder(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
01781 {
01782   char            szBuf[MAX_BUF];
01783   HANDLE          hDir;
01784   DWORD           dwIndex;
01785   WIN32_FIND_DATA wfdFindFileData;
01786 
01787   switch(msg)
01788   {
01789     case WM_INITDIALOG:
01790       DisableSystemMenuItems(hDlg, FALSE);
01791       SetWindowText(hDlg, diProgramFolder.szTitle);
01792       SetDlgItemText(hDlg, IDC_MESSAGE0, diProgramFolder.szMessage0);
01793       SetDlgItemText(hDlg, IDC_EDIT_PROGRAM_FOLDER, sgProduct.szProgramFolderName);
01794 
01795       lstrcpy(szBuf, sgProduct.szProgramFolderPath);
01796       lstrcat(szBuf, "\\*.*");
01797       if((hDir = FindFirstFile(szBuf , &wfdFindFileData)) != INVALID_HANDLE_VALUE)
01798       {
01799         if((wfdFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (lstrcmpi(wfdFindFileData.cFileName, ".") != 0) && (lstrcmpi(wfdFindFileData.cFileName, "..") != 0))
01800         {
01801           SendDlgItemMessage(hDlg, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)wfdFindFileData.cFileName);
01802         }
01803 
01804         while(FindNextFile(hDir, &wfdFindFileData))
01805         {
01806           if((wfdFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (lstrcmpi(wfdFindFileData.cFileName, ".") != 0) && (lstrcmpi(wfdFindFileData.cFileName, "..") != 0))
01807             SendDlgItemMessage(hDlg, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)wfdFindFileData.cFileName);
01808         }
01809         FindClose(hDir);
01810       }
01811 
01812       RepositionWindow(hDlg, NO_BANNER_IMAGE);
01813 
01814       SetDlgItemText(hDlg, IDC_STATIC1, sgInstallGui.szProgramFolder_);
01815       SetDlgItemText(hDlg, IDC_STATIC2, sgInstallGui.szExistingFolder_);
01816       SetDlgItemText(hDlg, IDWIZBACK, sgInstallGui.szBack_);
01817       SetDlgItemText(hDlg, IDWIZNEXT, sgInstallGui.szNext_);
01818       SetDlgItemText(hDlg, IDCANCEL, sgInstallGui.szCancel_);
01819       SendDlgItemMessage (hDlg, IDC_STATIC1, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01820       SendDlgItemMessage (hDlg, IDC_STATIC2, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01821       SendDlgItemMessage (hDlg, IDWIZBACK, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01822       SendDlgItemMessage (hDlg, IDWIZNEXT, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01823       SendDlgItemMessage (hDlg, IDCANCEL, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01824       SendDlgItemMessage (hDlg, IDC_MESSAGE0, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01825       SendDlgItemMessage (hDlg, IDC_EDIT_PROGRAM_FOLDER, WM_SETFONT, (WPARAM)sgInstallGui.systemFont, 0L);
01826       SendDlgItemMessage (hDlg, IDC_LIST, WM_SETFONT, (WPARAM)sgInstallGui.systemFont, 0L);
01827       ClosePreviousDialog();
01828       break;
01829 
01830     case WM_COMMAND:
01831       switch(LOWORD(wParam))
01832       {
01833         case IDWIZNEXT:
01834           SaveWindowPosition(hDlg);
01835           GetDlgItemText(hDlg, IDC_EDIT_PROGRAM_FOLDER, szBuf, MAX_BUF);
01836           if(*szBuf == '\0')
01837           {
01838             char szEProgramFolderName[MAX_BUF];
01839 
01840             GetPrivateProfileString("Messages", "ERROR_PROGRAM_FOLDER_NAME", "", szEProgramFolderName, sizeof(szEProgramFolderName), szFileIniInstall);
01841             MessageBox(hDlg, szEProgramFolderName, NULL, MB_OK | MB_ICONEXCLAMATION);
01842             break;
01843           }
01844           lstrcpy(sgProduct.szProgramFolderName, szBuf);
01845         
01846           sgProduct.lastDialog = hDlg;
01847           DlgSequence(NEXT_DLG);
01848           break;
01849 
01850         case IDWIZBACK:
01851           SaveWindowPosition(hDlg);
01852           sgProduct.lastDialog = hDlg;
01853           DlgSequence(PREV_DLG);
01854           break;
01855 
01856         case IDC_LIST:
01857           if((dwIndex = SendDlgItemMessage(hDlg, IDC_LIST, LB_GETCURSEL, 0, 0)) != LB_ERR)
01858           {
01859             SendDlgItemMessage(hDlg, IDC_LIST, LB_GETTEXT, dwIndex, (LPARAM)szBuf);
01860             SetDlgItemText(hDlg, IDC_EDIT_PROGRAM_FOLDER, szBuf);
01861           }
01862           break;
01863 
01864         case IDCANCEL:
01865           AskCancelDlg(hDlg);
01866           break;
01867 
01868         default:
01869           break;
01870       }
01871       break;
01872   }
01873   return(0);
01874 }
01875 
01876 void SaveDownloadProtocolOption(HWND hDlg)
01877 {
01878   if(IsDlgButtonChecked(hDlg, IDC_USE_FTP) == BST_CHECKED)
01879     diAdditionalOptions.dwUseProtocol = UP_FTP;
01880   else if(IsDlgButtonChecked(hDlg, IDC_USE_HTTP) == BST_CHECKED)
01881     diAdditionalOptions.dwUseProtocol = UP_HTTP;
01882 }
01883 
01884 LRESULT CALLBACK DlgProcAdvancedSettings(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
01885 {
01886   char  szBuf[MAX_BUF];
01887 
01888   switch(msg)
01889   {
01890     case WM_INITDIALOG:
01891       DisableSystemMenuItems(hDlg, FALSE);
01892       SetWindowText(hDlg, diAdvancedSettings.szTitle);
01893       SetDlgItemText(hDlg, IDC_MESSAGE0,          diAdvancedSettings.szMessage0);
01894       SetDlgItemText(hDlg, IDC_EDIT_PROXY_SERVER, diAdvancedSettings.szProxyServer);
01895       SetDlgItemText(hDlg, IDC_EDIT_PROXY_PORT,   diAdvancedSettings.szProxyPort);
01896       SetDlgItemText(hDlg, IDC_EDIT_PROXY_USER,   diAdvancedSettings.szProxyUser);
01897       SetDlgItemText(hDlg, IDC_EDIT_PROXY_PASSWD, diAdvancedSettings.szProxyPasswd);
01898 
01899       RepositionWindow(hDlg, NO_BANNER_IMAGE);
01900 
01901       GetPrivateProfileString("Strings", "IDC Use Ftp", "", szBuf, sizeof(szBuf), szFileIniConfig);
01902       SetDlgItemText(hDlg, IDC_USE_FTP, szBuf);
01903       GetPrivateProfileString("Strings", "IDC Use Http", "", szBuf, sizeof(szBuf), szFileIniConfig);
01904       SetDlgItemText(hDlg, IDC_USE_HTTP, szBuf);
01905 
01906       SetDlgItemText(hDlg, IDC_STATIC, sgInstallGui.szProxySettings);
01907       SetDlgItemText(hDlg, IDC_STATIC1, sgInstallGui.szServer);
01908       SetDlgItemText(hDlg, IDC_STATIC2, sgInstallGui.szPort);
01909       SetDlgItemText(hDlg, IDC_STATIC3, sgInstallGui.szUserId);
01910       SetDlgItemText(hDlg, IDC_STATIC4, sgInstallGui.szPassword);
01911       SetDlgItemText(hDlg, IDWIZNEXT, sgInstallGui.szOk_);
01912       SetDlgItemText(hDlg, IDCANCEL, sgInstallGui.szCancel_);
01913       SendDlgItemMessage (hDlg, IDC_STATIC, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01914       SendDlgItemMessage (hDlg, IDC_STATIC1, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01915       SendDlgItemMessage (hDlg, IDC_STATIC2, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01916       SendDlgItemMessage (hDlg, IDC_STATIC3, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01917       SendDlgItemMessage (hDlg, IDC_STATIC4, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01918       SendDlgItemMessage (hDlg, IDWIZNEXT, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01919       SendDlgItemMessage (hDlg, IDCANCEL, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01920       SendDlgItemMessage (hDlg, IDC_MESSAGE0, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01921       SendDlgItemMessage (hDlg, IDC_EDIT_PROXY_SERVER, WM_SETFONT, (WPARAM)sgInstallGui.systemFont, 0L);
01922       SendDlgItemMessage (hDlg, IDC_EDIT_PROXY_PORT, WM_SETFONT, (WPARAM)sgInstallGui.systemFont, 0L);
01923       SendDlgItemMessage (hDlg, IDC_EDIT_PROXY_USER, WM_SETFONT, (WPARAM)sgInstallGui.systemFont, 0L);
01924       SendDlgItemMessage (hDlg, IDC_EDIT_PROXY_PASSWD, WM_SETFONT, (WPARAM)sgInstallGui.systemFont, 0L);
01925       SendDlgItemMessage (hDlg, IDC_USE_FTP, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01926       SendDlgItemMessage (hDlg, IDC_USE_HTTP, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
01927 
01928       switch(diAdditionalOptions.dwUseProtocol)
01929       {
01930         case UP_HTTP:
01931           CheckDlgButton(hDlg, IDC_USE_FTP,  BST_UNCHECKED);
01932           CheckDlgButton(hDlg, IDC_USE_HTTP, BST_CHECKED);
01933           break;
01934 
01935         case UP_FTP:
01936         default:
01937           CheckDlgButton(hDlg, IDC_USE_FTP,  BST_CHECKED);
01938           CheckDlgButton(hDlg, IDC_USE_HTTP, BST_UNCHECKED);
01939           break;
01940 
01941       }
01942 
01943       if((diAdditionalOptions.bShowProtocols) && (diAdditionalOptions.bUseProtocolSettings))
01944       {
01945         ShowWindow(GetDlgItem(hDlg, IDC_USE_FTP),  SW_SHOW);
01946         ShowWindow(GetDlgItem(hDlg, IDC_USE_HTTP), SW_SHOW);
01947       }
01948       else
01949       {
01950         ShowWindow(GetDlgItem(hDlg, IDC_USE_FTP),  SW_HIDE);
01951         ShowWindow(GetDlgItem(hDlg, IDC_USE_HTTP), SW_HIDE);
01952       }
01953       ClosePreviousDialog();
01954       break;
01955 
01956     case WM_COMMAND:
01957       switch(LOWORD(wParam))
01958       {
01959         case IDWIZNEXT:
01960           SaveWindowPosition(hDlg);
01961           /* get the proxy server and port information */
01962           GetDlgItemText(hDlg, IDC_EDIT_PROXY_SERVER, diAdvancedSettings.szProxyServer, MAX_BUF);
01963           GetDlgItemText(hDlg, IDC_EDIT_PROXY_PORT,   diAdvancedSettings.szProxyPort,   MAX_BUF);
01964           GetDlgItemText(hDlg, IDC_EDIT_PROXY_USER,   diAdvancedSettings.szProxyUser,   MAX_BUF);
01965           GetDlgItemText(hDlg, IDC_EDIT_PROXY_PASSWD, diAdvancedSettings.szProxyPasswd, MAX_BUF);
01966 
01967           SaveDownloadProtocolOption(hDlg);
01968           sgProduct.lastDialog = hDlg;
01969           DlgSequence(NEXT_DLG);
01970           break;
01971 
01972         case IDWIZBACK:
01973         case IDCANCEL:
01974           SaveWindowPosition(hDlg);
01975           sgProduct.lastDialog = hDlg;
01976           DlgSequence(PREV_DLG);
01977           break;
01978 
01979         default:
01980           break;
01981       }
01982       break;
01983   }
01984   return(0);
01985 }
01986 
01987 void SaveAdditionalOptions(HWND hDlg, HWND hwndCBSiteSelector)
01988 {
01989   int iIndex;
01990 
01991   /* get selected item from the site selector's pull down list */
01992   iIndex = SendMessage(hwndCBSiteSelector, CB_GETCURSEL, 0, 0);
01993   SendMessage(hwndCBSiteSelector, CB_GETLBTEXT, (WPARAM)iIndex, (LPARAM)szSiteSelectorDescription);
01994 
01995   /* get the state of the Save Installer Files checkbox */
01996   if(IsDlgButtonChecked(hDlg, IDC_CHECK_SAVE_INSTALLER_FILES) == BST_CHECKED)
01997     diAdditionalOptions.bSaveInstaller = TRUE;
01998   else
01999     diAdditionalOptions.bSaveInstaller = FALSE;
02000 
02001   /* get the state of the Recapture Homepage checkbox */
02002   if(IsDlgButtonChecked(hDlg, IDC_CHECK_RECAPTURE_HOMEPAGE) == BST_CHECKED)
02003     diAdditionalOptions.bRecaptureHomepage = TRUE;
02004   else
02005     diAdditionalOptions.bRecaptureHomepage = FALSE;
02006 }
02007 
02008 LRESULT CALLBACK DlgProcAdditionalOptions(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
02009 {
02010   char  szBuf[MAX_BUF];
02011   HWND  hwndCBSiteSelector;
02012   int   iIndex;
02013   ssi   *ssiTemp;
02014   char  szCBDefault[MAX_BUF];
02015 
02016   hwndCBSiteSelector = GetDlgItem(hDlg, IDC_LIST_SITE_SELECTOR);
02017 
02018   switch(msg)
02019   {
02020     case WM_INITDIALOG:
02021 //      if(gdwSiteSelectorStatus == SS_HIDE)
02022 //      {
02023 //        ShowWindow(GetDlgItem(hDlg, IDC_MESSAGE0),  SW_HIDE);
02024 //        ShowWindow(GetDlgItem(hDlg, IDC_LIST_SITE_SELECTOR),  SW_HIDE);
02025 //      }
02026 
02027       if(diAdditionalOptions.bShowHomepageOption == FALSE)
02028       {
02029         ShowWindow(GetDlgItem(hDlg, IDC_MESSAGE0),  SW_HIDE);
02030         ShowWindow(GetDlgItem(hDlg, IDC_CHECK_RECAPTURE_HOMEPAGE),  SW_HIDE);
02031       }
02032 
02033       if(GetTotalArchivesToDownload() == 0)
02034       {
02035         ShowWindow(GetDlgItem(hDlg, IDC_MESSAGE1),  SW_HIDE);
02036         ShowWindow(GetDlgItem(hDlg, IDC_CHECK_SAVE_INSTALLER_FILES),  SW_HIDE);
02037         ShowWindow(GetDlgItem(hDlg, IDC_EDIT_LOCAL_INSTALLER_PATH), SW_HIDE);
02038         ShowWindow(GetDlgItem(hDlg, IDC_BUTTON_PROXY_SETTINGS), SW_HIDE);
02039       }
02040 
02041       DisableSystemMenuItems(hDlg, FALSE);
02042       SetWindowText(hDlg, diAdditionalOptions.szTitle);
02043       SetDlgItemText(hDlg, IDC_MESSAGE0, diAdditionalOptions.szMessage0);
02044       SetDlgItemText(hDlg, IDC_MESSAGE1, diAdditionalOptions.szMessage1);
02045 
02046       GetPrivateProfileString("Strings", "IDC Save Installer Files", "", szBuf, sizeof(szBuf), szFileIniConfig);
02047       SetDlgItemText(hDlg, IDC_CHECK_SAVE_INSTALLER_FILES, szBuf);
02048       GetPrivateProfileString("Strings", "IDC Recapture Homepage", "", szBuf, sizeof(szBuf), szFileIniConfig);
02049       SetDlgItemText(hDlg, IDC_CHECK_RECAPTURE_HOMEPAGE, szBuf);
02050 
02051       GetSaveInstallerPath(szBuf, sizeof(szBuf));
02052       SetDlgItemText(hDlg, IDC_EDIT_LOCAL_INSTALLER_PATH, szBuf);
02053 
02054       SetDlgItemText(hDlg, IDC_BUTTON_PROXY_SETTINGS, sgInstallGui.szProxySettings_);
02055       SetDlgItemText(hDlg, IDWIZBACK, sgInstallGui.szBack_);
02056       SetDlgItemText(hDlg, IDWIZNEXT, sgInstallGui.szNext_);
02057       SetDlgItemText(hDlg, IDCANCEL, sgInstallGui.szCancel_);
02058       SendDlgItemMessage (hDlg, IDC_BUTTON_PROXY_SETTINGS, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02059       SendDlgItemMessage (hDlg, IDWIZBACK, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02060       SendDlgItemMessage (hDlg, IDWIZNEXT, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02061       SendDlgItemMessage (hDlg, IDCANCEL, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02062       SendDlgItemMessage (hDlg, IDC_MESSAGE0, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02063       SendDlgItemMessage (hDlg, IDC_LIST_SITE_SELECTOR, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02064       SendDlgItemMessage (hDlg, IDC_MESSAGE1, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02065       SendDlgItemMessage (hDlg, IDC_CHECK_SAVE_INSTALLER_FILES, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02066       SendDlgItemMessage (hDlg, IDC_CHECK_RECAPTURE_HOMEPAGE, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02067       SendDlgItemMessage (hDlg, IDC_EDIT_LOCAL_INSTALLER_PATH, WM_SETFONT, (WPARAM)sgInstallGui.systemFont, 0L);
02068 
02069       RepositionWindow(hDlg, NO_BANNER_IMAGE);
02070 
02071       ssiTemp = ssiSiteSelector;
02072       do
02073       {
02074         if(ssiTemp == NULL)
02075           break;
02076 
02077         SendMessage(hwndCBSiteSelector, CB_ADDSTRING, 0, (LPARAM)(ssiTemp->szDescription));
02078         ssiTemp = ssiTemp->Next;
02079       } while(ssiTemp != ssiSiteSelector);
02080 
02081       if((szSiteSelectorDescription == NULL) || (*szSiteSelectorDescription == '\0'))
02082       {
02083           if(GetPrivateProfileString("Messages", "CB_DEFAULT", "", szCBDefault, sizeof(szCBDefault), szFileIniInstall) &&
02084           ((iIndex = SendMessage(hwndCBSiteSelector, CB_SELECTSTRING, -1, (LPARAM)szCBDefault)) != CB_ERR))
02085           SendMessage(hwndCBSiteSelector, CB_SETCURSEL, (WPARAM)iIndex, 0);
02086         else
02087           SendMessage(hwndCBSiteSelector, CB_SETCURSEL, 0, 0);
02088       }
02089       else if((iIndex = SendMessage(hwndCBSiteSelector, CB_SELECTSTRING, -1, (LPARAM)szSiteSelectorDescription)) != CB_ERR)
02090         SendMessage(hwndCBSiteSelector, CB_SETCURSEL, (WPARAM)iIndex, 0);
02091       else
02092         SendMessage(hwndCBSiteSelector, CB_SETCURSEL, 0, 0);
02093 
02094       if(diAdditionalOptions.bSaveInstaller)
02095         CheckDlgButton(hDlg, IDC_CHECK_SAVE_INSTALLER_FILES, BST_CHECKED);
02096       else
02097         CheckDlgButton(hDlg, IDC_CHECK_SAVE_INSTALLER_FILES, BST_UNCHECKED);
02098 
02099       if(diAdditionalOptions.bRecaptureHomepage)
02100         CheckDlgButton(hDlg, IDC_CHECK_RECAPTURE_HOMEPAGE, BST_CHECKED);
02101       else
02102         CheckDlgButton(hDlg, IDC_CHECK_RECAPTURE_HOMEPAGE, BST_UNCHECKED);
02103 
02104       ClosePreviousDialog();
02105       break;
02106 
02107     case WM_COMMAND:
02108       switch(LOWORD(wParam))
02109       {
02110         case IDWIZNEXT:
02111           SaveWindowPosition(hDlg);
02112           SaveAdditionalOptions(hDlg, hwndCBSiteSelector);
02113           sgProduct.lastDialog = hDlg;
02114           DlgSequence(NEXT_DLG);
02115           break;
02116 
02117         case IDWIZBACK:
02118           SaveWindowPosition(hDlg);
02119           SaveAdditionalOptions(hDlg, hwndCBSiteSelector);
02120           sgProduct.lastDialog = hDlg;
02121           DlgSequence(PREV_DLG);
02122           break;
02123 
02124         case IDC_BUTTON_ADDITIONAL_SETTINGS:
02125           SaveWindowPosition(hDlg);
02126           SaveAdditionalOptions(hDlg, hwndCBSiteSelector);
02127           sgProduct.lastDialog = hDlg;
02128           DlgSequence(OTHER_DLG_1);
02129           break;
02130 
02131         case IDCANCEL:
02132           AskCancelDlg(hDlg);
02133           break;
02134 
02135         default:
02136           break;
02137       }
02138       break;
02139   }
02140   return(0);
02141 }
02142 
02143 void AppendStringWOAmpersand(LPSTR szInputString, DWORD dwInputStringSize, LPSTR szString)
02144 {
02145   DWORD i;
02146   DWORD iInputStringCounter;
02147   DWORD iInputStringLen;
02148   DWORD iStringLen;
02149 
02150 
02151   iInputStringLen = lstrlen(szInputString);
02152   iStringLen      = lstrlen(szString);
02153 
02154   if((iInputStringLen + iStringLen) >= dwInputStringSize)
02155     return;
02156 
02157   iInputStringCounter = iInputStringLen;
02158   for(i = 0; i < iStringLen; i++)
02159   {
02160     if(szString[i] != '&')
02161       szInputString[iInputStringCounter++] = szString[i];
02162   }
02163 }
02164 
02165 LPSTR GetStartInstallMessage()
02166 {
02167   char  szBuf[MAX_BUF];
02168   char  szSTRRequired[MAX_BUF_TINY];
02169   siC   *siCObject   = NULL;
02170   LPSTR szMessageBuf = NULL;
02171   DWORD dwBufSize;
02172   DWORD dwIndex0;
02173 
02174   GetPrivateProfileString("Strings", "STR Force Upgrade Required", "", szSTRRequired, sizeof(szSTRRequired), szFileIniConfig);
02175 
02176   /* calculate the amount of memory to allocate for the buffer */
02177   dwBufSize = 0;
02178 
02179   /* setup type */
02180   if(GetPrivateProfileString("Messages", "STR_SETUP_TYPE", "", szBuf, sizeof(szBuf), szFileIniInstall))
02181     dwBufSize += lstrlen(szBuf) + 2; // the extra 2 bytes is for the \r\n characters
02182   dwBufSize += 4; // take into account 4 indentation spaces
02183 
02184   switch(dwSetupType)
02185   {
02186     case ST_RADIO3:
02187       dwBufSize += lstrlen(diSetupType.stSetupType3.szDescriptionShort) + 2; // the extra 2 bytes is for the \r\n characters
02188       break;
02189 
02190     case ST_RADIO2:
02191       dwBufSize += lstrlen(diSetupType.stSetupType2.szDescriptionShort) + 2; // the extra 2 bytes is for the \r\n characters
02192       break;
02193 
02194     case ST_RADIO1:
02195       dwBufSize += lstrlen(diSetupType.stSetupType1.szDescriptionShort) + 2; // the extra 2 bytes is for the \r\n characters
02196       break;
02197 
02198     default:
02199       dwBufSize += lstrlen(diSetupType.stSetupType0.szDescriptionShort) + 2; // the extra 2 bytes is for the \r\n characters
02200       break;
02201   }
02202   dwBufSize += 2; // the extra 2 bytes is for the \r\n characters
02203 
02204   /* selected components */
02205   if(GetPrivateProfileString("Messages", "STR_SELECTED_COMPONENTS", "", szBuf, sizeof(szBuf), szFileIniInstall))
02206     dwBufSize += lstrlen(szBuf) + 2; // the extra 2 bytes is for the \r\n characters
02207 
02208   dwIndex0 = 0;
02209   siCObject = SiCNodeGetObject(dwIndex0, FALSE, AC_ALL);
02210   while(siCObject)
02211   {
02212     if(siCObject->dwAttributes & SIC_SELECTED)
02213     {
02214       dwBufSize += 4; // take into account 4 indentation spaces
02215       dwBufSize += lstrlen(siCObject->szDescriptionShort);
02216     }
02217 
02218     if(siCObject->bForceUpgrade)
02219     {
02220       /* add the "(Required)" string (or something equivalent) after the component description */
02221       if(*szSTRRequired != '\0')
02222       {
02223         dwBufSize += 1; // space after the short description
02224         dwBufSize += lstrlen(szSTRRequired);
02225       }
02226     }
02227 
02228     if(siCObject->dwAttributes & SIC_SELECTED)
02229       dwBufSize += 2; // the extra 2 bytes is for the \r\n characters
02230 
02231     ++dwIndex0;
02232     siCObject = SiCNodeGetObject(dwIndex0, FALSE, AC_ALL);
02233   }
02234   dwBufSize += 2; // the extra 2 bytes is for the \r\n characters
02235 
02236   /* destination path */
02237   if(GetPrivateProfileString("Messages", "STR_DESTINATION_DIRECTORY", "", szBuf, sizeof(szBuf), szFileIniInstall))
02238     dwBufSize += lstrlen(szBuf) + 2; // the extra 2 bytes is for the \r\n characters
02239 
02240   dwBufSize += 4; // take into account 4 indentation spaces
02241   dwBufSize += lstrlen(sgProduct.szPath) + 2; // the extra 2 bytes is for the \r\n characters
02242   dwBufSize += 2; // the extra 2 bytes is for the \r\n characters
02243 
02244   /* program folder */
02245   if(GetPrivateProfileString("Messages", "STR_PROGRAM_FOLDER", "", szBuf, sizeof(szBuf), szFileIniInstall))
02246     dwBufSize += lstrlen(szBuf) + 2; // the extra 2 bytes is for the \r\n characters
02247 
02248   dwBufSize += 4; // take into account 4 indentation spaces
02249   dwBufSize += lstrlen(sgProduct.szProgramFolderName) + 2; // the extra 2 bytes is for the \r\n\r\n characters
02250 
02251   if(GetTotalArchivesToDownload() > 0)
02252   {
02253     dwBufSize += 2; // the extra 2 bytes is for the \r\n characters
02254 
02255     /* site selector info */
02256     if(GetPrivateProfileString("Messages", "STR_DOWNLOAD_SITE", "", szBuf, sizeof(szBuf), szFileIniInstall))
02257       dwBufSize += lstrlen(szBuf) + 2; // the extra 2 bytes is for the \r\n characters
02258 
02259     dwBufSize += 4; // take into account 4 indentation spaces
02260     dwBufSize += lstrlen(szSiteSelectorDescription) + 2; // the extra 2 bytes is for the \r\n characters
02261 
02262     if(diAdditionalOptions.bSaveInstaller)
02263     {
02264       dwBufSize += 2; // the extra 2 bytes is for the \r\n characters
02265 
02266       /* site selector info */
02267       if(GetPrivateProfileString("Messages", "STR_SAVE_INSTALLER_FILES", "", szBuf, sizeof(szBuf), szFileIniInstall))
02268         dwBufSize += lstrlen(szBuf) + 2; // the extra 2 bytes is for the \r\n characters
02269 
02270       GetSaveInstallerPath(szBuf, sizeof(szBuf));
02271       dwBufSize += 4; // take into account 4 indentation spaces
02272       dwBufSize += lstrlen(szBuf) + 2; // the extra 2 bytes is for the \r\n characters
02273     }
02274   }
02275 
02276   dwBufSize += 1; // take into account the null character
02277 
02278 
02279   /* From here down, the buffer is created given the above calculated buffer size.  If the 
02280    * string concatenation (addition) is changed below, then the buffer size calculation above
02281    * needs to be changed accordingly! */
02282 
02283   /* allocate the memory */
02284   if((szMessageBuf = NS_GlobalAlloc(dwBufSize)) != NULL)
02285   {
02286     ZeroMemory(szMessageBuf, dwBufSize);
02287 
02288     /* Setup Type */
02289     if(GetPrivateProfileString("Messages", "STR_SETUP_TYPE", "", szBuf, sizeof(szBuf), szFileIniInstall))
02290     {
02291       lstrcat(szMessageBuf, szBuf);
02292       lstrcat(szMessageBuf, "\r\n");
02293     }
02294     lstrcat(szMessageBuf, "    "); // add 4 indentation spaces
02295       
02296     switch(dwSetupType)
02297     {
02298       case ST_RADIO3:
02299         AppendStringWOAmpersand(szMessageBuf, dwBufSize, diSetupType.stSetupType3.szDescriptionShort);
02300         break;
02301 
02302       case ST_RADIO2:
02303         AppendStringWOAmpersand(szMessageBuf, dwBufSize, diSetupType.stSetupType2.szDescriptionShort);
02304         break;
02305 
02306       case ST_RADIO1:
02307         AppendStringWOAmpersand(szMessageBuf, dwBufSize, diSetupType.stSetupType1.szDescriptionShort);
02308         break;
02309 
02310       default:
02311         AppendStringWOAmpersand(szMessageBuf, dwBufSize, diSetupType.stSetupType0.szDescriptionShort);
02312         break;
02313     }
02314     lstrcat(szMessageBuf, "\r\n\r\n");
02315 
02316     /* Selected Components */
02317     if(GetPrivateProfileString("Messages", "STR_SELECTED_COMPONENTS", "", szBuf, sizeof(szBuf), szFileIniInstall))
02318     {
02319       lstrcat(szMessageBuf, szBuf);
02320       lstrcat(szMessageBuf, "\r\n");
02321     }
02322 
02323     dwIndex0  = 0;
02324     siCObject = SiCNodeGetObject(dwIndex0, FALSE, AC_ALL);
02325     while(siCObject)
02326     {
02327       if(siCObject->dwAttributes & SIC_SELECTED)
02328       {
02329         lstrcat(szMessageBuf, "    "); // add 4 indentation spaces
02330         lstrcat(szMessageBuf, siCObject->szDescriptionShort);
02331       }
02332 
02333       if(siCObject->bForceUpgrade)
02334       {
02335         /* add the "(Required)" string (or something equivalent) after the component description */
02336         if(*szSTRRequired != '\0')
02337         {
02338           lstrcat(szMessageBuf, " "); // add 1 space
02339           lstrcat(szMessageBuf, szSTRRequired);
02340         }
02341       }
02342 
02343       if(siCObject->dwAttributes & SIC_SELECTED)
02344         lstrcat(szMessageBuf, "\r\n");
02345 
02346       ++dwIndex0;
02347       siCObject = SiCNodeGetObject(dwIndex0, FALSE, AC_ALL);
02348     }
02349     lstrcat(szMessageBuf, "\r\n");
02350 
02351     /* destination directory */
02352     if(GetPrivateProfileString("Messages", "STR_DESTINATION_DIRECTORY", "", szBuf, sizeof(szBuf), szFileIniInstall))
02353     {
02354       lstrcat(szMessageBuf, szBuf);
02355       lstrcat(szMessageBuf, "\r\n");
02356     }
02357     lstrcat(szMessageBuf, "    "); // add 4 indentation spaces
02358     lstrcat(szMessageBuf, sgProduct.szPath);
02359     lstrcat(szMessageBuf, "\r\n\r\n");
02360 
02361     /* program folder */
02362     if(GetPrivateProfileString("Messages", "STR_PROGRAM_FOLDER", "", szBuf, sizeof(szBuf), szFileIniInstall))
02363     {
02364       lstrcat(szMessageBuf, szBuf);
02365       lstrcat(szMessageBuf, "\r\n");
02366     }
02367     lstrcat(szMessageBuf, "    "); // add 4 indentation spaces
02368     lstrcat(szMessageBuf, sgProduct.szProgramFolderName);
02369     lstrcat(szMessageBuf, "\r\n");
02370 
02371     if(GetTotalArchivesToDownload() > 0)
02372     {
02373       lstrcat(szMessageBuf, "\r\n");
02374 
02375       /* site selector info */
02376       if(GetPrivateProfileString("Messages", "STR_DOWNLOAD_SITE", "", szBuf, sizeof(szBuf), szFileIniInstall))
02377       {
02378         lstrcat(szMessageBuf, szBuf);
02379         lstrcat(szMessageBuf, "\r\n");
02380       }
02381 
02382       lstrcat(szMessageBuf, "    "); // add 4 indentation spaces
02383       lstrcat(szMessageBuf, szSiteSelectorDescription); // site selector description
02384       lstrcat(szMessageBuf, "\r\n");
02385 
02386       if(diAdditionalOptions.bSaveInstaller)
02387       {
02388         lstrcat(szMessageBuf, "\r\n");
02389 
02390         /* site selector info */
02391         if(GetPrivateProfileString("Messages", "STR_SAVE_INSTALLER_FILES", "", szBuf, sizeof(szBuf), szFileIniInstall))
02392         {
02393           lstrcat(szMessageBuf, szBuf);
02394           lstrcat(szMessageBuf, "\r\n");
02395         }
02396 
02397         GetSaveInstallerPath(szBuf, sizeof(szBuf));
02398         lstrcat(szMessageBuf, "    "); // add 4 indentation spaces
02399         lstrcat(szMessageBuf, szBuf);
02400         lstrcat(szMessageBuf, "\r\n");
02401       }
02402     }
02403   }
02404 
02405   return(szMessageBuf);
02406 }
02407 
02408 // XXX also defined in extra.c, need to factor out
02409 
02410 #define SETUP_STATE_REG_KEY "Software\\%s\\%s\\%s\\Setup"
02411 
02412 LRESULT CALLBACK DlgProcQuickLaunch(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
02413 {
02414   LPSTR szMessage = NULL;
02415   char  szBuf[MAX_BUF];
02416 
02417   switch(msg)
02418   {
02419     case WM_INITDIALOG:
02420       DisableSystemMenuItems(hDlg, FALSE);
02421       SetWindowText(hDlg, diQuickLaunch.szTitle);
02422 
02423       GetPrivateProfileString("Strings", "IDC Turbo Mode", "", szBuf, sizeof(szBuf), szFileIniConfig);
02424       SetDlgItemText(hDlg, IDC_CHECK_TURBO_MODE, szBuf);
02425       SetDlgItemText(hDlg, IDC_STATIC, sgInstallGui.szCurrentSettings);
02426       SetDlgItemText(hDlg, IDWIZBACK, sgInstallGui.szBack_);
02427       SetDlgItemText(hDlg, IDWIZNEXT, sgInstallGui.szNext_);
02428       SetDlgItemText(hDlg, IDCANCEL, sgInstallGui.szCancel_);
02429       SendDlgItemMessage (hDlg, IDC_STATIC, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02430       SendDlgItemMessage (hDlg, IDWIZBACK, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02431       SendDlgItemMessage (hDlg, IDWIZNEXT, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02432       SendDlgItemMessage (hDlg, IDCANCEL, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02433       SendDlgItemMessage (hDlg, IDC_MESSAGE0, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02434       SendDlgItemMessage (hDlg, IDC_MESSAGE1, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02435       SendDlgItemMessage (hDlg, IDC_MESSAGE2, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02436       SendDlgItemMessage (hDlg, IDC_CHECK_TURBO_MODE, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02437 
02438       RepositionWindow(hDlg, NO_BANNER_IMAGE);
02439 
02440       SetDlgItemText(hDlg, IDC_MESSAGE0, diQuickLaunch.szMessage0);
02441       SetDlgItemText(hDlg, IDC_MESSAGE1, diQuickLaunch.szMessage1);
02442       SetDlgItemText(hDlg, IDC_MESSAGE2, diQuickLaunch.szMessage2);
02443 
02444       if(diQuickLaunch.bTurboModeEnabled)
02445         ShowWindow(GetDlgItem(hDlg, IDC_CHECK_TURBO_MODE),  SW_SHOW);
02446       else
02447       {
02448         ShowWindow(GetDlgItem(hDlg, IDC_CHECK_TURBO_MODE),  SW_HIDE);
02449         diQuickLaunch.bTurboMode = FALSE;
02450       }
02451 
02452       if(diQuickLaunch.bTurboMode)
02453         CheckDlgButton(hDlg, IDC_CHECK_TURBO_MODE, BST_CHECKED);
02454       else
02455         CheckDlgButton(hDlg, IDC_CHECK_TURBO_MODE, BST_UNCHECKED);
02456 
02457       ClosePreviousDialog();
02458       break;
02459 
02460     case WM_COMMAND:
02461       switch(LOWORD(wParam))
02462       {
02463         case IDWIZNEXT:
02464           SaveWindowPosition(hDlg);
02465           if(diQuickLaunch.bTurboModeEnabled)
02466           {
02467             if(IsDlgButtonChecked(hDlg, IDC_CHECK_TURBO_MODE) == BST_CHECKED)
02468               diQuickLaunch.bTurboMode = TRUE;
02469             else
02470               diQuickLaunch.bTurboMode = FALSE;
02471           }
02472  
02473           sgProduct.lastDialog = hDlg;
02474           DlgSequence(NEXT_DLG);
02475           break;
02476 
02477         case IDWIZBACK:
02478           SaveWindowPosition(hDlg);
02479           /* remember the last state of the TurboMode checkbox */
02480           if(IsDlgButtonChecked(hDlg, IDC_CHECK_TURBO_MODE) == BST_CHECKED) {
02481             diQuickLaunch.bTurboMode = TRUE;
02482           }
02483           else {
02484             diQuickLaunch.bTurboMode = FALSE;
02485           }
02486           sgProduct.lastDialog = hDlg;
02487           DlgSequence(PREV_DLG);
02488           break;
02489 
02490         case IDCANCEL:
02491           AskCancelDlg(hDlg);
02492           break;
02493 
02494         default:
02495           break;
02496       }
02497       break;
02498   }
02499   return(0);
02500 }
02501 
02502 LRESULT CALLBACK DlgProcStartInstall(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
02503 {
02504   LPSTR szMessage = NULL;
02505 
02506   switch(msg)
02507   {
02508     case WM_INITDIALOG:
02509       DisableSystemMenuItems(hDlg, FALSE);
02510       SetWindowText(hDlg, diStartInstall.szTitle);
02511 
02512       SetDlgItemText(hDlg, IDC_STATIC, sgInstallGui.szCurrentSettings);
02513       SetDlgItemText(hDlg, IDWIZBACK, sgInstallGui.szBack_);
02514       SetDlgItemText(hDlg, IDWIZNEXT, sgInstallGui.szInstall_);
02515       SetDlgItemText(hDlg, IDCANCEL, sgInstallGui.szCancel_);
02516       SendDlgItemMessage (hDlg, IDC_STATIC, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02517       SendDlgItemMessage (hDlg, IDWIZBACK, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02518       SendDlgItemMessage (hDlg, IDWIZNEXT, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02519       SendDlgItemMessage (hDlg, IDCANCEL, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02520       SendDlgItemMessage (hDlg, IDC_MESSAGE0, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02521       SendDlgItemMessage (hDlg, IDC_CURRENT_SETTINGS, WM_SETFONT, (WPARAM)sgInstallGui.systemFont, 0L);
02522  
02523       RepositionWindow(hDlg, NO_BANNER_IMAGE);
02524 
02525       if((diAdvancedSettings.bShowDialog == FALSE) || (GetTotalArchivesToDownload() == 0))
02526       {
02527         ShowWindow(GetDlgItem(hDlg, IDC_BUTTON_SITE_SELECTOR), SW_HIDE);
02528         SetDlgItemText(hDlg, IDC_MESSAGE0, diStartInstall.szMessageInstall);
02529       }
02530       else
02531       {
02532         ShowWindow(GetDlgItem(hDlg, IDC_BUTTON_SITE_SELECTOR), SW_SHOW);
02533         SetDlgItemText(hDlg, IDC_MESSAGE0, diStartInstall.szMessageDownload);
02534       }
02535 
02536       if((szMessage = GetStartInstallMessage()) != NULL)
02537       {
02538         SetDlgItemText(hDlg, IDC_CURRENT_SETTINGS, szMessage);
02539         FreeMemory(&szMessage);
02540       }
02541       ClosePreviousDialog();
02542       break;
02543 
02544     case WM_COMMAND:
02545       switch(LOWORD(wParam))
02546       {
02547         case IDWIZNEXT:
02548           SaveWindowPosition(hDlg);
02549           sgProduct.lastDialog = hDlg;
02550           DlgSequence(NEXT_DLG);
02551           break;
02552 
02553         case IDWIZBACK:
02554           SaveWindowPosition(hDlg);
02555           sgProduct.lastDialog = hDlg;
02556           DlgSequence(PREV_DLG);
02557           break;
02558 
02559         case IDCANCEL:
02560           AskCancelDlg(hDlg);
02561           break;
02562 
02563         default:
02564           break;
02565       }
02566       break;
02567   }
02568   return(0);
02569 }
02570 
02571 LRESULT CALLBACK DlgProcReboot(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
02572 {
02573   HANDLE            hToken;
02574   TOKEN_PRIVILEGES  tkp;
02575   HWND              hRadioYes;
02576 
02577   hRadioYes = GetDlgItem(hDlg, IDC_RADIO_YES);
02578 
02579   switch(msg)
02580   {
02581     case WM_INITDIALOG:
02582       DisableSystemMenuItems(hDlg, FALSE);
02583       CheckDlgButton(hDlg, IDC_RADIO_YES, BST_CHECKED);
02584       SetFocus(hRadioYes);
02585 
02586       RepositionWindow(hDlg, NO_BANNER_IMAGE);
02587 
02588       SetWindowText(hDlg, sgInstallGui.szRestart);
02589       SetDlgItemText(hDlg, 202, sgInstallGui.szSetupMessage);
02590       SetDlgItemText(hDlg, IDC_RADIO_YES, sgInstallGui.szYesRestart);
02591       SetDlgItemText(hDlg, IDC_RADIO_NO, sgInstallGui.szNoRestart);
02592       SetDlgItemText(hDlg, IDOK, sgInstallGui.szOk);
02593       SendDlgItemMessage (hDlg, 202, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02594       SendDlgItemMessage (hDlg, IDC_RADIO_YES, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02595       SendDlgItemMessage (hDlg, IDC_RADIO_NO, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02596       SendDlgItemMessage (hDlg, IDOK, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02597       break;
02598 
02599     case WM_COMMAND:
02600       SaveWindowPosition(hDlg);
02601       switch(LOWORD(wParam))
02602       {
02603         case IDOK:
02604           if(IsDlgButtonChecked(hDlg, IDC_RADIO_YES) == BST_CHECKED)
02605           {
02606             // Get a token for this process.
02607             OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
02608 
02609             // Get the LUID for the shutdown privilege.
02610             LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
02611             tkp.PrivilegeCount = 1;  // one privilege to set
02612             tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
02613 
02614             // Get the shutdown privilege for this process.
02615             AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
02616 
02617             DestroyWindow(hDlg);
02618             PostQuitMessage(0);
02619             DestroyWindow(hWndMain);
02620 
02621             // Reboot the system and force all applications to close.
02622             ExitWindowsEx(EWX_REBOOT, 0);
02623           }
02624           else
02625           {
02626             DestroyWindow(hDlg);
02627             PostQuitMessage(0);
02628           }
02629           break;
02630 
02631         case IDCANCEL:
02632           DestroyWindow(hDlg);
02633           PostQuitMessage(0);
02634           break;
02635 
02636         default:
02637           break;
02638       }
02639       break;
02640   }
02641   return(0);
02642 }
02643 
02644 void ResizeAndSetString(HWND aDlg, LPARAM lParam)
02645 {
02646   HDC       hdcSTMessage;
02647   RECT      rDlg;
02648   SIZE      sizeString;
02649   LOGFONT   logFont;
02650   HFONT     hfontTmp;
02651   HFONT     hfontOld;
02652   LPSTR     string = (LPSTR)lParam;
02653   HWND      hSTMessage;
02654   int       width;
02655   int       height;
02656 
02657   if(!aDlg || !string || (*string == 0))
02658     return;
02659 
02660   hSTMessage   = GetDlgItem(aDlg, IDC_MESSAGE); /* handle to the Static Text message window */
02661   hdcSTMessage = GetWindowDC(hSTMessage);
02662   SystemParametersInfo(SPI_GETICONTITLELOGFONT,
02663                        sizeof(logFont),
02664                        (PVOID)&logFont,
02665                        0);
02666   hfontTmp = CreateFontIndirect(&logFont);
02667   if(hfontTmp)
02668     hfontOld = SelectObject(hdcSTMessage, hfontTmp);
02669 
02670   GetTextExtentPoint32(hdcSTMessage, string, lstrlen(string), &sizeString);
02671   SelectObject(hdcSTMessage, hfontOld);
02672   ReleaseDC(hSTMessage, hdcSTMessage);
02673   DeleteObject(hfontTmp);
02674   width  = sizeString.cx + 55>150?sizeString.cx + 55:150;
02675   height = sizeString.cy + 50;
02676   SetWindowPos(aDlg, aDlg,
02677               (gSystemInfo.lastWindowPosCenterX)-(width/2),
02678               (gSystemInfo.lastWindowPosCenterY)-(height/2),
02679               width,
02680               height,
02681               SWP_NOACTIVATE|SWP_NOZORDER|SWP_SHOWWINDOW);
02682   if(GetClientRect(aDlg, &rDlg))
02683     SetWindowPos(hSTMessage,
02684                  hSTMessage,
02685                  rDlg.left,
02686                  rDlg.top,
02687                  rDlg.right,
02688                  rDlg.bottom,
02689                  SWP_NOACTIVATE|SWP_NOZORDER|SWP_SHOWWINDOW);
02690   SetDlgItemText(aDlg, IDC_MESSAGE, string);
02691   SaveWindowPosition(aDlg);
02692 }
02693 
02694 LRESULT CALLBACK DlgProcMessage(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
02695 {
02696   char      szBuf[MAX_BUF];
02697   char      szBuf2[MAX_BUF];
02698   BOOL      wasMinimized = FALSE;
02699 
02700   ZeroMemory(szBuf, sizeof(szBuf));
02701   ZeroMemory(szBuf2, sizeof(szBuf2));
02702 
02703   switch(msg)
02704   {
02705     case WM_INITDIALOG:
02706       DisableSystemMenuItems(hDlg, TRUE);
02707       if(GetPrivateProfileString("Messages", "STR_MESSAGEBOX_TITLE", "", szBuf2, sizeof(szBuf2), szFileIniInstall))
02708       {
02709         if((sgProduct.szProductName != NULL) && (*sgProduct.szProductName != '\0'))
02710           wsprintf(szBuf, szBuf2, sgProduct.szProductName);
02711         else
02712           wsprintf(szBuf, szBuf2, "");
02713       }
02714       else if((sgProduct.szProductName != NULL) && (*sgProduct.szProductName != '\0'))
02715         lstrcpy(szBuf, sgProduct.szProductName);
02716 
02717       SendDlgItemMessage(hDlg, IDC_MESSAGE, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
02718       SetWindowText(hDlg, szBuf);
02719       RepositionWindow(hDlg, NO_BANNER_IMAGE);
02720       break;
02721 
02722     case WM_SIZE:
02723       switch(wParam)
02724       {
02725         case SIZE_MINIMIZED:
02726           wasMinimized = TRUE;
02727           break;
02728 
02729         case SIZE_RESTORED:
02730           if(wasMinimized)
02731           {
02732             wasMinimized = FALSE;
02733             ResizeAndSetString(hDlg, lParam);
02734           }
02735           break;
02736       }
02737       break;
02738 
02739     case WM_COMMAND:
02740       switch(LOWORD(wParam))
02741       {
02742         case IDC_MESSAGE:
02743           ResizeAndSetString(hDlg, lParam);
02744           break;
02745       }
02746       break;
02747   }
02748   return(0);
02749 }
02750 
02751 void ProcessWindowsMessages()
02752 {
02753   MSG msg;
02754 
02755   while(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
02756   {
02757     TranslateMessage(&msg);
02758     DispatchMessage(&msg);
02759   }
02760 }
02761 
02762 void ShowMessage(LPSTR szMessage, BOOL bShow)
02763 {
02764   if(sgProduct.mode == SILENT)
02765     return;
02766 
02767   if(bShow)
02768   {
02769     if(!szMessage || (*szMessage == '\0'))
02770       return;
02771 
02772     if(!hDlgMessage)
02773     {
02774       char szBuf[MAX_BUF];
02775 
02776       ZeroMemory(szBuf, sizeof(szBuf));
02777       GetPrivateProfileString("Messages", "MB_MESSAGE_STR", "", szBuf, sizeof(szBuf), szFileIniInstall);
02778       hDlgMessage = InstantiateDialog(hWndMain, DLG_MESSAGE, szBuf, DlgProcMessage);
02779     }
02780 
02781     if(!IsWindowVisible(hDlgMessage))
02782     {
02783       DWORD cmdShow = 0x00000000;
02784 
02785       if(gSystemInfo.lastWindowMinimized)
02786         cmdShow = SW_SHOWMINNOACTIVE;
02787 
02788       if(gSystemInfo.lastWindowIsTopWindow)
02789         cmdShow = SW_SHOWNORMAL;
02790 
02791       RepositionWindow(hDlgMessage, NO_BANNER_IMAGE);
02792       ShowWindow(hDlgMessage, cmdShow);
02793     }
02794     else
02795       SaveWindowPosition(hDlgMessage);
02796 
02797     SendMessage(hDlgMessage, WM_COMMAND, IDC_MESSAGE, (LPARAM)szMessage);
02798   }
02799   else if(hDlgMessage && (IsWindowVisible(hDlgMessage) || gSystemInfo.lastWindowMinimized))
02800   {
02801     SaveWindowPosition(hDlgMessage);
02802     DestroyWindow(hDlgMessage);
02803     hDlgMessage = NULL;
02804   }
02805 }
02806 
02807 HWND InstantiateDialog(HWND hParent, DWORD dwDlgID, LPSTR szTitle, WNDPROC wpDlgProc)
02808 {
02809   char szBuf[MAX_BUF];
02810   HWND hDlg = NULL;
02811 
02812 
02813   if((hDlg = CreateDialog(hSetupRscInst, MAKEINTRESOURCE(dwDlgID), hParent, wpDlgProc)) == NULL)
02814   {
02815     char szEDialogCreate[MAX_BUF];
02816 
02817     if(GetPrivateProfileString("Messages", "ERROR_DIALOG_CREATE", "", szEDialogCreate, sizeof(szEDialogCreate), szFileIniInstall))
02818     {
02819       wsprintf(szBuf, szEDialogCreate, szTitle);
02820       PrintError(szBuf, ERROR_CODE_SHOW);
02821     }
02822     PostQuitMessage(1);
02823   }
02824 
02825   return(hDlg);
02826 }
02827 
02828 /*
02829  * Check to see if turbo is enabled.  If so, do the following:
02830  *   * Log the turbo status that use had chosen.
02831  *   * Set the appropriate Windows registry keys/values.
02832  */
02833 void SetTurboArgs(void)
02834 {
02835   char szData[MAX_BUF];
02836   char szKey[MAX_BUF];
02837 
02838   if(diQuickLaunch.bTurboModeEnabled)
02839   {
02840     /* log if the user selected the turbo mode or not */
02841     LogISTurboMode(diQuickLaunch.bTurboMode);
02842     LogMSTurboMode(diQuickLaunch.bTurboMode);
02843 
02844     if(diQuickLaunch.bTurboMode)
02845       strcpy( szData, "turbo=yes" );
02846     else
02847       strcpy( szData, "turbo=no" );
02848 
02849     wsprintf(szKey,
02850              SETUP_STATE_REG_KEY,
02851              sgProduct.szCompanyName,
02852              sgProduct.szProductNameInternal,
02853              sgProduct.szUserAgent);
02854     AppendWinReg(HKEY_CURRENT_USER,
02855                  szKey,
02856                  "browserargs",
02857                  REG_SZ,
02858                  szData,
02859                  0,
02860                  strlen( szData ) + 1,
02861                  FALSE,
02862                  FALSE );
02863   }
02864 }
02865 
02866 void DlgSequence(int iDirection)
02867 {
02868   HRESULT hrValue;
02869   BOOL    bDone = FALSE;
02870 
02871   do
02872   {
02873     gbProcessingXpnstallFiles = FALSE;
02874 
02875     if(iDirection == NEXT_DLG)
02876     {
02877       switch(dwWizardState)
02878       {
02879         case DLG_NONE:
02880           dwWizardState = DLG_WELCOME;
02881           break;
02882         case DLG_WELCOME:
02883           dwWizardState = DLG_LICENSE;
02884           break;
02885         case DLG_LICENSE:
02886           dwWizardState = DLG_SETUP_TYPE;
02887           break;
02888         case DLG_SETUP_TYPE:
02889           dwWizardState = DLG_UPGRADE;
02890           break;
02891         case DLG_UPGRADE:
02892           dwWizardState = DLG_SELECT_COMPONENTS;
02893           break;
02894         case DLG_SELECT_COMPONENTS:
02895           dwWizardState = DLG_SELECT_ADDITIONAL_COMPONENTS;
02896           break;
02897         case DLG_SELECT_ADDITIONAL_COMPONENTS:
02898           dwWizardState = DLG_WINDOWS_INTEGRATION;
02899           break;
02900         case DLG_WINDOWS_INTEGRATION:
02901           dwWizardState = DLG_PROGRAM_FOLDER;
02902           break;
02903         case DLG_PROGRAM_FOLDER:
02904           dwWizardState = DLG_QUICK_LAUNCH;
02905           break;
02906         case DLG_QUICK_LAUNCH:
02907           dwWizardState = DLG_ADDITIONAL_OPTIONS;
02908           break;
02909         case DLG_ADDITIONAL_OPTIONS:
02910           dwWizardState = DLG_START_INSTALL;
02911           break;
02912         case DLG_START_INSTALL:
02913           dwWizardState = DLG_COMMIT_INSTALL;
02914           break;
02915 
02916         case DLG_ADVANCED_SETTINGS:
02917           dwWizardState = DLG_ADDITIONAL_OPTIONS;
02918           break;
02919 
02920         default:
02921           dwWizardState = DLG_WELCOME;
02922           break;      }
02923     }
02924     else if(iDirection == PREV_DLG)
02925     {
02926       switch(dwWizardState)
02927       {
02928         case DLG_LICENSE:
02929           dwWizardState = DLG_WELCOME;
02930           break;
02931         case DLG_SETUP_TYPE:
02932           dwWizardState = DLG_LICENSE;
02933           break;
02934         case DLG_UPGRADE:
02935           dwWizardState = DLG_SETUP_TYPE;
02936           break;
02937         case DLG_SELECT_COMPONENTS:
02938           dwWizardState = DLG_SETUP_TYPE;
02939           break;
02940         case DLG_SELECT_ADDITIONAL_COMPONENTS:
02941           dwWizardState = DLG_SELECT_COMPONENTS;
02942           break;
02943         case DLG_WINDOWS_INTEGRATION:
02944           dwWizardState = DLG_SELECT_ADDITIONAL_COMPONENTS;
02945           break;
02946         case DLG_PROGRAM_FOLDER:
02947           dwWizardState = DLG_WINDOWS_INTEGRATION;
02948           break;
02949         case DLG_QUICK_LAUNCH:
02950           dwWizardState = DLG_PROGRAM_FOLDER;
02951           break;
02952         case DLG_ADDITIONAL_OPTIONS:
02953           dwWizardState = DLG_QUICK_LAUNCH;
02954           break;
02955         case DLG_START_INSTALL:
02956           dwWizardState = DLG_ADDITIONAL_OPTIONS;
02957           break;
02958 
02959         case DLG_ADVANCED_SETTINGS:
02960           dwWizardState = DLG_ADDITIONAL_OPTIONS;
02961           break;
02962 
02963         default:
02964           dwWizardState = DLG_WELCOME;
02965           break;
02966       }
02967     }
02968     else if(iDirection == OTHER_DLG_1)
02969     {
02970       switch(dwWizardState)
02971       {
02972         case DLG_ADDITIONAL_OPTIONS:
02973           dwWizardState = DLG_ADVANCED_SETTINGS;
02974           break;
02975 
02976         // You'll get here only if DLG_ADVANCED_SETTINGS is not displayed, which really should
02977         //   should never be the case unless DLG_ADDITIONAL_OPTIONS is also not displayed, since this
02978         //   is a button off that dialog.  But if the user turns this off in error, handling the case
02979         //   will keep from dropping into an infinite loop.
02980         case DLG_ADVANCED_SETTINGS:
02981           dwWizardState = DLG_ADDITIONAL_OPTIONS;
02982           break;
02983       }
02984     }
02985 
02986     switch(dwWizardState)
02987     {
02988       case DLG_WELCOME:
02989         if(diWelcome.bShowDialog)
02990         {
02991           hDlgCurrent = InstantiateDialog(hWndMain, dwWizardState, diWelcome.szTitle, DlgProcWelcome);
02992           bDone = TRUE;
02993         }
02994         break;
02995 
02996       case DLG_LICENSE:
02997         if(diLicense.bShowDialog)
02998         {
02999           hDlgCurrent = InstantiateDialog(hWndMain, dwWizardState, diLicense.szTitle, DlgProcLicense);
03000           bDone = TRUE;
03001         }
03002         break;
03003 
03004       case DLG_SETUP_TYPE:
03005         if(diSetupType.bShowDialog)
03006         {
03007           hDlgCurrent = InstantiateDialog(hWndMain, dwWizardState, diSetupType.szTitle, DlgProcSetupType);
03008           bDone = TRUE;
03009         }
03010         break;
03011 
03012       case DLG_UPGRADE:
03013         if(sgProduct.checkCleanupOnUpgrade)
03014         {
03015           char buf[MAX_BUF];
03016 
03017           // Found destination folder.  check to see if we're upgrading ontop
03018           // of a previous installation.  If so, we need to prompt the user
03019           // about removing the entire dir before installation happens.
03020           MozCopyStr(sgProduct.szPath, buf, sizeof(buf));
03021           AppendBackSlash(buf, sizeof(buf));
03022           lstrcat(buf, sgProduct.szProgramName);
03023           if(FileExists(buf))
03024           {
03025             char warningTitleString[MAX_BUF];
03026 
03027             GetPrivateProfileString("Messages", "MB_WARNING_STR", "",
03028                 warningTitleString, sizeof(warningTitleString),
03029                 szFileIniInstall);
03030 
03031             /* Prompt user if deleting target path is okay. Only show
03032              * prompt if the setup is running in normal mode, else
03033              * assume user wants deletion */
03034             if(sgProduct.mode == NORMAL)
03035             {
03036               hDlgCurrent = InstantiateDialog(hWndMain, dwWizardState,
03037                   warningTitleString, DlgProcUpgrade);
03038               bDone = TRUE;
03039             }
03040             else
03041               sgProduct.doCleanupOnUpgrade = TRUE;
03042           }
03043         }
03044 
03045         /* SiCNodeSetItemsSelected() is called from within DlgProcUpgrade().
03046          * If DlgProcUpgrade is not called (in the case of a !NORMAL install),
03047          * then we need to call it here. */
03048         if(sgProduct.mode != NORMAL)
03049           SiCNodeSetItemsSelected(dwSetupType);
03050 
03051         break;
03052 
03053       case DLG_SELECT_COMPONENTS:
03054         if((diSelectComponents.bShowDialog) && (sgProduct.dwCustomType == dwSetupType))
03055         {
03056           hDlgCurrent = InstantiateDialog(hWndMain, dwWizardState, diSelectComponents.szTitle, DlgProcSelectComponents);
03057           bDone = TRUE;
03058         }
03059         break;
03060 
03061       case DLG_SELECT_ADDITIONAL_COMPONENTS:
03062         if((diSelectAdditionalComponents.bShowDialog) && (GetAdditionalComponentsCount() > 0))
03063         {
03064           hDlgCurrent = InstantiateDialog(hWndMain, dwWizardState, diSelectAdditionalComponents.szTitle, DlgProcSelectAdditionalComponents);
03065           bDone = TRUE;
03066         }
03067         break;
03068 
03069       case DLG_WINDOWS_INTEGRATION:
03070         if(diWindowsIntegration.bShowDialog)
03071         {
03072           hDlgCurrent = InstantiateDialog(hWndMain, dwWizardState, diWindowsIntegration.szTitle, DlgProcWindowsIntegration);
03073           bDone = TRUE;
03074         }
03075         break;
03076 
03077       case DLG_PROGRAM_FOLDER:
03078         if(diProgramFolder.bShowDialog && (sgProduct.dwCustomType == dwSetupType))
03079         {
03080           hDlgCurrent = InstantiateDialog(hWndMain, dwWizardState, diProgramFolder.szTitle, DlgProcProgramFolder);
03081           bDone = TRUE;
03082         }
03083       break;
03084 
03085       case DLG_ADVANCED_SETTINGS:
03086         if(diAdvancedSettings.bShowDialog)
03087         {
03088           hDlgCurrent = InstantiateDialog(hWndMain, dwWizardState, diAdvancedSettings.szTitle, DlgProcAdvancedSettings);
03089           bDone = TRUE;
03090         }
03091         break;
03092 
03093      case DLG_QUICK_LAUNCH:
03094         if(diQuickLaunch.bShowDialog)
03095         {
03096           hDlgCurrent = InstantiateDialog(hWndMain, dwWizardState, diQuickLaunch.szTitle, DlgProcQuickLaunch);
03097           bDone = TRUE;
03098         }
03099         break;
03100 
03101      case DLG_ADDITIONAL_OPTIONS:
03102         do
03103         {
03104           hrValue = VerifyDiskSpace();
03105           if(hrValue == IDOK)
03106           {
03107             /* show previous visible window */
03108             iDirection = PREV_DLG;
03109           }
03110           else if(hrValue == IDCANCEL)
03111           {
03112             AskCancelDlg(hWndMain);
03113             hrValue = IDRETRY;
03114           }
03115         }while(hrValue == IDRETRY);
03116 
03117         if(hrValue != IDOK)
03118         {
03119           if(ShowAdditionalOptionsDialog() == TRUE)
03120           {
03121             hDlgCurrent = InstantiateDialog(hWndMain, dwWizardState, diAdditionalOptions.szTitle, DlgProcAdditionalOptions);
03122             bDone = TRUE;
03123           }
03124         }
03125         break;
03126 
03127       case DLG_START_INSTALL:
03128         if(diStartInstall.bShowDialog)
03129         {
03130           hDlgCurrent = InstantiateDialog(hWndMain, dwWizardState, diStartInstall.szTitle, DlgProcStartInstall);
03131           bDone = TRUE;
03132         }
03133         break;
03134 
03135       case DLG_COMMIT_INSTALL:
03136         gbProcessingXpnstallFiles = TRUE;
03137         CommitInstall();
03138         bDone = TRUE;
03139         break;
03140     }
03141   } while(!bDone);
03142 }
03143 
03144 void CommitInstall(void)
03145 {
03146   HRESULT hrErr;
03147   char    msgPleaseWait[MAX_BUF];
03148   char    szDestPath[MAX_BUF];
03149   char    szInstallLogFile[MAX_BUF];
03150   long    RetrieveResults;
03151 
03152   GetPrivateProfileString("Messages", "MSG_PLEASE_WAIT", "", msgPleaseWait, sizeof(msgPleaseWait), szFileIniInstall);
03153   ShowMessage(msgPleaseWait, TRUE);
03154   ClosePreviousDialog();
03155 
03156   LogISShared();
03157   LogISDestinationPath();
03158   LogISSetupType();
03159   LogISComponentsSelected();
03160   LogISComponentsToDownload();
03161   LogISDiskSpace(gdsnComponentDSRequirement);
03162 
03163   lstrcpy(szDestPath, sgProduct.szPath);
03164   if(*sgProduct.szSubPath != '\0')
03165   {
03166     AppendBackSlash(szDestPath, sizeof(szDestPath));
03167     lstrcat(szDestPath, sgProduct.szSubPath);
03168   }
03169   AppendBackSlash(szDestPath, sizeof(szDestPath));
03170 
03171   /* Create the destination path here in case it had not been created,
03172    * as in the case of silent or auto mode installs */
03173   if(CreateDirectoriesAll(szDestPath, ADD_TO_UNINSTALL_LOG) != WIZ_OK)
03174   {
03175     char buf[MAX_BUF];
03176     char errorCreateDir[MAX_BUF];
03177     char pathToShow[MAX_PATH];
03178 
03179     /* reformat the path to display so that it'll be readable in the
03180      * error dialog shown */
03181     _snprintf(pathToShow, sizeof(pathToShow), "\"%s\" ", szDestPath);
03182     pathToShow[sizeof(pathToShow) - 1] = '\0';
03183     if(GetPrivateProfileString("Messages", "ERROR_CREATE_DIRECTORY", "", errorCreateDir, sizeof(errorCreateDir), szFileIniInstall))
03184       wsprintf(buf, errorCreateDir, pathToShow);
03185     assert(*buf != '\0');
03186     PrintError(buf, ERROR_CODE_HIDE);
03187     PostQuitMessage(1);
03188     return;
03189   }
03190 
03191   /* Set global var, that determines where the log file is to update, to
03192    * not use the TEMP dir *before* the FileCopy() calls because we want
03193    * to log the FileCopy() calls to where the log files were copied to.
03194    * This is possible because the logging, that is done within the
03195    * FileCopy() function, is done after the actual copy
03196    */
03197   gbILUseTemp = FALSE;
03198 
03199   /* copy the install_wizard.log file from the temp\ns_temp dir to
03200    * the destination dir and use the new destination file to continue
03201    * logging.
03202    */
03203   lstrcpy(szInstallLogFile, szTempDir);
03204   AppendBackSlash(szInstallLogFile, sizeof(szInstallLogFile));
03205   lstrcat(szInstallLogFile, FILE_INSTALL_LOG);
03206   FileCopy(szInstallLogFile, szDestPath, FALSE, FALSE);
03207   DeleteFile(szInstallLogFile);
03208 
03209   /* copy the install_status.log file from the temp\ns_temp dir to
03210    * the destination dir and use the new destination file to continue
03211    * logging.
03212    */
03213   lstrcpy(szInstallLogFile, szTempDir);
03214   AppendBackSlash(szInstallLogFile, sizeof(szInstallLogFile));
03215   lstrcat(szInstallLogFile, FILE_INSTALL_STATUS_LOG);
03216   FileCopy(szInstallLogFile, szDestPath, FALSE, FALSE);
03217   DeleteFile(szInstallLogFile);
03218 
03219   /* PRE_DOWNLOAD process file manipulation functions */
03220   RetrieveResults = WIZ_OK;
03221   if(sgProduct.bInstallFiles)
03222   {
03223     ProcessFileOpsForAll(T_PRE_DOWNLOAD);
03224     RetrieveResults = RetrieveArchives();
03225   }
03226 
03227   if(RetrieveResults == WIZ_OK)
03228   {
03229     // Clean up old versions of GRE previously installed.
03230     // These GREs should only be fully uninstalled if they were only
03231     // being used by the mozilla that we're installing over/ontop of
03232     // (upgrade scenario).
03233     // We should only do this type of cleanup if we're about to install'
03234     // GRE in shared mode.
03235     //
03236     // This should only be called when the installer is installing GRE!
03237     if(IsInstallerProductGRE())
03238       CleanupOrphanedGREs();
03239 
03240     if(sgProduct.bInstallFiles)
03241     {
03242       /* Check to see if Turbo is required.  If so, set the
03243        * appropriate Windows registry keys */
03244       SetTurboArgs();
03245 
03246       /* POST_DOWNLOAD process file manipulation functions */
03247       ProcessFileOpsForAll(T_POST_DOWNLOAD);
03248       /* PRE_XPCOM process file manipulation functions */
03249       ProcessFileOpsForAll(T_PRE_XPCOM);
03250 
03251       /* save the installer files in the local machine */
03252       if(diAdditionalOptions.bSaveInstaller)
03253         SaveInstallerFiles();
03254 
03255       if(CheckInstances())
03256       {
03257         bSDUserCanceled = TRUE;
03258         CleanupXpcomFile();
03259         PostQuitMessage(0);
03260         return;
03261       }
03262 
03263       /* Remove the previous installation of the product here.
03264        * This should be done before processing the Xpinstall engine. */
03265       if(sgProduct.doCleanupOnUpgrade)
03266       {
03267         SetSetupState(SETUP_STATE_REMOVING_PREV_INST);
03268         CleanupOnUpgrade();
03269       }
03270 
03271       if(gbDownloadTriggered || gbPreviousUnfinishedDownload)
03272         SetSetupState(SETUP_STATE_UNPACK_XPCOM);
03273 
03274       if(ProcessXpinstallEngine() != WIZ_OK)
03275       {
03276         bSDUserCanceled = TRUE;
03277         CleanupXpcomFile();
03278         PostQuitMessage(0);
03279         ShowMessage(NULL, FALSE);
03280         return;
03281       }
03282 
03283       if(gbDownloadTriggered || gbPreviousUnfinishedDownload)
03284         SetSetupState(SETUP_STATE_INSTALL_XPI); // clears and sets new setup state
03285 
03286       /* POST_XPCOM process file manipulation functions */
03287       ProcessFileOpsForAll(T_POST_XPCOM);
03288       /* PRE_SMARTUPDATE process file manipulation functions */
03289       ProcessFileOpsForAll(T_PRE_SMARTUPDATE);
03290 
03291       lstrcat(szDestPath, "uninstall\\");
03292       CreateDirectoriesAll(szDestPath, ADD_TO_UNINSTALL_LOG);
03293       hrErr = SmartUpdateJars();
03294     }
03295     else
03296       hrErr = WIZ_OK;
03297 
03298     ShowMessage(msgPleaseWait, TRUE);
03299     if((hrErr == WIZ_OK) || (hrErr == 999))
03300     {
03301       if(sgProduct.bInstallFiles)
03302         UpdateJSProxyInfo();
03303 
03304       /* POST_SMARTUPDATE process file manipulation functions */
03305       ProcessFileOpsForAll(T_POST_SMARTUPDATE);
03306 
03307       if(sgProduct.bInstallFiles)
03308       {
03309         /* PRE_LAUNCHAPP process file manipulation functions */
03310         ProcessFileOpsForAll(T_PRE_LAUNCHAPP);
03311 
03312         LaunchApps();
03313 
03314         // Refresh system icons if necessary
03315         if(gSystemInfo.bRefreshIcons)
03316           RefreshIcons();
03317 
03318         UnsetSetupState(); // clear setup state
03319         ClearWinRegUninstallFileDeletion();
03320         if(!gbIgnoreProgramFolderX)
03321           ProcessProgramFolderShowCmd();
03322 
03323         CleanupArgsRegistry();
03324         CleanupPreviousVersionRegKeys();
03325 
03326         /* POST_LAUNCHAPP process file manipulation functions */
03327         ProcessFileOpsForAll(T_POST_LAUNCHAPP);
03328         /* DEPEND_REBOOT process file manipulation functions */
03329         ProcessFileOpsForAll(T_DEPEND_REBOOT);
03330       }
03331 
03332       CleanupXpcomFile();
03333       ShowMessage(NULL, FALSE);
03334       if(NeedReboot())
03335       {
03336         LogExitStatus("Reboot");
03337         if(sgProduct.mode == NORMAL)
03338           hDlgCurrent = InstantiateDialog(hWndMain, DLG_RESTART, diReboot.szTitle, DlgProcReboot);
03339         else
03340           PostQuitMessage(0);
03341       }
03342       else
03343         PostQuitMessage(0);
03344     }
03345     else
03346     {
03347       CleanupXpcomFile();
03348       PostQuitMessage(0);
03349     }
03350   }
03351   else
03352   {
03353     bSDUserCanceled = TRUE;
03354     CleanupXpcomFile();
03355     CleanupArgsRegistry();
03356     PostQuitMessage(0);
03357   }
03358   ShowMessage(NULL, FALSE);
03359   gbProcessingXpnstallFiles = FALSE;
03360 }