home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / IShield for Visual C++ 6.0 / DATA1.CAB / Include_Files / SDCOMDLG.RUL < prev    next >
Encoding:
Text File  |  1997-11-20  |  6.9 KB  |  172 lines

  1.  
  2.  /*=======================================================================*/
  3.  /*                                                                       */
  4.  /*           (c) InstallShield Software Corporation (1996-1997)          */
  5.  /*            (c)  InstallShield Corporation  (1990-1996)                */
  6.  /*                       Schaumburg, Illinois 60173                      */
  7.  /*                          All Rights Reserved                          */
  8.  /*                           InstallShield (R)                           */
  9.  /*                                                                       */
  10.  /*   File    : sdcomdlg.rul                                              */
  11.  /*                                                                       */
  12.  /*   Purpose : This file contains the code for the SdComponentDialog     */
  13.  /*             script dialog function.                                   */
  14.  /*                                                                       */
  15.  /*=======================================================================*/
  16.  
  17.  
  18.  /*------------------------------------------------------------------------*/
  19.  /*                                                                        */
  20.  /*   Function: SdComponentDialog                                          */
  21.  /*                                                                        */
  22.  /*   Descrip:  This dialog will let user choose different parts of the    */
  23.  /*             software to install based on the name and disk space.      */
  24.  /*   Misc:                                                                */
  25.  /*                                                                        */
  26.  /*------------------------------------------------------------------------*/
  27. function SdComponentDialog(szTitle, szMsg, svDir, szComponents)
  28.           STRING  szDlg, szFreeSpace, szReqSpace, szTemp, svDirLoc;
  29.           NUMBER  nId, nTemp, nComponentView;
  30.           HWND    hwndDlg, hwndListBox;
  31.           BOOL    bDone, bChange;
  32.         begin
  33.  
  34.            szDlg     = SD_DLG_COMPONENTDIALOG;
  35.            nSdDialog = SD_NDLG_COMPONENTDIALOG;
  36.            svDirLoc  = svDir;
  37.  
  38.            // record data produced by this dialog
  39.            if (MODE=SILENTMODE) then
  40.              SdMakeName( szAppKey, szDlg, szTitle, nSdComponentDialog );
  41.              SilentReadData( szAppKey, "Result", DATA_NUMBER, szTemp, nId );
  42.              if ((nId != BACK) && (nId != CANCEL)) then
  43.                 SilentReadData( szAppKey, "Component", DATA_COMPONENT, szComponents, nTemp );
  44.                 SilentReadData( szAppKey, "szDir", DATA_STRING, svDir, nTemp );
  45.              endif;
  46.  
  47.              return nId;
  48.            endif;
  49.  
  50.            // ensure general initialization is complete
  51.            if (!bSdInit) then
  52.               SdInit();
  53.            endif;
  54.  
  55.            if (EzDefineDialog( szDlg, "", "", SD_NDLG_COMPONENTDIALOG ) = DLG_ERR) then
  56.               return -1;
  57.            endif;
  58.  
  59.  
  60.            // Loop in dialog until the user selects a standard button
  61.            bDone = FALSE;
  62.  
  63.            while (!bDone)
  64.  
  65.               nId = WaitOnDialog( szDlg );
  66.  
  67.               switch (nId)
  68.               case DLG_INIT:
  69.  
  70.                    if( szMsg != "" ) then
  71.                        SdSetStatic( szDlg, SD_COMPONENT_MSG, szMsg );
  72.                    endif;
  73.  
  74.                    CtrlSetText( szDlg, 0x80000000 | SD_STA_DESTDIR, svDirLoc );
  75.  
  76.                    hwndDlg = CmdGetHwndDlg( szDlg );
  77.                    SdGeneralInit( szDlg, hwndDlg, STYLE_NORMAL, szSdProduct );
  78.  
  79.                    if(szTitle != "") then
  80.                        SetWindowText(hwndDlg, szTitle);
  81.                    endif;
  82.  
  83.                    nComponentView =  SdCreateComponentView( hwndDlg, SD_LISTBOX, szComponents, svDirLoc );
  84.                    if (!nComponentView) then
  85.                        SdError( -1, "SdComponentDialog" );
  86.                        nId = -1;
  87.                        bDone = TRUE;
  88.                    endif;
  89.  
  90.                    ComponentViewRefresh( nComponentView, 0 );
  91.  
  92.                    hwndListBox = GetDlgItem( hwndDlg, SD_LISTBOX );
  93.                    SetFocus( hwndListBox );
  94.  
  95.               case SD_PBUT_CHANGEDIR:
  96.                    nTemp = MODE;
  97.                    MODE  = NORMALMODE;
  98.                    SelectDir( "",
  99.                               "",
  100.                               svDirLoc,
  101.                               TRUE );
  102.                    CtrlSetText( szDlg, 0x80000000 | SD_STA_DESTDIR, svDirLoc );
  103.                    ComponentViewSetInfo( nComponentView, COMPONENT_VIEW_TARGETLOCATION, 0,  svDirLoc );
  104.                    ComponentViewRefresh( nComponentView, 0 );
  105.  
  106.                    MODE = nTemp;
  107.  
  108.               case SD_PBUT_DISKSPACE:
  109.  
  110.                    CtrlGetText( szDlg, SD_SPACEAVI, szFreeSpace );
  111.                    CtrlGetText( szDlg, SD_SPACEREQ, szReqSpace );
  112.                    SdDiskSpace( svDirLoc, szFreeSpace, szReqSpace, bChange );
  113.  
  114.                    if( bChange = TRUE ) then
  115.                       CtrlSetText( szDlg, 0x80000000 | SD_STA_DESTDIR, svDirLoc );
  116.                       CtrlSetText( szDlg, SD_SPACEAVI, szFreeSpace );
  117.  
  118.                       ComponentViewSetInfo( nComponentView, COMPONENT_VIEW_TARGETLOCATION, 0,  svDirLoc );
  119.                       ComponentViewRefresh( nComponentView, 0 );
  120.  
  121.                    endif;
  122.  
  123.  
  124.               case SD_PBUT_OK:
  125.                    if( StrCompare(svDirLoc, "") && !SdComponentDlgCheckSpace( szComponents, szDlg, svDirLoc ) ) then
  126.                       MessageBox( szSdStr_NotEnoughSpace, WARNING );
  127.                    else
  128.  
  129.                       svDir = svDirLoc;
  130.  
  131.                       nId   = OK;
  132.                       bDone = TRUE;
  133.  
  134.                    endif;
  135.  
  136.               case BACK:
  137.                    nId    = BACK;
  138.                    bDone  = TRUE;
  139.  
  140.               case DLG_ERR:
  141.                    SdError( -1, "SdComponentDialog" );
  142.                    nId   = -1;
  143.                    bDone = TRUE;
  144.  
  145.               case DLG_CLOSE:
  146.                    SdCloseDlg( hwndDlg, nId, bDone );
  147.  
  148.               default:
  149.                    // check standard handling
  150.                    if (SdIsStdButton( nId ) && SdDoStdButton( nId )) then
  151.                        bDone = TRUE;
  152.                    endif;
  153.               endswitch;
  154.  
  155.            endwhile;
  156.  
  157.            EndDialog( szDlg );
  158.            ReleaseDialog( szDlg );
  159.            ComponentViewDestroy( nComponentView );
  160.  
  161.            SdUnInit( );
  162.  
  163.            // record data produced by this dialog
  164.            SdMakeName( szAppKey, szDlg, szTitle, nSdComponentDialog );
  165.            SilentWriteData( szAppKey, "szDir", DATA_STRING, svDir, nTemp );
  166.            SilentWriteData( szAppKey, "Component", DATA_COMPONENT, szComponents, nTemp );
  167.            SilentWriteData( szAppKey, "Result", DATA_NUMBER, "", nId );
  168.  
  169.            return nId;
  170.  
  171.         end;
  172.