To declare the API put the following code at top of the form code.
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal _
lpOperation As String, ByVal lpFile As String, ByVal _
lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
The core of the sample is basically done, however, as you know, nothing is really done without some style with the GUI. Here is the plan, lets put a button on the form to stop the recognition engine and also to start the engine when its stopped. Also, lets put a label to show the status of the engine and the recognized word.
Place a label on the form. Next place a buttom on the form. Set it's caption property to Enable and then double click on the button to open the code. Place the following code inside:
Private Sub Command1_Click()
Select Case Command1.Caption
Case "Disable"
DirectSR1.Deactivate
Command1.Caption = "Enable"
Label1 = "Disabled"
Case "Enable"
DirectSR1.Activate
Command1.Caption = "Disable"
Label1 = "Ready"
End Select
End Sub
The code is straight forward. A select case to test the caption of the button.
If Disable, Deactivate engine, set button caption to "Enable" and
set the label caption to "Disabled". If Enable, Activate engine, set
button caption to "Disable" and set the label caption to "Ready".
Remember, its label caption and button caption, two different things.
Comments