Hi Jeff,

    Just in case you want to use the ListView and watch the event then you will 
have to monitor the keyboard, or another, or set a timer when the event happens 
for as I had said, there is no object while the event is happening, at least 
for a ListView individual item.

    I decided to finally fix my issue and give you an example. I did not post 
the entire program but mention the important ones for the events in question.

    You can look at this and try it if you want to. Inside a ListBox at least 
you have indexing and such.

    Now I wonder if your change is posted immediately or when the key is up or 
processed? For you may not have any change until then, so check even your 
program out to make sure when the event fires you have the correct change.

        Bruce

' ClipFiles 1.0 Generated by WEScript Framework
Option Explicit
Dim LV_Obj: Set LV_Obj = Nothing
Dim LV_Control: Set LV_Control = Nothing
Dim LV_Changed: LV_Changed = False
Dim LV_Focused: LV_Focused = False
Dim LV_KeyDown: LV_KeyDown = False
Dim myLV_KeyConnection: myLV_KeyConnection = 0
Dim LV_MouseDown: LV_MouseDown = False
Dim myLV_MouseConnection: myLV_MouseConnection = 0
Dim myMainDialog: Set myMainDialog = Nothing
Dim FileListNumber: FileListNumber = -1
Function MainDialogProc(dObj, dEvent, dId, dControl)
 ' The main menu for the Clipboard Clip Files Program.
 MainDialogProc = False
If dEvent = ListViewKeyDown Then
  Set LV_Obj = myMainDialog
  Set LV_Control = dControl
  LV_KeyDown = True
  myLV_KeyConnection = ConnectEvent( Keyboard, "OnKeyProcessedUp", 
"OnKeyProcessedUp")
    MainDialogProc = True
    Exit Function
 End If
 Select Case dId
  Case FileListName
   If dEvent = listviewItemChanged Then
    LV_Changed = True
    MainDialogProc = True
    Exit Function
   ElseIf dEvent = listviewFocus Then
    LV_Focused = True
    Queue "SelectionChanged", FileListName
    MainDialogProc = True
    Exit Function
   End If
  Case Else
   If dEvent = dialogCreated Then
    ' This routine is to init all main buttons and fields.
    ' Since the dialog event for creation, no menu exists, so initialize it now.
    Set myDialogMenu = dObj.Menu
    Set myMainEscape = Keyboard.RegisterHotkey("Escape", "ExitMenu", 
dObj.Window,
dObj)
    Set myMainAltF4 = Keyboard.RegisterHotkey("Alt-F4", "ExitMenu", dObj.Window,
dObj)
    Set myMainF5 = Keyboard.RegisterHotkey("F5", "RefreshDialog", dObj.Window, 
dObj)
    dObj.Window.Activate
    Queue "SetMenuItems", myDialogMenu
    Queue "MakeFileList", dObj
    Queue "SetMenu_Ini"
    MainDialogProc = True
    Exit Function
   ElseIf dEvent = dialogClosing Then
    Set myMainEscape = Nothing
    Set myMainAltF4 = Nothing
    Set myMainDialog = Nothing
    CompactMenuItem = False
    ' The dialog may have closed before creation so make sure.
    If Not myDialogMenu Is Nothing Then
     Set myDialogMenu = Nothing
    End If
    MainDialogProc = True
    Exit Function
   End If
 End Select
End Function
Sub SelectionChanged( id)
 If LV_Changed Or LV_Focused Then
  LV_Changed = False
  If LV_Focused Then
   FileListNumber = myMainDialog.Control( id).Items.Focused.Index
   LV_Focused = false
   Speak " List Has Focus "
  End If
  Speak "Selection Has Changed to: " & myMainDialog.Control( id).Text
  Speak " Index Number Is: " & myMainDialog.Control( id).Items.Focused.Index
  Sleep 2000
 End If
End Sub
Sub OnKeyProcessedUp( ky, md)
 Disconnect myLV_KeyConnection
 myLV_KeyConnection = 0
 If LV_Changed Then
  Queue "SelectionChanged", FileListName
  Exit Sub
 End If
 'Move up or down!
 If LV_KeyDown and ky = vk_Space Then
  If SpacebarURL Then
   Queue "LaunchFavorite"
  Else
   If md = 0 Then Queue "MoveUpList"
   If md = 1 Then Queue "MoveDownList"
  End If
 End If
 LV_KeyDown = False
End Sub
Sub LaunchFavorite()
 'Go To Favorite Web Site.
 Dim text, text1
 On Error Resume Next
 text = LV_Control.Items.focused.text
 text1 = LV_Control.Items.focused.text(1)
 Sleep 1000
 Silence
' msgBox (" Launching URL: " & text1&text)
 If Not SO_LaunchUrl Is Nothing Then
  SO_LaunchUrl GetLinkURL( text1&text)
 End If
End Sub

Sent: Wednesday, January 15, 2014 9:43 AM
Subject: RE: listbox change


Thanks Chip and Bruce.
Chip, Your example does work just the way I wanted it to.
After case ListboxSelectionChange, I was missing:

DialogEventHandler = True
queue "SaySelectedItem",  dObj.control("lst").text

I guess that I am a person who learns by concrete examples, and this is a good 
one.
Thanks
Jeff Weiss


---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com

Reply via email to