home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ipdssdk.zip / SDK / SAMPLES / ELMOQ / ELMOQ_UI.C < prev    next >
Text File  |  1994-02-07  |  14KB  |  291 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_UI.C                                               */
  21. /*                                                                     */
  22. /* DESCRIPTIVE NAME: This procedure retrieves and displays any         */
  23. /*                   information or statistics that pertain to a       */
  24. /*                   user ID or an enrollment ID.                      */
  25. /*                                                                     */
  26. /*                                                                     */
  27. /* STATUS: REVISION 1                                                  */
  28. /*                                                                     */
  29. /*                                                                     */
  30. /* FUNCTION: Contains the dialog box procedure for query and           */
  31. /*           display of user information.                              */
  32. /*                                                                     */
  33. /* NOTES:                                                              */
  34. /*                                                                     */
  35. /*    MODULE STRUCTURE:                                                */
  36. /*                                                                     */
  37. /*     - do_query_users                                                */
  38. /*                                                                     */
  39. /*                                                                     */
  40. /*   DEPENDENCIES:                                                     */
  41. /*                                                                     */
  42. /*     - elmoq.h    Elmoq defines                                      */
  43. /*                                                                     */
  44. /*     - smapi.h    speech API defines                                 */
  45. /*                                                                     */
  46. /*                                                                     */
  47. /* MODULE TYPE: (C language)                                           */
  48. /*                                                                     */
  49. /*                                                                     */
  50. /* CHANGE ACTIVITY: AS FOLLOWS                                         */
  51. /*                                                                     */
  52. /* FLAG  REASON  RLSE  DATE  ORIGIN   DESCRIPTION                      */
  53. /* ---- -------- ---- ------ ------   -----------                      */
  54. /*               0001 931207 JAF      created                          */
  55. /*                                                                     */
  56. /***********************************************************************/
  57.  
  58. #define    INCL_WIN
  59. #define    INCL_DOS
  60. #define    INCL_DOSPROCESS
  61. #define    INCL_GPIBITMAPS
  62.  
  63. /*---------------------------------------------------------------------*/
  64. /* application system include files                                    */
  65. /*---------------------------------------------------------------------*/
  66. #include   <os2.h>
  67. #include   <stdio.h>
  68. #include   <stdlib.h>
  69. #include   <string.h>
  70.  
  71. /*---------------------------------------------------------------------*/
  72. /* IBM Personal Dictation System api include files                     */
  73. /*---------------------------------------------------------------------*/
  74. #include   <smapi.h>
  75.  
  76. /*---------------------------------------------------------------------*/
  77. /* application private include files                                   */
  78. /*---------------------------------------------------------------------*/
  79. #include   "elmoq.h"
  80.  
  81. /*---------------------------------------------------------------------*/
  82. /* static variable declarations                                        */
  83. /*---------------------------------------------------------------------*/
  84. static  char            language  [ 256 ];
  85. static  char            user_id   [ 256 ];
  86. static  char            enroll_id [ 256 ];
  87. static  char            itemname  [ 256 ];
  88.  
  89. /***********************************************************************/
  90. /* FUNCTION: DlgProcQueryUserInfoP                                     */
  91. /*                                                                     */
  92. /* PURPOSE : Elmo's Magic Question Machine Query User Information      */
  93. /*           dialog procedure                                          */
  94. /*                                                                     */
  95. /* INPUTS  : hwnd       - window handle                                */
  96. /*           msg        - message                                      */
  97. /*           mp1        - first message parameter                      */
  98. /*           mp2        - second message parameter                     */
  99. /*                                                                     */
  100. /* OUTPUTS : On Success - displays the user information                */
  101. /*           On Failure - displays an error message                    */
  102. /*           On Return  - returns FALSE                                */
  103. /*                                                                     */
  104. /* GLOBALS : NONE                                                      */
  105. /*                                                                     */
  106. /***********************************************************************/
  107. MRESULT EXPENTRY DlgProcQueryUserInfoP ( HWND hwnd,
  108.                                          USHORT msg,
  109.                                          MPARAM mp1,
  110.                                          MPARAM mp2  )
  111. {
  112.    int              rc;
  113.    SM_MSG           reply;
  114.    unsigned long    number_of_userids;
  115.    char             **userids;
  116.  
  117.   /*----------------------------*/
  118.   /* switch on the message type */
  119.   /*----------------------------*/
  120.    switch ( msg ) {
  121.  
  122.       /*------------------------------*/
  123.       /* process the command messages */
  124.       /*------------------------------*/
  125.       case WM_COMMAND:
  126.  
  127.          /*-----------------------------*/
  128.          /* switch on the command value */
  129.          /*-----------------------------*/
  130.          switch ( SHORT1FROMMP( mp1 ) ) {
  131.  
  132.             /*----------------------*/
  133.             /* handle the OK button */
  134.             /*----------------------*/
  135.             case DID_OK:
  136.  
  137.                /*---------------------------------*/
  138.                /* initialize the language to zero */
  139.                /*---------------------------------*/
  140.                language [ 0 ] = 0;
  141.  
  142.                /*-----------------*/
  143.                /* get the user ID */
  144.                /*-----------------*/
  145.                WinQueryDlgItemText ( hwnd,
  146.                                      USERID_EF,
  147.                                      sizeof ( user_id ),
  148.                                      user_id );
  149.  
  150.                /*-----------------------*/
  151.                /* get the enrollment ID */
  152.                /*-----------------------*/
  153.                WinQueryDlgItemText ( hwnd,
  154.                                      ENROLLID_EF,
  155.                                      sizeof ( enroll_id ),
  156.                                      enroll_id );
  157.  
  158.  
  159.                /*-------------------*/
  160.                /* get the item name */
  161.                /*-------------------*/
  162.                WinQueryDlgItemText ( hwnd,
  163.                                      ITEMNAME_EF,
  164.                                      sizeof ( itemname ),
  165.                                      itemname );
  166.  
  167.                /*----------------------------------------*/
  168.                /* dismiss the query user info dialog box */
  169.                /*----------------------------------------*/
  170.                WinDismissDlg ( hwnd, DID_OK );
  171.  
  172.                /*-----------------------------*/
  173.                /* query the speech recognizer */
  174.                /* for the list of user IDs,   */
  175.                /* enrollment IDs, and item    */
  176.                /* names                       */
  177.                /*-----------------------------*/
  178.                rc = SmQueryUserInfo ( user_id,
  179.                                       enroll_id,
  180.                                       itemname,
  181.                                       &reply );
  182.  
  183.                /*-------------------------------------*/
  184.                /* if the list does not exist then     */
  185.                /* display an error message and return */
  186.                /*-------------------------------------*/
  187.                if ( rc != SM_RC_OK ) {
  188.                  display_msg_on_desktop ( hwnd, "SmQueryUserInfo call failed" );
  189.                  break;
  190.                }
  191.  
  192.                /*--------------------------*/
  193.                /* get the list of user IDs */
  194.                /*--------------------------*/
  195.                SmGetUserIds ( reply, &number_of_userids, &userids );
  196.  
  197.                /*-------------------------------*/
  198.                /* if there are IDs in the list  */
  199.                /* dsiplay the user IDs title    */
  200.                /* otherwise display no user IDs */
  201.                /*-------------------------------*/
  202.                if ( number_of_userids )
  203.                  add_item_to_answer_box   ( "====  userids  ===="  );
  204.                else
  205.                  add_item_to_answer_box   ( "==== no userid ====" );
  206.  
  207.                /*-----------------------------------*/
  208.                /* display the full list of user IDs */
  209.                /*-----------------------------------*/
  210.                for ( ; number_of_userids-- > 0; userids++ ) {
  211.                  add_item_to_answer_box ( *userids );
  212.                }
  213.  
  214.                break;
  215.  
  216.             /*--------------------------*/
  217.             /* handle the Cancel button */
  218.             /*--------------------------*/
  219.             case DID_CANCEL:
  220.  
  221.                /*----------------------------------------*/
  222.                /* dismiss the query user info dialog box */
  223.                /*----------------------------------------*/
  224.                WinDismissDlg ( hwnd, DID_CANCEL );
  225.                break;
  226.          }
  227.          break;
  228.  
  229.       /*-----------------------------*/
  230.       /* control message, do nothing */
  231.       /*-----------------------------*/
  232.       case WM_CONTROL:
  233.          break;
  234.  
  235.       /*---------------------------------------*/
  236.       /* process the initialize dialog message */
  237.       /*---------------------------------------*/
  238.       case WM_INITDLG:
  239.  
  240.          /*---------------------------------------*/
  241.          /* set the maximum text limit of the     */
  242.          /* user ID entry field to 256 characters */
  243.          /*---------------------------------------*/
  244.          WinSendDlgItemMsg ( hwnd,
  245.                              USERID_EF,
  246.                              EM_SETTEXTLIMIT,
  247.                              MPFROM2SHORT( 256, 0 ),
  248.                              0L );
  249.  
  250.          /*---------------------------------------------*/
  251.          /* set the maximum text limit of the           */
  252.          /* enrollment ID entry field to 256 characters */
  253.          /*---------------------------------------------*/
  254.          WinSendDlgItemMsg ( hwnd,
  255.                              ENROLLID_EF,
  256.                              EM_SETTEXTLIMIT,
  257.                              MPFROM2SHORT( 256, 0 ),
  258.                              0L );
  259.  
  260.          /*-----------------------------------------*/
  261.          /* set the maximum text limit of the       */
  262.          /* item name entry field to 256 characters */
  263.          /*-----------------------------------------*/
  264.          WinSendDlgItemMsg ( hwnd,
  265.                              ITEMNAME_EF,
  266.                              EM_SETTEXTLIMIT,
  267.                              MPFROM2SHORT( 256, 0 ),
  268.                              0L );
  269.          break;
  270.  
  271.       /*---------------------------*/
  272.       /* process the paint message */
  273.       /*---------------------------*/
  274.       case WM_PAINT:
  275.  
  276.          /*--------------------------------------*/
  277.          /* involke the default dialog procedure */
  278.          /*--------------------------------------*/
  279.          return ( WinDefDlgProc ( hwnd, msg, mp1, mp2 ) );
  280.  
  281.      default:
  282.  
  283.          /*--------------------------------------*/
  284.          /* involke the default dialog procedure */
  285.          /*--------------------------------------*/
  286.          return ( WinDefDlgProc ( hwnd, msg, mp1, mp2 ) );
  287.    }
  288.    return ( FALSE );
  289. }
  290.  
  291.