How do I support multiple forms?

Last reviewed: 10/20/1998

HOW Article ID: H109804

The information in this article applies to:

  • SpeechKit 2.0 and SpeechKit 2.1

Summary

I now am ready to enabling speech recognition on more forms in my Delphi project. How do I do this?

I cannot seem to register another OnHasPhrase to be used with the second form.

You want to use the handle for each form to create a separate session. For each StartRecognition, you pass the handle of the form. You can use the same HasPhrase callback routine or you can associate different ones. If you use a static callback entry point, you can either specify the same or different entry points.

More Information

Start each session with the different owner handle (note method names and parameters may be slightly different in different programming languages):


    // Register for windows message based callback for the first session
    RegisterSRCallback(ChantHasPhrase, NULL, form1Handle);
    // Application initializes speech recognition for the first session
    StartRecognition("My Application", "", NullVocabulary, NullArray, 0, 
    TRUE, form1Handle);
    
    // Register for windows message based callback for the second session
    RegisterSRCallback(ChantHasPhrase, NULL, form2Handle);
    // Application initializes speech recognition for the second session
    StartRecognition("My Application", "", NullVocabulary, NullArray, 0, 
    TRUE, form2Handle);
    
    ...application processsing...
    
    // Application terminates speech recognition for the first session
    StopRecognition(form1Handle);
    // Application terminates speech recognition for the second session
    StopRecognition(form2Handle);