On 5/11/2010 11:01 AM, Jeff Weiss wrote:
I took this from the Simon Says script in the manual. I just thought
that since it was in there , it ought to be that way.
There are several sections that discuss the syntax of the function, so
it sounds like you copied twice. There's a final Simon Says example code
section that might help get all of that straight. I did, however, find
one error that I've since fixed. On line 7, you'd want to change Sub
LaunchDialog(vk, km) to just Sub LaunchDialog().
I know that I've got something wrong here, but I don't know what!
A few things.
1. You could replace:
Set myKey = Keyboard.Keys(vk_I)
myKey.RequireModifiers(kmControl + kmShift + kmAlt)
ConnectEvent myKey, "OnKeyProcessedUp", "LaunchDialog"
With one line:
Set myKey = Keyboard.RegisterHotkey("Control-Alt-Shift-I", "LaunchDialog")
2. You're doing the If Mark < 5 Then every single time a dialog event
happens. Remember, every time a control gets focused, or blurred, or
clicked, or changed in any way, the dialog proc will receive an event.
So what your routine is saying, in a nutshell, is, "Every time an event
happens in my dialog, check to see if Mark is less than 5. If it is, add
a new XYZ list item." You'll get a dialogCreated event as soon as the
dialog gets created, so that's list item number 1. You'll then most
likely get an event for the first control to get focus, which means Mark
will become 2, and another list item will be added. Since the add code
is identical, another list item with Aaron as the text will get added,
which means you now have two Aaron list items. This will continue until
you have five list items, all called Aaron. That's what you down arrow
five times, and hear Aaron each time. Not a bad thing in my opinion, but
I digress. The reason you only hear one item when you call the
SpeakResult function is because the default text for a list view items
is the first column, not the entire row. If you want the entire row
spoken, you'll have to retrieve the text from each of the columns.
3. SpeakResult takes four parameters, but three of them are never used.
Instead of passing the entire dialog through, I would just pass the
string that you want to speak:
Case "btn_ok"
If dEvent = buttonClicked Then
SpeakResult dObj.Control("listview1").Text
DialogEventHandler = True
Exit Function
End If
or if you want the whole row:
Case "btn_ok"
If dEvent = buttonClicked Then
SpeakResult dObj.Control("listview1").Text & " " &
dObj.Control("listview1").Text(1) & " " & dObj.Control("listview1").Text(2)
DialogEventHandler = True
Exit Function
End If
and then your SpeakResult routine (a sub in this case, because you're
not returning a value) would be:
Sub SpeakResult(str)
Speak "You have chosen " & str
End Sub
HTH
Aaron
--
Aaron Smith
Product Support Specialist * Web Development
GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825
260-489-3671 * gwmicro.com
To insure that you receive proper support, please include all past
correspondence (where applicable), and any relevant information
pertinent to your situation when submitting a problem report to the GW
Micro Technical Support Team.