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 >
Wrap
Text File
|
1994-02-07
|
14KB
|
291 lines
/***********************************************************************/
/* */
/* COPYRIGHT: */
/* */
/* Copyright (C) International Business Machine Corp, 1991,1994. */
/* */
/* DISCLAIMER OF WARRANTIES: */
/* */
/* The following enclosed code is sample code created by IBM */
/* Corporation. This code is not part of any standard IBM product */
/* and is provided to you solely for the purpose of assisting you in */
/* the development of your applications. The code is provided */
/* "AS IS", without warranty of any kind. IBM shall not be liable for */
/* any damages arising out of your use of the sample code, even if */
/* they have been advised of the possibility of such damages. */
/* */
/* */
/* PROGRAM NAME: <ELMOQ.EXE> */
/* */
/* FILE NAME: ELMOQ_UI.C */
/* */
/* DESCRIPTIVE NAME: This procedure retrieves and displays any */
/* information or statistics that pertain to a */
/* user ID or an enrollment ID. */
/* */
/* */
/* STATUS: REVISION 1 */
/* */
/* */
/* FUNCTION: Contains the dialog box procedure for query and */
/* display of user information. */
/* */
/* NOTES: */
/* */
/* MODULE STRUCTURE: */
/* */
/* - do_query_users */
/* */
/* */
/* DEPENDENCIES: */
/* */
/* - elmoq.h Elmoq defines */
/* */
/* - smapi.h speech API defines */
/* */
/* */
/* MODULE TYPE: (C language) */
/* */
/* */
/* CHANGE ACTIVITY: AS FOLLOWS */
/* */
/* FLAG REASON RLSE DATE ORIGIN DESCRIPTION */
/* ---- -------- ---- ------ ------ ----------- */
/* 0001 931207 JAF created */
/* */
/***********************************************************************/
#define INCL_WIN
#define INCL_DOS
#define INCL_DOSPROCESS
#define INCL_GPIBITMAPS
/*---------------------------------------------------------------------*/
/* application system include files */
/*---------------------------------------------------------------------*/
#include <os2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*---------------------------------------------------------------------*/
/* IBM Personal Dictation System api include files */
/*---------------------------------------------------------------------*/
#include <smapi.h>
/*---------------------------------------------------------------------*/
/* application private include files */
/*---------------------------------------------------------------------*/
#include "elmoq.h"
/*---------------------------------------------------------------------*/
/* static variable declarations */
/*---------------------------------------------------------------------*/
static char language [ 256 ];
static char user_id [ 256 ];
static char enroll_id [ 256 ];
static char itemname [ 256 ];
/***********************************************************************/
/* FUNCTION: DlgProcQueryUserInfoP */
/* */
/* PURPOSE : Elmo's Magic Question Machine Query User Information */
/* dialog procedure */
/* */
/* INPUTS : hwnd - window handle */
/* msg - message */
/* mp1 - first message parameter */
/* mp2 - second message parameter */
/* */
/* OUTPUTS : On Success - displays the user information */
/* On Failure - displays an error message */
/* On Return - returns FALSE */
/* */
/* GLOBALS : NONE */
/* */
/***********************************************************************/
MRESULT EXPENTRY DlgProcQueryUserInfoP ( HWND hwnd,
USHORT msg,
MPARAM mp1,
MPARAM mp2 )
{
int rc;
SM_MSG reply;
unsigned long number_of_userids;
char **userids;
/*----------------------------*/
/* switch on the message type */
/*----------------------------*/
switch ( msg ) {
/*------------------------------*/
/* process the command messages */
/*------------------------------*/
case WM_COMMAND:
/*-----------------------------*/
/* switch on the command value */
/*-----------------------------*/
switch ( SHORT1FROMMP( mp1 ) ) {
/*----------------------*/
/* handle the OK button */
/*----------------------*/
case DID_OK:
/*---------------------------------*/
/* initialize the language to zero */
/*---------------------------------*/
language [ 0 ] = 0;
/*-----------------*/
/* get the user ID */
/*-----------------*/
WinQueryDlgItemText ( hwnd,
USERID_EF,
sizeof ( user_id ),
user_id );
/*-----------------------*/
/* get the enrollment ID */
/*-----------------------*/
WinQueryDlgItemText ( hwnd,
ENROLLID_EF,
sizeof ( enroll_id ),
enroll_id );
/*-------------------*/
/* get the item name */
/*-------------------*/
WinQueryDlgItemText ( hwnd,
ITEMNAME_EF,
sizeof ( itemname ),
itemname );
/*----------------------------------------*/
/* dismiss the query user info dialog box */
/*----------------------------------------*/
WinDismissDlg ( hwnd, DID_OK );
/*-----------------------------*/
/* query the speech recognizer */
/* for the list of user IDs, */
/* enrollment IDs, and item */
/* names */
/*-----------------------------*/
rc = SmQueryUserInfo ( user_id,
enroll_id,
itemname,
&reply );
/*-------------------------------------*/
/* if the list does not exist then */
/* display an error message and return */
/*-------------------------------------*/
if ( rc != SM_RC_OK ) {
display_msg_on_desktop ( hwnd, "SmQueryUserInfo call failed" );
break;
}
/*--------------------------*/
/* get the list of user IDs */
/*--------------------------*/
SmGetUserIds ( reply, &number_of_userids, &userids );
/*-------------------------------*/
/* if there are IDs in the list */
/* dsiplay the user IDs title */
/* otherwise display no user IDs */
/*-------------------------------*/
if ( number_of_userids )
add_item_to_answer_box ( "==== userids ====" );
else
add_item_to_answer_box ( "==== no userid ====" );
/*-----------------------------------*/
/* display the full list of user IDs */
/*-----------------------------------*/
for ( ; number_of_userids-- > 0; userids++ ) {
add_item_to_answer_box ( *userids );
}
break;
/*--------------------------*/
/* handle the Cancel button */
/*--------------------------*/
case DID_CANCEL:
/*----------------------------------------*/
/* dismiss the query user info dialog box */
/*----------------------------------------*/
WinDismissDlg ( hwnd, DID_CANCEL );
break;
}
break;
/*-----------------------------*/
/* control message, do nothing */
/*-----------------------------*/
case WM_CONTROL:
break;
/*---------------------------------------*/
/* process the initialize dialog message */
/*---------------------------------------*/
case WM_INITDLG:
/*---------------------------------------*/
/* set the maximum text limit of the */
/* user ID entry field to 256 characters */
/*---------------------------------------*/
WinSendDlgItemMsg ( hwnd,
USERID_EF,
EM_SETTEXTLIMIT,
MPFROM2SHORT( 256, 0 ),
0L );
/*---------------------------------------------*/
/* set the maximum text limit of the */
/* enrollment ID entry field to 256 characters */
/*---------------------------------------------*/
WinSendDlgItemMsg ( hwnd,
ENROLLID_EF,
EM_SETTEXTLIMIT,
MPFROM2SHORT( 256, 0 ),
0L );
/*-----------------------------------------*/
/* set the maximum text limit of the */
/* item name entry field to 256 characters */
/*-----------------------------------------*/
WinSendDlgItemMsg ( hwnd,
ITEMNAME_EF,
EM_SETTEXTLIMIT,
MPFROM2SHORT( 256, 0 ),
0L );
break;
/*---------------------------*/
/* process the paint message */
/*---------------------------*/
case WM_PAINT:
/*--------------------------------------*/
/* involke the default dialog procedure */
/*--------------------------------------*/
return ( WinDefDlgProc ( hwnd, msg, mp1, mp2 ) );
default:
/*--------------------------------------*/
/* involke the default dialog procedure */
/*--------------------------------------*/
return ( WinDefDlgProc ( hwnd, msg, mp1, mp2 ) );
}
return ( FALSE );
}