home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / IShield for Visual C++ 6.0 / DATA1.CAB / Include_Files / SDOPTBUT.RUL < prev    next >
Encoding:
Text File  |  1997-11-20  |  8.8 KB  |  220 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    : sdaskopt.rul                                              */
  11.  /*                                                                       */
  12.  /*   Purpose : This file contains the code for the SdOptionsButtons      */
  13.  /*             script dialog function.                                   */
  14.  /*                                                                       */
  15.  /*=======================================================================*/
  16.  
  17.  /*------------------------------------------------------------------------*/
  18.  /*                                                                        */
  19.  /*   Function: SdOptionsButtons                                           */
  20.  /*                                                                        */
  21.  /*   Descrip:  This dialog will let user display an array of bitmap       */
  22.  /*             buttons along with messgaes.  The resource (dialog)        */
  23.  /*             governs how and where the items are positioned.            */
  24.  /*   Misc:                                                                */
  25.  /*                                                                        */
  26.  /*------------------------------------------------------------------------*/
  27. function SdOptionsButtons( szTitle, szMsg, listButton, listDescrip )
  28.           STRING  szDlg, szTemp;
  29.           STRING  svItem[ MAX_STRING ];
  30.           HWND    hwndDlg;
  31.           NUMBER  nId, nTemp;
  32.           NUMBER  nReturn, nMessage;
  33.           BOOL    bDone, bChange;
  34.         begin
  35.  
  36.            szDlg     = SD_DLG_OPTIONSBUTTONS;
  37.            nSdDialog = SD_NDLG_OPTIONSBUTTONS;
  38.  
  39.            // record data produced by this dialog
  40.            if (MODE=SILENTMODE) then
  41.              SdMakeName( szAppKey, szDlg, szTitle, nSdOptionsButtons );
  42.              SilentReadData( szAppKey, "Result", DATA_NUMBER, szTemp, nId );
  43.              return nId;
  44.            endif;
  45.  
  46.            // ensure general initialization is complete
  47.            if (!bSdInit) then
  48.               SdInit();
  49.            endif;
  50.  
  51.            if (EzDefineDialog( szDlg, "", "", SD_NDLG_OPTIONSBUTTONS ) = DLG_ERR) then
  52.               return -1;
  53.            endif;
  54.  
  55.  
  56.            // Loop in dialog until the user selects a standard button
  57.            bDone = FALSE;
  58.  
  59.            while (!bDone)
  60.  
  61.               nId = WaitOnDialog( szDlg );
  62.  
  63.               switch (nId)
  64.               case DLG_INIT:
  65.  
  66.                    if( szMsg != "" ) then
  67.                        SdSetStatic( szDlg, SD_COMPONENT_MSG, szMsg );
  68.                    endif;
  69.  
  70.                    Delay(1);
  71.                    hwndDlg = CmdGetHwndDlg( szDlg );
  72.                    SdGeneralInit( szDlg, hwndDlg, STYLE_NORMAL, szSdProduct );
  73.                    if(szTitle != "") then
  74.                        SetWindowText(hwndDlg, szTitle);
  75.                    endif;
  76.  
  77.                    // initialize the buttons and static fields
  78.                    SdOptionsButtonsInit( szDlg, hwndDlg, listButton, listDescrip );
  79.  
  80.               case SD_PBUT_OK:
  81.                    nId   = OK;
  82.                    bDone = TRUE;
  83.  
  84.               case SD_PBUT_BACK:
  85.                    nId    = BACK;
  86.                    bDone  = TRUE;
  87.  
  88.               case DLG_ERR:
  89.                    SdError( -1, "SdOptionsButtons" );
  90.                    nId   = -1;
  91.                    bDone = TRUE;
  92.  
  93.               case DLG_CLOSE:
  94.                    SdCloseDlg( hwndDlg, nId, bDone );
  95.  
  96.               default:
  97.                    // check standard handling
  98.                    if (SdIsStdButton( nId ) && SdDoStdButton( nId )) then
  99.                        bDone = TRUE;
  100.                    else
  101.                        if ((nId >= 100) && (nId < 200)) then
  102.                           bDone = TRUE; // user button
  103.                        endif;
  104.                    endif;
  105.               endswitch;
  106.  
  107.            endwhile;
  108.  
  109.            EndDialog( szDlg );
  110.            ReleaseDialog( szDlg );
  111.  
  112.            SdUnInit();
  113.  
  114.            // record data produced by this dialog
  115.            SdMakeName( szAppKey, szDlg, szTitle, nSdOptionsButtons );
  116.            SilentWriteData( szAppKey, "Result", DATA_NUMBER, "", nId );
  117.  
  118.            return nId;
  119.  
  120.         end;
  121.  
  122.  /*------------------------------------------------------------------------*/
  123.  /*                                                                        */
  124.  /*   Function: SdOptionsButtonsInit                                       */
  125.  /*                                                                        */
  126.  /*   Descrip:  This dialog will initialize the static and button controls */
  127.  /*             in the dialog.  This includes hiding controls as           */
  128.  /*             appropriate.                                               */
  129.  /*   Misc:                                                                */
  130.  /*                                                                        */
  131.  /*------------------------------------------------------------------------*/
  132. function SdOptionsButtonsInit( szDlg, hwndDlg, listButton, listDescrip )
  133.           NUMBER        nResult, nFirstChar;
  134.           LIST          listTemp;
  135.           STRING        szMsg[ MAX_STRING ];
  136.           STRING        szNew[ MAX_STRING ];
  137.           HWND          hwndButton, hwndNext;
  138.         begin
  139.  
  140.          // set buttons, ensure @ is in the first set element
  141.          nResult  = ListGetFirstString( listButton, szMsg );
  142.          listTemp = ListCreate( STRINGLIST );
  143.  
  144.          while (nResult = 0)
  145.               szNew = szMsg;
  146.               GetByte( nFirstChar, szMsg, 0 );
  147.               if (nFirstChar != 64) then // Add '@' to start of string
  148.                  Sprintf( szNew, "@%s", szMsg );
  149.               endif;
  150.               ListAddString( listTemp, szNew, AFTER );
  151.               nResult = ListGetNextString( listButton, szMsg );
  152.          endwhile;
  153.  
  154.          // set controls
  155.          SdSetSequentialItems( szDlg, hwndDlg, SD_PBUT_STARTBUTTON1, listTemp );
  156.          SdSetSequentialItems( szDlg, hwndDlg, SD_STA_STARTMSG1, listDescrip );
  157.  
  158.          ListDestroy( listTemp );
  159.  
  160.          // check if next button is not enabled, if not then make first button focus
  161.          hwndNext   = GetDlgItem( hwndDlg, OK );
  162.          hwndButton = GetDlgItem( hwndDlg, SD_PBUT_STARTBUTTON1 );
  163.          if (!IsWindowEnabled( hwndNext )) then
  164.             SetFocus( hwndButton );
  165.          endif;
  166.  
  167.         end;
  168.  
  169.  /*------------------------------------------------------------------------*/
  170.  /*                                                                        */
  171.  /*   Function: SdSetSequentialItems                                       */
  172.  /*                                                                        */
  173.  /*   Descrip:  This dialog will set a list to a sequential set of controls*/
  174.  /*             It will set the window text.                               */
  175.  /*   Misc:                                                                */
  176.  /*                                                                        */
  177.  /*------------------------------------------------------------------------*/
  178. function SdSetSequentialItems( szDlg, hwndDlg, nStart, list )
  179.           HWND          hwnd;
  180.           INT           nResult, nId;
  181.           BOOL          bOutOfControls;
  182.           STRING        szMsg[ MAX_STRING ];
  183.         begin
  184.  
  185.            nResult        = ListGetFirstString( list, szMsg );
  186.            nId            = nStart;
  187.            bOutOfControls = FALSE;
  188.  
  189.            while (nResult = 0)
  190.               hwnd = GetDlgItem( hwndDlg, nId );
  191.  
  192.               if (hwnd) then
  193.                 CtrlSetText( szDlg, nId, szMsg );
  194.                 nResult = ListGetNextString( list, szMsg );
  195.                 nId = nId + 1;
  196.               else
  197.                 bOutOfControls = TRUE;
  198.                 nResult = 1;
  199.               endif;
  200.  
  201.            endwhile;
  202.  
  203.            // if not out of controls then hide the remaining ones
  204.            if (bOutOfControls = FALSE) then
  205.  
  206.               hwnd = 1;
  207.               while (hwnd)
  208.                  hwnd = GetDlgItem( hwndDlg, nId );
  209.                  if (hwnd) then
  210.                     ShowWindow( hwnd, SW_HIDE );
  211.                  endif;
  212.                  nId = nId + 1;
  213.               endwhile;
  214.  
  215.            endif;
  216.  
  217.         end;
  218.  
  219.  
  220.