name22

Navigate ListView with GUI Buttons + Focus

Mar 4th, 2014
155
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <GUIConstants.au3>
  2. #include <SendMessage.au3>
  3.  
  4. $hWnd = GUICreate("LIstView Button Navigation", 300, 410)
  5. $cList = GUICtrlCreateListView("Test A|TestB", 5, 5, 290, 340)
  6. $cButton_Up = GUICtrlCreateButton("Up", 5, 350, 80, 25)
  7. $cButton_Down = GUICtrlCreateButton("Down", 5, 380, 80, 25)
  8. GUISetState()
  9.  
  10. $hWnd_ListView = GUICtrlGetHandle($cList)
  11.  
  12. For $i = 1 To 20
  13.     GUICtrlCreateListViewItem($i & "|" & Random(), $cList)
  14. Next
  15.  
  16. While True
  17.     Switch GUIGetMsg()
  18.         Case $GUI_EVENT_CLOSE
  19.             Exit
  20.         Case $cButton_Up
  21.             _SendMessage($hWnd_ListView, $WM_KEYDOWN, 0x26, 0)
  22.             Sleep(100)
  23.             _SendMessage($hWnd_ListView, $WM_KEYUP, 0x26, 0)
  24.             ControlFocus($hWnd, "", $cList)
  25.         Case $cButton_Down
  26.             _SendMessage($hWnd_ListView, $WM_KEYDOWN, 0x28, 0)
  27.             Sleep(100)
  28.             _SendMessage($hWnd_ListView, $WM_KEYUP, 0x28, 0)
  29.             ControlFocus($hWnd, "", $cList)
  30.     EndSwitch
  31. WEnd
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×