home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / GETSCRN.EXE / SOURCE / POPUP.C < prev    next >
Text File  |  1990-06-24  |  25KB  |  858 lines

  1. /*
  2.  
  3.  
  4.  
  5.  
  6.                                 POPUP.c
  7.  
  8.         Copyright (c) 1990 by:  Arthur Kevin McGrath
  9.                                 Contract Engineers
  10.                                 P. O. Box 128
  11.                                 Barboursville, VA  22923
  12.  
  13.                                 703/832-7025
  14.  
  15.  
  16.   ALL RIGHTS ARE RESERVED.  You may not copy this program in any way
  17.   except to make back-up copies FOR YOUR OWN USE.  If you copy this
  18.   program for any reason without WRITTEN PERMISSION from the above
  19.   named copyright owner (except to make back-up copies FOR YOUR OWN USE),
  20.   you are breaking the Copyright Laws of the United States.  You will go
  21.   to jail for one year and pay a $50,000 fine.
  22.  
  23.  
  24.  
  25.  
  26. */
  27.  
  28.  
  29.  
  30. #include        <stdio.h>
  31. #include        <stdlib.h>
  32. #include        <ctype.h>
  33.  
  34.  
  35. #define INCL_BASE
  36. #define INCL_VIO
  37. #include <os2.h>
  38.  
  39. #include "capture.h"
  40. #include "extern.h"
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. /*  GET_FILE_NAME() gets the following information from the user:
  48.         1.  What FILE_NAME will hold the data we are about
  49.             to capture?
  50.         2.  What directory will hold this file?
  51.         3.  What drive will this directory live on?
  52.  
  53.     THE CALLING FUNCTION IS RESPONSIBLE FOR ENSURING THAT THE
  54.     POP UP WINDOW DIMENSIONS ARE AT LEAST AS LARGE AS THE TEXT
  55.     PLACED INSIDE!!!!!
  56.  
  57.     This function requires the following parameters:
  58.         LEFT        the column number of the first column
  59.                     of text in the pop up
  60.         RIGHT       the column number of the last column
  61.                     of text in the pop up
  62.         TOP         the row number of the first line of text in the pop up
  63.         FILE_NAME       The address of a string that will
  64.                         hold the name of a file that will
  65.                         receive the captured data from the
  66.                         PHYSICAL VIDEO BUFFER.
  67.  
  68.     This function returns the following return codes:
  69.         NOTHING ( VOID )                                */
  70. void    get_file_name(  USHORT  left,
  71.                     USHORT right,
  72.                     USHORT top,
  73.                     char   *file_name  )
  74. {
  75.     UCHAR       ok = FALSE, attribute = NORMAL_TEXT_COLOR;
  76.     USHORT      error;
  77.     USHORT      column, row;
  78.     USHORT      length;
  79.     char        drive_letter[ 2 ], directory_name[ LONGEST_PATH_NAME ];
  80.     char                file[ LONGEST_FILE_NAME ];
  81.     char                current_path[ LONGEST_PATH_NAME ];
  82.     KBDKEYINFO          character;
  83.     HKBD                keyboard;
  84.     struct screen_text  response, back_slash, colon;
  85.     USHORT              drive_number;
  86.     ULONG               drive_map, x;
  87.     unsigned            valid_drive;
  88.  
  89.  
  90.  
  91.     /*  Initialize the back_slash structure.    */
  92.     back_slash.letter = ( UCHAR )'\\';
  93.     back_slash.attribute = NORMAL_TEXT_COLOR;
  94.  
  95.     /*  Initialize the colon structure. */
  96.     colon.letter = ( UCHAR )':';
  97.     colon.attribute = NORMAL_TEXT_COLOR;
  98.  
  99.     /*  Find out what other drives exist on this system.    */
  100.     error = DosQCurDisk( &drive_number, &drive_map );
  101.  
  102.     /*  Find out the current drive and path.    */
  103.     length = ( USHORT )sizeof( current_path );
  104.     error = DosQCurDir( drive_number,
  105.                     ( BYTE *)current_path,
  106.                     &length     );
  107.  
  108.     /*  Initialize our default path name.  If the user has specified
  109.         a default path at the command line, use that.  If not, use
  110.         the current path as the default.    */
  111.     if( default_path_name[0] == '\0' )
  112.     {
  113.         thread_copy( default_path_name, current_path );
  114.  
  115.     }
  116.  
  117.     /*  Make sure the drive string ends in a NULL character.    */
  118.     drive_letter[1] = '\0';
  119.  
  120.     /*  Initialize our drive prompt.    */
  121.     if( default_drive_name != '\0' )
  122.     {
  123.         drive_letter[0] = default_drive_name;
  124.  
  125.     }
  126.     else
  127.     {
  128.         drive_letter[0] = ( char )('@' + drive_number);
  129.  
  130.     }
  131.  
  132.     response.attribute = NORMAL_TEXT_COLOR;
  133.     response.letter = ( UCHAR )drive_letter[0];
  134.  
  135.     /*  Label the pop up window.    */
  136.     length = thread_strlen( get_file_popup_title );
  137.     column = left + center_the_line( left,
  138.                                     right,
  139.                                     length      );
  140.     error = VioWrtCharStrAtt( get_file_popup_title,
  141.                     length,
  142.                     top, column,
  143.                     &attribute,
  144.                     DEFAULT_SCREEN_HANDLE );
  145.  
  146.  
  147.  
  148.     /*  Put the prompts on the screen in the correct locations. */
  149.     row = top + 2;
  150.     error = VioWrtCharStrAtt( drive_prompt, thread_strlen( drive_prompt ),
  151.                     row, left,
  152.                     &attribute,
  153.                     DEFAULT_SCREEN_HANDLE );
  154.  
  155.     /*  Echo the character back to the screen.  */
  156.     column = left + thread_strlen( drive_prompt ) + 3;
  157.     error = VioWrtNCell( ( BYTE *)&response,
  158.                             1,
  159.                             row,
  160.                             column,
  161.                             DEFAULT_SCREEN_HANDLE  );
  162.  
  163.     /*  Put the colon in the column next to the DRIVE LETTER.   */
  164.     column++;
  165.     error = VioWrtNCell( ( BYTE *)&colon,
  166.                             1,
  167.                             row,
  168.                             column,
  169.                             DEFAULT_SCREEN_HANDLE  );
  170.  
  171.  
  172.  
  173.     /*  Prompt for the DIRECTORY NAME.      */
  174.     row += 2;
  175.     length = thread_strlen( directory_prompt );
  176.     column = left + center_the_line( left,
  177.                                     right,
  178.                                     length      );
  179.     error = VioWrtCharStrAtt( directory_prompt,
  180.                     length,
  181.                     row, column,
  182.                     &attribute,
  183.                     DEFAULT_SCREEN_HANDLE );
  184.  
  185.  
  186.  
  187.  
  188.     /*  Prompt for the FILE NAME.   */
  189.     row += 3;
  190.     column = left + center_the_line( left,
  191.                                     right,
  192.                                     length      );
  193.  
  194.     length = thread_strlen( file_prompt );
  195.  
  196.     error = VioWrtCharStrAtt( file_prompt,
  197.                     length,
  198.                     row, column,
  199.                     &attribute,
  200.                     DEFAULT_SCREEN_HANDLE );
  201.  
  202.  
  203.  
  204.     /*  Ask if everything is OK.    */
  205.     row += 3;
  206.     column = left;
  207.     error = VioWrtCharStrAtt( ok_prompt,
  208.                     thread_strlen( ok_prompt ),
  209.                     row, column,
  210.                     &attribute,
  211.                     DEFAULT_SCREEN_HANDLE );
  212.  
  213.  
  214.  
  215.  
  216.     /*  Get the responses to the above prompts. */
  217.     error = KbdOpen( &keyboard );
  218.  
  219.     error = KbdGetFocus( IO_WAIT, keyboard );
  220.  
  221.     while( !ok )
  222.     {
  223.         /*  Position the cursor.    */
  224.         row = top + 2;
  225.         column = left + thread_strlen( drive_prompt ) + 3;
  226.  
  227.         for( valid_drive = FALSE; !valid_drive; )
  228.         {
  229.             response.letter = ( UCHAR )drive_letter[0];
  230.             error = VioSetCurPos( row, column, DEFAULT_SCREEN_HANDLE );
  231.  
  232.             /*  Get the DRIVE letter.   */
  233.             error = KbdCharIn( &character, IO_WAIT, keyboard );
  234.  
  235.             if( ( character.chChar == '\n' ) || ( character.chChar == '\r' )   )
  236.             {
  237.                 drive_letter[0] = response.letter;
  238.  
  239.             }
  240.             else
  241.             {
  242.                 drive_letter[0] = response.letter = ( UCHAR )toupper( character.chChar );
  243.  
  244.             }
  245.  
  246.             /*  Echo the character back to the screen.  */
  247.             error = VioWrtNCell( ( BYTE *)&response,
  248.                             1,
  249.                             row,
  250.                             column,
  251.                             DEFAULT_SCREEN_HANDLE  );
  252.  
  253.             /*  Make sure we got a valid drive letter.  */
  254.             x = ( ULONG )( 1L  <<       ( drive_letter[0] - 'A' )  );
  255.  
  256.             /*  If this is TRUE, we have a valid drive. */
  257.             if( x & drive_map )
  258.             {
  259.                 valid_drive = TRUE;
  260.  
  261.             }
  262.             else
  263.             {
  264.                 valid_drive = FALSE;
  265.  
  266.             }
  267.  
  268.  
  269.         }
  270.  
  271.         /*  Position the cursor.    */
  272.         row += 3;
  273.         column = left + 1;
  274.  
  275.         /*      Put the BACK SLASH character on the screen just before the DIRECTORY name.      */
  276.         error = VioWrtNCell( ( BYTE *)&back_slash,
  277.                             1,
  278.                             row,
  279.                             column,
  280.                             DEFAULT_SCREEN_HANDLE  );
  281.  
  282.         /*  Get the DIRECTORY NAME.         */
  283.         column++;
  284.  
  285.         get_string( default_path_name,
  286.                     directory_name,
  287.                     sizeof( directory_name ),
  288.                     row,
  289.                     column, right - 2 - left,
  290.                     keyboard       );
  291.  
  292.         /*  Position the cursor.    */
  293.         row += 3;
  294.         column--;
  295.  
  296.         /*      Put the BACK SLASH character on the screen just before the FILE name.   */
  297.         error = VioWrtNCell( ( BYTE *)&back_slash,
  298.                             1,
  299.                             row,
  300.                             column,
  301.                             DEFAULT_SCREEN_HANDLE  );
  302.  
  303.         /*  Get tye FILE NAME.  */
  304.         column++;
  305.  
  306.         get_string( default_file_name,
  307.                     file,
  308.                     sizeof( file ),
  309.                     row,
  310.                     column, right - 2 - left,
  311.                     keyboard       );
  312.  
  313.         /*  Trap the keyboard.  Limit input to the YES character
  314.             or the NO character.        */
  315.         row += 2;
  316.         column = left + thread_strlen( ok_prompt ) + 3;
  317.  
  318.         do
  319.         {
  320.             /*  Position the cursor.    */
  321.             error = VioSetCurPos( row, column, DEFAULT_SCREEN_HANDLE );
  322.  
  323.  
  324.             /*  Find out if everything is OK.   */
  325.             error = KbdCharIn( &character, IO_WAIT, keyboard );
  326.             character.chChar = ( UCHAR )toupper( character.chChar );
  327.  
  328.             response.letter = character.chChar;
  329.  
  330.             /*  Echo the character back to the screen.  */
  331.             error = VioWrtNCell( ( BYTE *)&response,
  332.                             1,
  333.                             row,
  334.                             column,
  335.                             DEFAULT_SCREEN_HANDLE  );
  336.  
  337.         }while( ( character.chChar != yes)
  338.                             &&
  339.                 ( character.chChar != no )   );
  340.  
  341.  
  342.         ok = ( character.chChar == yes )  ?  ( UCHAR )TRUE : ( UCHAR )FALSE;
  343.         error = KbdFlushBuffer( keyboard );
  344.  
  345.  
  346.     }
  347.  
  348.     if( directory_name[0] != '\0' )
  349.     {
  350.         /*  Combine the DRIVE, DIRECTORY, and FILE NAME
  351.             into one fully qualified file name. */
  352.         sprintf( file_name, "%s:\\%s\\%s\0",
  353.                         drive_letter,
  354.                         directory_name,
  355.                         file        );
  356.  
  357.     }
  358.     else
  359.     {
  360.         /*  Combine the DRIVE and FILE NAME
  361.             into one fully qualified file name. */
  362.         sprintf( file_name, "%s:\\%s\0",
  363.                         drive_letter,
  364.                         file        );
  365.  
  366.     }
  367.  
  368.  
  369.     error = KbdFreeFocus( keyboard );
  370.     error = KbdClose( keyboard );
  371.  
  372.  
  373.     return;
  374.  
  375. }
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382. /*  RESULTS() tells the user:
  383.         1.  that the screen capture is complete,
  384.         2.  that it was a success or a failure.
  385.  
  386.     It requires the following parameters:
  387.         LEFT        the column number of the first column
  388.                     of text in the pop up
  389.         RIGHT       the column number of the last column
  390.                     of text in the pop up
  391.         TOP         the row number of the first line of text in the pop up
  392.         FAILURE     a Boolean flag that tells this function:
  393.                         1.  if the screen was successfully
  394.                             copied.
  395.                         2.  if the data was successfully written
  396.                             to the user specified file.
  397.  
  398.     It returns the following error codes:
  399.         NOTHING     ( VOID )                    */
  400. void    results(    USHORT   left,
  401.                     USHORT   right,
  402.                     USHORT   top,
  403.                     unsigned failure )
  404. {
  405.     USHORT  error;
  406.     BYTE    attribute;
  407.     USHORT  next_column, next_row;
  408.     USHORT  columns_remaining;
  409.     USHORT  length;
  410.     KBDKEYINFO          character;
  411.     HKBD                keyboard;
  412.     char    *error_msg;
  413.  
  414.  
  415.     next_column = left;
  416.  
  417.     /*  Center the line on the pop up.  */
  418.     next_column += center_the_line( left,
  419.                                     right,
  420.                                     ( sizeof( RESULTS_1 ) + sizeof( RESULTS_FAILURE ) )       );
  421.  
  422.     columns_remaining = right - next_column;
  423.     next_row = top;
  424.     attribute = NORMAL_TEXT_COLOR;
  425.  
  426.     /*  Truncate the text, if necessary, to the size of the pop up. */
  427.     length = MIN( sizeof( RESULTS_1 ), columns_remaining );
  428.  
  429.  
  430.     /*  Write the first line of text.   */
  431.     error = VioWrtCharStrAtt(
  432.                     RESULTS_1,
  433.                     length,
  434.                     next_row,
  435.                     next_column,
  436.                     &attribute,
  437.                     DEFAULT_SCREEN_HANDLE   );
  438.  
  439.     next_column += sizeof( RESULTS_1 );
  440.     columns_remaining -= sizeof( RESULTS_1 );
  441.  
  442.     if ( failure )
  443.     {
  444.         attribute = ERROR_TEXT_COLOR;
  445.         length = MIN( sizeof( RESULTS_FAILURE ), columns_remaining );
  446.  
  447.  
  448.  
  449.         error = VioWrtCharStrAtt(
  450.                     RESULTS_FAILURE,
  451.                     sizeof( RESULTS_FAILURE ),
  452.                     next_row,
  453.                     next_column,
  454.                     &attribute,
  455.                     DEFAULT_SCREEN_HANDLE   );
  456.  
  457.         /*  Write the next line.  Describe the error. */
  458.         next_row +=2;
  459.         next_column = left;
  460.         columns_remaining = right - left;
  461.         attribute = NORMAL_TEXT_COLOR;
  462.         next_column += center_the_line( left,
  463.                                         right,
  464.                                         sizeof( ERROR_INTRO )   );
  465.  
  466.         error = VioWrtCharStrAtt(
  467.                     ERROR_INTRO,
  468.                     sizeof( ERROR_INTRO ),
  469.                     next_row,
  470.                     next_column,
  471.                     &attribute,
  472.                     DEFAULT_SCREEN_HANDLE   );
  473.  
  474.         /*  Describe the error on the final line.   */
  475.         next_row ++;
  476.         next_column = left;
  477.         columns_remaining = right - left;
  478.         attribute = ERROR_TEXT_COLOR;
  479.  
  480.         switch( failure )
  481.         {
  482.             case ERROR_FILE_NOT_FOUND :
  483.                 error_msg = "Cannot find the file you entered." ;
  484.                 break;
  485.  
  486.             case ERROR_PATH_NOT_FOUND :
  487.                 error_msg = "Drive or directory does not exist.";
  488.                 break;
  489.  
  490.             case ERROR_TOO_MANY_OPEN_FILES :
  491.                 error_msg = "The system cannot open any more files.";
  492.                 break;
  493.  
  494.             case ERROR_ACCESS_DENIED  :
  495.                 error_msg = "Access to this file is DENIED by OS/2.";
  496.                 break;
  497.  
  498.             case ERROR_INVALID_ACCESS :
  499.                 error_msg = "This file cannot be opened for WRITTING at this time.";
  500.                 break;
  501.  
  502.             case ERROR_NOT_DOS_DISK :
  503.                 error_msg = "OS/2 does not recognize the format of this disk.";
  504.                 break;
  505.  
  506.             case ERROR_SHARING_VIOLATION :
  507.                 error_msg = "Sharing violation.";
  508.                 break;
  509.  
  510.             case ERROR_SHARING_BUFFER_EXCEEDED :
  511.                 error_msg = "OS/2 sharing buffer has no more space.";
  512.                 break;
  513.  
  514.             case ERROR_CANNOT_MAKE :
  515.                 error_msg = "OS/2 cannot make this file.";
  516.                 break;
  517.  
  518.             case ERROR_INVALID_PARAMETER :
  519.                 error_msg = "Invalid parameter.";
  520.                 break;
  521.  
  522.             case ERROR_DRIVE_LOCKED :
  523.                 error_msg = "The entire drive is locked.";
  524.                 break;
  525.  
  526.             case ERROR_OPEN_FAILED :
  527.                 error_msg = "DosOpen failed.";
  528.                 break;
  529.  
  530.             case ERROR_DISK_FULL :
  531.                 error_msg = "This disk is full.";
  532.                 break;
  533.  
  534.             case ERROR_FILENAME_EXCED_RANGE :
  535.                 error_msg = "The file name you entered is too big.";
  536.                 break;
  537.  
  538.             case ERROR_PIPE_BUSY :
  539.                 error_msg = "The pipe you named is busy.";
  540.                 break;
  541.  
  542. /*          case ERROR_DEVICE_IN_USE :
  543.                 error_msg = "The device you named is in use.";
  544.                 break;      */
  545.  
  546.             case ERROR_INVALID_HANDLE :
  547.                 error_msg = "Invalid handle.  Call the programmer.";
  548.                 break;
  549.  
  550.             case ERROR_LOCK_VIOLATION :
  551.                 error_msg = "This file is locked at the moment.";
  552.                 break;
  553.  
  554.             case ERROR_BROKEN_PIPE :
  555.                 error_msg = "Your pipe is broken.";
  556.                 break;
  557.  
  558.             case MALLOC_ERROR :
  559.                 error_msg = "MALLOC() failed.  Call the programmer.";
  560.                 break;
  561.  
  562.             default:
  563.                 error_msg = "An unknown error occurred.";
  564.                 break;
  565.  
  566.         }
  567.  
  568.         /*  Truncate the message, if necessary, to the length
  569.             of one line of our pop up window.   */
  570.         length = MIN( ( unsigned )thread_strlen( error_msg ), columns_remaining );
  571.  
  572.         /*      Center the line on the pop up.  */
  573.         next_column += center_the_line( left,
  574.                                     right,
  575.                                     length      );
  576.  
  577.         error = VioWrtCharStrAtt(
  578.                     error_msg,
  579.                     length,
  580.                     next_row,
  581.                     next_column,
  582.                     &attribute,
  583.                     DEFAULT_SCREEN_HANDLE   );
  584.  
  585.     }
  586.     else
  587.     {
  588.         attribute = HILITE_TEXT_COLOR;
  589.         length = MIN( sizeof( RESULTS_SUCCESS ), columns_remaining );
  590.  
  591.         error = VioWrtCharStrAtt(
  592.                     RESULTS_SUCCESS,
  593.                     length,
  594.                     next_row,
  595.                     next_column,
  596.                     &attribute,
  597.                     DEFAULT_SCREEN_HANDLE   );
  598.  
  599.     }
  600.  
  601.  
  602.  
  603.     next_row += 2;
  604.     attribute = NORMAL_TEXT_COLOR;
  605.     next_column = left + 3;
  606.     length = thread_strlen( pause_prompt );
  607.  
  608.     /*  Center the line on the pop up.  */
  609.     next_column += center_the_line( left,
  610.                                     right,
  611.                                     length      );
  612.  
  613.     error = VioWrtCharStrAtt(
  614.                     pause_prompt,
  615.                     length,
  616.                     next_row,
  617.                     next_column,
  618.                     &attribute,
  619.                     DEFAULT_SCREEN_HANDLE   );
  620.  
  621.     /*  Get the responses to the above prompts. */
  622.     error = KbdOpen( &keyboard );
  623.  
  624.     error = KbdGetFocus( IO_WAIT, keyboard );
  625.  
  626.  
  627.     /*  Get a keystroke from the keyboard just to force the operator to respond.        */
  628.     error = KbdCharIn( &character, IO_WAIT, keyboard );
  629.  
  630.     error = KbdFreeFocus( keyboard );
  631.     error = KbdClose( keyboard );
  632.  
  633.  
  634.  
  635.  
  636.     return;
  637.  
  638. }
  639.  
  640.  
  641.  
  642.  
  643.  
  644. /*  FAREWELL() tells the user:
  645.         1.  that the screen capture is complete,
  646.         2.  that it was a success or a failure.
  647.  
  648.     It requires the following parameters:
  649.         LEFT        the column number of the first column
  650.                     of text in the pop up
  651.         RIGHT       the column number of the last column
  652.                     of text in the pop up
  653.         TOP         the row number of the first line of text in the pop up
  654.  
  655.     It returns the following error codes:
  656.         NOTHING     ( VOID )                    */
  657. void    farewell(   USHORT   left,
  658.                     USHORT   right,
  659.                     USHORT   top   )
  660. {
  661.     USHORT  error;
  662.     BYTE    attribute;
  663.     USHORT  next_column, next_row;
  664.     USHORT  columns_remaining;
  665.     USHORT  length;
  666.     KBDKEYINFO          character;
  667.     HKBD                keyboard;
  668.  
  669.  
  670.     next_column = left;
  671.     length = thread_strlen( program_name );
  672.  
  673.     /*  Center the line on the pop up.  */
  674.     next_column += center_the_line( left,
  675.                                     right,
  676.                                     ( length + sizeof( FAREWELL_STRING ) )           );
  677.  
  678.     columns_remaining = right - next_column;
  679.     next_row = top;
  680.     attribute = NORMAL_TEXT_COLOR;
  681.  
  682.     /*  Truncate the displayed text, if necessary, to the size of the pop up. */
  683.     length = MIN( length, columns_remaining );
  684.  
  685.  
  686.     /*  Write the program name.  */
  687.     error = VioWrtCharStrAtt(
  688.                     program_name,
  689.                     length,
  690.                     next_row,
  691.                     next_column,
  692.                     &attribute,
  693.                     DEFAULT_SCREEN_HANDLE   );
  694.  
  695.     next_column += length;
  696.     columns_remaining -= length;
  697.     length = MIN( sizeof( FAREWELL_STRING ), columns_remaining );
  698.  
  699.     /*  Write the rest of the first line of text.       */
  700.     error = VioWrtCharStrAtt(
  701.                     FAREWELL_STRING,
  702.                     length,
  703.                     next_row,
  704.                     next_column,
  705.                     &attribute,
  706.                     DEFAULT_SCREEN_HANDLE   );
  707.  
  708.     next_row += 2;
  709.     attribute = NORMAL_TEXT_COLOR;
  710.     next_column = left + 3;
  711.     length = thread_strlen( pause_prompt );
  712.  
  713.     /*  Center the line on the pop up.  */
  714.     next_column += center_the_line( left,
  715.                                     right,
  716.                                     length      );
  717.  
  718.     error = VioWrtCharStrAtt(
  719.                     pause_prompt,
  720.                     length,
  721.                     next_row,
  722.                     next_column,
  723.                     &attribute,
  724.                     DEFAULT_SCREEN_HANDLE   );
  725.  
  726.     /*  Get the responses to the above prompts. */
  727.     error = KbdOpen( &keyboard );
  728.  
  729.     error = KbdGetFocus( IO_WAIT, keyboard );
  730.  
  731.  
  732.     /*  Get a keystroke from the keyboard just to force the operator to respond.        */
  733.     error = KbdCharIn( &character, IO_WAIT, keyboard );
  734.  
  735.     error = KbdFreeFocus( keyboard );
  736.     error = KbdClose( keyboard );
  737.  
  738.  
  739.  
  740. }
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749. /*  POP_UP() does the following things:
  750.         1.  issues the three calls ALL pop ups in this program must issue:
  751.                 VioPopUp
  752.                 VioGetConfig
  753.                 VioEndPopUp
  754.         2.  calls the correct pop up code
  755.  
  756.     It requires the following parameters:
  757.         TYPE        which pop up are we calling.
  758.         FILE_NAME   this is the name of the file that will hold the
  759.                     captured screen data.
  760.         SUCCESS     a Boolean flag that tells this function:
  761.                         1.  if the screen was successfully
  762.                             copied.
  763.                         2.  if the data was successfully written
  764.                             to the user specified file.
  765.  
  766.     It returns the following error codes:
  767.         NO_ERROR    everything went well
  768.         anything else (probably the return code from VioPopUp)  */
  769. int     pop_up( unsigned type, char *file_name, unsigned failure )
  770. {
  771.     USHORT      error, options, left, right, top, bottom;
  772.     VIOMODEINFO screen;
  773.     struct screen_text fill_character;
  774.  
  775.     /*  Initialize...   */
  776.     fill_character.letter = ' ';
  777.     fill_character.attribute = POPUP_BACKGROUND_COLOR;
  778.     screen.cb = sizeof( screen );
  779.  
  780.     /*  Begin the popup session.    */
  781.     options = VP_TRANSPARENT | VP_WAIT;
  782.     error = VioPopUp( &options, DEFAULT_SCREEN_HANDLE );
  783.  
  784.  
  785.     if( error == NO_ERROR )
  786.     {
  787.         /*      Find out what our screen dimensions are.    */
  788.         error = VioGetMode( &screen, DEFAULT_SCREEN_HANDLE );
  789.  
  790.         left = screen.col / 5;
  791.         right = (left << 2);
  792.         top = screen.row >> 2;
  793.  
  794.         switch( type )
  795.         {
  796.             case MALLOC_ERROR :
  797.             case GET_FILE_NAME :
  798.                 bottom = top * 3;
  799.                 break;
  800.  
  801.             case RESULTS :
  802.                 if( failure )
  803.                 {
  804.                     bottom = top + 7;
  805.  
  806.                 }
  807.                 else
  808.                 {
  809.                     bottom = top + 5;
  810.  
  811.                 }
  812.                 break;
  813.  
  814.             case FAREWELL :
  815.                 bottom = top + 5;
  816.                 break;
  817.  
  818.         }
  819.  
  820.  
  821.         /*  Scroll the pop up.  */
  822.         error = VioScrollUp( top, left, bottom, right, 0xFFFF, ( PBYTE )&fill_character, DEFAULT_SCREEN_HANDLE );
  823.         left += 2;
  824.         right -= 2;
  825.         top++;
  826.         bottom--;
  827.  
  828.  
  829.         if( type == GET_FILE_NAME )
  830.         {
  831.                 get_file_name( left, right, top, file_name );
  832.  
  833.         }
  834.  
  835.  
  836.         if( type == FAREWELL )
  837.         {
  838.                 farewell( left, right, top );
  839.  
  840.         }
  841.  
  842.         if( type == RESULTS )
  843.         {
  844.                 results( left, right, top, failure );
  845.  
  846.         }
  847.  
  848.  
  849.  
  850.         /*      End the popup session.  */
  851.         error = VioEndPopUp( DEFAULT_SCREEN_HANDLE );
  852.  
  853.     }
  854.  
  855.     return( error );
  856.  
  857. }
  858.