Jump to content

Recommended Posts

Posted (edited)

This function no need to describe

but maybe be helpfull for somebody

Func _GUICtrlListView_ScrollToItem($hListView, $item) ; $item : zero based ListViewItem
$item_to_scroll = $item
If $item_to_scroll >= 0 Then $item_to_scroll -= 1
$aRect = _GUICtrlListView_GetItemRect($hListView, $item_to_scroll, 3)
$v_iDY = $aRect[1] - 1
If $item <= 0 Then $v_iDY -= 16
_GUICtrlListView_Scroll($hListView, 0, $v_iDY)
EndFunc ;==>_GUICtrlListView_ScrollToItem
Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Would you mind posting an example of its usage?

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

If you use this style ($LVS_SHOWSELALWAYS) setting when you create the listview, all you need to do is use_GUICtrlListView_SetItemSelected and it will automatically scroll to the selected item wherever it is in the LV.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

an example

#include 
#include 

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
Local $hListView

GUICreate("ListView Scroll", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
GUISetState()

; Add column
_GUICtrlListView_AddColumn($hListView, "Items", 100)

; Add items
_GUICtrlListView_BeginUpdate($hListView)
For $iI = 1 To 1000
_GUICtrlListView_AddItem($hListView, "Item " & $iI - 1)
Next
_GUICtrlListView_EndUpdate($hListView)

; Scroll control 500 pixels
Sleep(5000)
_GUICtrlListView_ScrollToItem($hListView, 0)
Sleep(2000)
_GUICtrlListView_ScrollToItem($hListView, 1)
Sleep(2000)
_GUICtrlListView_ScrollToItem($hListView, 2)
Sleep(2000)
_GUICtrlListView_ScrollToItem($hListView, 9)
Sleep(2000)
_GUICtrlListView_ScrollToItem($hListView, 99)
Sleep(2000)
_GUICtrlListView_ScrollToItem($hListView, 499)
Sleep(2000)
_GUICtrlListView_ScrollToItem($hListView, 99)
Sleep(2000)
_GUICtrlListView_ScrollToItem($hListView, 9)
Sleep(2000)
_GUICtrlListView_ScrollToItem($hListView, 5)
Sleep(2000)
_GUICtrlListView_ScrollToItem($hListView, 4)
Sleep(2000)
_GUICtrlListView_ScrollToItem($hListView, 3)
Sleep(2000)
_GUICtrlListView_ScrollToItem($hListView, 2)
Sleep(2000)
_GUICtrlListView_ScrollToItem($hListView, 1)
Sleep(2000)
_GUICtrlListView_ScrollToItem($hListView, 0)
Sleep(2000)

; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main

Func _GUICtrlListView_ScrollToItem($hListView, $item) ; $item : zero based ListViewItem
$item_to_scroll = $item
If $item_to_scroll >= 0 Then $item_to_scroll -= 1
$aRect = _GUICtrlListView_GetItemRect($hListView, $item_to_scroll, 3)
ConsoleWrite('$item: ' & $item & ' =============================' & @CRLF)
ConsoleWrite($aRect[0] & @CRLF)
ConsoleWrite($aRect[1] & @CRLF)
ConsoleWrite($aRect[2] & @CRLF)
ConsoleWrite($aRect[3] & @CRLF)
$V_iDY = $aRect[1] - 1
If $item <= 0 Then $V_iDY -= 12
_GUICtrlListView_Scroll($hListView, 1, $V_iDY)
EndFunc ;==>_GUICtrlListView_ScrollToItem

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

thanks BrewManNH

I dont know about that ($LVS_SHOWSELALWAYS) to this time.

But i guess my function can be helpful with ListView which is not created by my own script but ListView which is created by other program which somebody want to control.

Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Thanks. My advise post a link in the original post just in case.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Nice, but we have also _GUICtrlListView_EnsureVisible :whistle:

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...