home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ipdssdk.zip / SDK / SAMPLES / ELMOQ / ELMOQ_QS.C < prev    next >
Text File  |  1994-02-07  |  12KB  |  247 lines

  1. /***********************************************************************/
  2. /*                                                                     */
  3. /* COPYRIGHT:                                                          */
  4. /*                                                                     */
  5. /* Copyright (C) International Business Machine Corp, 1991,1994.       */
  6. /*                                                                     */
  7. /* DISCLAIMER OF WARRANTIES:                                           */
  8. /*                                                                     */
  9. /* The following enclosed code is sample code created by IBM           */
  10. /* Corporation.  This code is not part of any standard IBM product     */
  11. /* and is provided to you solely for the purpose of assisting you in   */
  12. /* the development of your applications.  The code is provided         */
  13. /* "AS IS", without warranty of any kind.  IBM shall not be liable for */
  14. /* any damages arising out of your use of the sample code, even if     */
  15. /* they have been advised of the possibility of such damages.          */
  16. /*                                                                     */
  17. /*                                                                     */
  18. /* PROGRAM NAME: <ELMOQ.EXE>                                           */
  19. /*                                                                     */
  20. /* FILE NAME: ELMOQ_QS.C                                               */
  21. /*                                                                     */
  22. /* DESCRIPTIVE NAME: This procedure obtains a list of the available    */
  23. /*                   Enrollment Scripts used for training the          */
  24. /*                   recognizer for a user and displays the list.      */
  25. /*                                                                     */
  26. /* STATUS: REVISION 1                                                  */
  27. /*                                                                     */
  28. /*                                                                     */
  29. /* FUNCTION: Contains the dialog box procedure for Query of Enrollment */
  30. /*           Scripts                                                   */
  31. /*                                                                     */
  32. /* NOTES:                                                              */
  33. /*                                                                     */
  34. /*    MODULE STRUCTURE:                                                */
  35. /*                                                                     */
  36. /*     - DlgProcQueryScriptsP                                          */
  37. /*                                                                     */
  38. /*                                                                     */
  39. /*   DEPENDENCIES:                                                     */
  40. /*                                                                     */
  41. /*     - elmoq.h    Elmoq defines                                      */
  42. /*                                                                     */
  43. /*     - smapi.h    speech API defines                                 */
  44. /*                                                                     */
  45. /*                                                                     */
  46. /* MODULE TYPE: (C language)                                           */
  47. /*                                                                     */
  48. /*                                                                     */
  49. /* CHANGE ACTIVITY: AS FOLLOWS                                         */
  50. /*                                                                     */
  51. /* FLAG  REASON  RLSE  DATE  ORIGIN   DESCRIPTION                      */
  52. /* ---- -------- ---- ------ ------   -----------                      */
  53. /*               0001 931207 JAF      created                          */
  54. /*                                                                     */
  55. /***********************************************************************/
  56.  
  57. #define    INCL_WIN
  58. #define    INCL_DOS
  59. #define    INCL_DOSPROCESS
  60. #define    INCL_GPIBITMAPS
  61.  
  62. /*---------------------------------------------------------------------*/
  63. /* application system include files                                    */
  64. /*---------------------------------------------------------------------*/
  65. #include   <os2.h>
  66. #include   <stdio.h>
  67. #include   <stdlib.h>
  68. #include   <string.h>
  69.  
  70. /*---------------------------------------------------------------------*/
  71. /* IBM Personal Dictation System api include files                     */
  72. /*---------------------------------------------------------------------*/
  73. #include   <smapi.h>
  74.  
  75. /*---------------------------------------------------------------------*/
  76. /* application private include files                                   */
  77. /*---------------------------------------------------------------------*/
  78. #include   "elmoq.h"
  79.  
  80. /*---------------------------------------------------------------------*/
  81. /* static variable declarations                                        */
  82. /*---------------------------------------------------------------------*/
  83. static  char            language  [ 256 ];
  84.  
  85. /***********************************************************************/
  86. /* FUNCTION: DlgProcQueryScriptsP                                      */
  87. /*                                                                     */
  88. /* PURPOSE : Elmo's Magic Question Machine Query Scripts dialog        */
  89. /*           procedure                                                 */
  90. /*                                                                     */
  91. /* INPUTS  : hwnd       - window handle                                */
  92. /*           msg        - message                                      */
  93. /*           mp1        - first message parameter                      */
  94. /*           mp2        - second message parameter                     */
  95. /*                                                                     */
  96. /* OUTPUTS : On Success - displays a list of available enrollment      */
  97. /*                        scripts                                      */
  98. /*           On Failure - displays an error message                    */
  99. /*           On Return  - returns FALSE                                */
  100. /*                                                                     */
  101. /* GLOBALS : NONE                                                      */
  102. /*                                                                     */
  103. /***********************************************************************/
  104. MRESULT EXPENTRY DlgProcQueryScriptsP ( HWND hwnd,
  105.                                         USHORT msg,
  106.                                         MPARAM mp1,
  107.                                         MPARAM mp2  )
  108. {
  109.    int              rc;
  110.    SM_MSG           reply;
  111.    unsigned long    number_of_scripts;
  112.    char             **scripts;
  113.                                                                                                                /*----------------------------*/
  114.   /*----------------------------*/
  115.   /* switch on the message type */
  116.   /*----------------------------*/
  117.    switch ( msg ) {
  118.  
  119.       /*------------------------------*/
  120.       /* process the command messages */
  121.       /*------------------------------*/
  122.       case WM_COMMAND:
  123.  
  124.          /*-----------------------------*/
  125.          /* switch on the command value */
  126.          /*-----------------------------*/
  127.          switch ( SHORT1FROMMP( mp1 ) ) {
  128.  
  129.             /*----------------------*/
  130.             /* handle the OK button */
  131.             /*----------------------*/
  132.             case DID_OK:
  133.  
  134.                /*---------------------------------*/
  135.                /* initialize the language to zero */
  136.                /*---------------------------------*/
  137.                language [ 0 ] = 0;
  138.  
  139.                /*----------------------------------*/
  140.                /* prompt the user for the language */
  141.                /*----------------------------------*/
  142.                WinQueryDlgItemText ( hwnd,
  143.                                      LANGUAGE_EF,
  144.                                      sizeof ( language ),
  145.                                      language );
  146.  
  147.                /*--------------------------------------*/
  148.                /* dismiss the query scripts dialog box */
  149.                /*--------------------------------------*/
  150.                WinDismissDlg ( hwnd, DID_OK );
  151.  
  152.                /*------------------------------*/
  153.                /* query for a list of the      */
  154.                /* available enrollment scripts */
  155.                /*------------------------------*/
  156.                rc = SmQueryScripts ( language, &reply );
  157.  
  158.                /*-------------------------------------*/
  159.                /* if the list does not exist then     */
  160.                /* display an error message and return */
  161.                /*-------------------------------------*/
  162.                if ( rc != SM_RC_OK ) {
  163.                  display_msg_on_desktop ( hwnd, "SmQueryScripts call failed" );
  164.                  break;
  165.                }
  166.  
  167.                /*------------------------------------*/
  168.                /* get the list of enrollment scripts */
  169.                /*------------------------------------*/
  170.                SmGetScripts      ( reply, &number_of_scripts, &scripts );
  171.  
  172.                /*--------------------------------*/
  173.                /* if the list exists display the */
  174.                /* scripts title otherwise write  */
  175.                /* no scripts                     */
  176.                /*--------------------------------*/
  177.                if ( number_of_scripts )
  178.                  add_item_to_answer_box   ( "====  scripts  ===="  );
  179.                else
  180.                  add_item_to_answer_box   ( "==== no scripts ====" );
  181.  
  182.                /*--------------------------*/
  183.                /* display the full list of */
  184.                /* enrollment scripts       */
  185.                /*--------------------------*/
  186.                for ( ; number_of_scripts-- > 0; scripts++ ) {
  187.                  add_item_to_answer_box ( *scripts );
  188.                }
  189.                break;
  190.  
  191.             /*--------------------------*/
  192.             /* handle the Cancel button */
  193.             /*--------------------------*/
  194.             case DID_CANCEL:
  195.  
  196.                /*--------------------------------------*/
  197.                /* dismiss the query scripts dialog box */
  198.                /*--------------------------------------*/
  199.                WinDismissDlg ( hwnd, DID_CANCEL );
  200.                break;
  201.          }
  202.          break;
  203.  
  204.       /*-----------------------------*/
  205.       /* control message, do nothing */
  206.       /*-----------------------------*/
  207.       case WM_CONTROL:
  208.          break;
  209.  
  210.       /*---------------------------------------*/
  211.       /* process the initialize dialog message */
  212.       /*---------------------------------------*/
  213.       case WM_INITDLG:
  214.  
  215.          /*----------------------------------------*/
  216.          /* set the maximum text limit of the      */
  217.          /* language entry field to 256 characters */
  218.          /*----------------------------------------*/
  219.          WinSendDlgItemMsg ( hwnd,
  220.                              LANGUAGE_EF,
  221.                              EM_SETTEXTLIMIT,
  222.                              MPFROM2SHORT( 256, 0 ),
  223.                              0L );
  224.  
  225.          break;
  226.  
  227.       /*---------------------------*/
  228.       /* process the paint message */
  229.       /*---------------------------*/
  230.       case WM_PAINT:
  231.  
  232.          /*--------------------------------------*/
  233.          /* involke the default dialog procedure */
  234.          /*--------------------------------------*/
  235.          return ( WinDefDlgProc ( hwnd, msg, mp1, mp2 ) );
  236.  
  237.       default:
  238.  
  239.          /*--------------------------------------*/
  240.          /* involke the default dialog procedure */
  241.          /*--------------------------------------*/
  242.          return ( WinDefDlgProc ( hwnd, msg, mp1, mp2 ) );
  243.    }
  244.    return ( FALSE );
  245. }
  246.  
  247.