supersonic Posted January 22, 2010 Share Posted January 22, 2010 Hi! Is there a way to connect (~ bind) two ListView controls to scroll them down at the same time? I have no idea to realize this, so I have no sample code so far... Can someone gimme a clue? Greets, -supersonic. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 22, 2010 Moderators Share Posted January 22, 2010 supersonic, Why not make a ListView with 2 columns? Seems a lot easier to me! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
supersonic Posted January 22, 2010 Author Share Posted January 22, 2010 M23,Currently I have one LV.My idea:the first (= left) ListView lists our AD-Users.The second (= right) ListView lists some AD-Attributesfor the users shown in the left LV.When I scoll the right LV I would like toknow to whom the attributes belong.Any ideas?supersonic,Why not make a ListView with 2 columns? Seems a lot easier to me! M23 Link to comment Share on other sites More sharing options...
picea892 Posted January 22, 2010 Share Posted January 22, 2010 Scrolling first listview scrolls the second...could work vice versa also but did not set it up that way. #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $iLastPos = IniRead("Test.ini", "Scroll", "VPos", 0) $GUI = GUICreate("Test Script", 600, 200) $ListView = GUICtrlCreateListView("Col ", 20, 20, 260, 160) $hListView = GUICtrlGetHandle($ListView) $ListView2 = GUICtrlCreateListView("Col ", 280, 20, 260, 160) $hListView2 = GUICtrlGetHandle($ListView2) For $i = 1 To 80 GUICtrlCreateListViewItem("Item " & $i, $ListView) GUICtrlCreateListViewItem("Next " & $i, $ListView2) Next GUISetState(@SW_SHOW, $GUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch if _GUICtrlListView_GetTopIndex($hListView)<_GUICtrlListView_GetTopIndex($hListView2) then _GUICtrlListView_Scroll($hListView2, 0, -12) elseif _GUICtrlListView_GetTopIndex($hListView)>_GUICtrlListView_GetTopIndex($hListView2) then _GUICtrlListView_Scroll($hListView2, 0, +12) EndIf WEnd Link to comment Share on other sites More sharing options...
Mat Posted January 22, 2010 Share Posted January 22, 2010 Heres an example using WM_NOTIFY, which for some odd reason doesn't work perfectly if you shake the scroll bar up and down expandcollapse popup#include<SendMessage.au3> #include<WindowsConstants.au3> #include<StructureConstants.au3> #include<ListViewConstants.au3> Global $hGUI, $hList1, $hList2 $hGUI = GUICreate("Testing scroll", 500, 600) $hList1 = GUICtrlCreateListView("List view 1", 2, 2, 248, 596) $hList2 = GUICtrlCreateListView("List view 2", 253, 2, 249, 596) GUISetState() For $i = 1 To 500 GUICtrlCreateListViewItem($i, $hList1) GUICtrlCreateListViewItem($i, $hList2) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While GUIGetMsg() <> -3 WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) If DllStructGetData($tNMHDR, "code") <> $LVN_ENDSCROLL Then Return Local $hListFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $tNMLVSCROLL = DllStructCreate($tagNMLVSCROLL, $lParam) If $hListFrom = GUICtrlGetHandle($hList1) Then GUICtrlSendMsg($hList2, $LVM_SCROLL, DllStructGetData($tNMLVSCROLL, "dx"), DllStructGetData($tNMLVSCROLL, "dy") * 16) ElseIf $hListFrom = GUICtrlGetHandle($hList2) Then GUICtrlSendMsg($hList1, $LVM_SCROLL, DllStructGetData($tNMLVSCROLL, "dx"), DllStructGetData($tNMLVSCROLL, "dy") * 16) EndIf EndFunc ;==>WM_NOTIFY AutoIt Project Listing Link to comment Share on other sites More sharing options...
supersonic Posted January 22, 2010 Author Share Posted January 22, 2010 Thank you!Scrolling first listview scrolls the second...could work vice versa also but did not set it up that way. Link to comment Share on other sites More sharing options...
supersonic Posted January 22, 2010 Author Share Posted January 22, 2010 Thank you! Indead, heavy scrolling will not resync the ListViews. Never mind, better than nothing! :-) Heres an example using WM_NOTIFY, which for some odd reason doesn't work perfectly if you shake the scroll bar up and down expandcollapse popup#include<SendMessage.au3> #include<WindowsConstants.au3> #include<StructureConstants.au3> #include<ListViewConstants.au3> Global $hGUI, $hList1, $hList2 $hGUI = GUICreate("Testing scroll", 500, 600) $hList1 = GUICtrlCreateListView("List view 1", 2, 2, 248, 596) $hList2 = GUICtrlCreateListView("List view 2", 253, 2, 249, 596) GUISetState() For $i = 1 To 500 GUICtrlCreateListViewItem($i, $hList1) GUICtrlCreateListViewItem($i, $hList2) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While GUIGetMsg() <> -3 WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) If DllStructGetData($tNMHDR, "code") <> $LVN_ENDSCROLL Then Return Local $hListFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $tNMLVSCROLL = DllStructCreate($tagNMLVSCROLL, $lParam) If $hListFrom = GUICtrlGetHandle($hList1) Then GUICtrlSendMsg($hList2, $LVM_SCROLL, DllStructGetData($tNMLVSCROLL, "dx"), DllStructGetData($tNMLVSCROLL, "dy") * 16) ElseIf $hListFrom = GUICtrlGetHandle($hList2) Then GUICtrlSendMsg($hList1, $LVM_SCROLL, DllStructGetData($tNMLVSCROLL, "dx"), DllStructGetData($tNMLVSCROLL, "dy") * 16) EndIf EndFunc ;==>WM_NOTIFY Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 22, 2010 Moderators Share Posted January 22, 2010 supersonic,the first (= left) ListView lists our AD-Users.The second (= right) ListView lists some AD-AttributesIf you have the all data on hand to populate both ListViews and the data is synchronised line-to-line before you start any scrolling, I still believe it would be much easier to make a single ListView to hold all the data and make the whole problem moot...... But it is your script - you decide. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ResNullius Posted January 23, 2010 Share Posted January 23, 2010 Building on picea892's idea, here is one that doesn't lag when you have a large number of items in the list view: expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $iLastPos = IniRead("Test.ini", "Scroll", "VPos", 0) $GUI = GUICreate("Test Script", 600, 200) $ListView = GUICtrlCreateListView("Col ", 20, 20, 260, 160) $hListView = GUICtrlGetHandle($ListView) $ListView2 = GUICtrlCreateListView("Col ", 280, 20, 260, 160) $hListView2 = GUICtrlGetHandle($ListView2) For $i = 1 To 1000 GUICtrlCreateListViewItem("Item " & $i, $ListView) GUICtrlCreateListViewItem("Next " & $i, $ListView2) Next GUISetState(@SW_SHOW, $GUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $iLvTopItem = _GUICtrlListView_GetTopIndex($hListView) $iLv2TopItem = _GUICtrlListView_GetTopIndex($hListView2) $iLvVertSpacing = _GUICtrlListView_GetItemSpacingY($hListView2) _GUICtrlListView_EnsureVisible($hListView2, $iLvTopItem) If $iLvTopItem < $iLv2TopItem Then ;ConsoleWrite("Less Than:" & @TAB & $iLv2TopItem - $iLvTopItem & @CRLF) _GUICtrlListView_EnsureVisible($hListView2, $iLvTopItem - $iLv2TopItem) ElseIf $iLvTopItem > $iLv2TopItem Then ;ConsoleWrite("Greater Than:" & @TAB & $iLvTopItem - $iLv2TopItem & @CRLF) _GUICtrlListView_Scroll($hListView2, 0, $iLvVertSpacing) EndIf WEnd Link to comment Share on other sites More sharing options...
gcue Posted April 19, 2012 Share Posted April 19, 2012 very nice ResNulius, can the same logic exist so it would apply to both scroll bars? i have two listviews that I would like to scroll simultaneously - i have 2 seperate listviews because different actions can be done to either so that's why i keep them seperate Link to comment Share on other sites More sharing options...
gcue Posted April 23, 2012 Share Posted April 23, 2012 *bump* Link to comment Share on other sites More sharing options...
water Posted April 23, 2012 Share Posted April 23, 2012 Hi gcue,I would stick with Melba's suggestion. Much easier to code and easy to understand for the user because there is a 1:1 realationship between the AD user and the properties.Or do you have andy reasons why you need two LVs? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
gcue Posted April 23, 2012 Share Posted April 23, 2012 hey water =) the script is intended to resolve a list of user account names to person's full names in the other list view. so having them as seperate listviews helps with the usability so that the user can visually seperate the 2 different entities. so thats why i wanted the scroll thing to work, so that both lists scroll at the same time and items that correlate with each other on both lists correspond to each other even when scrolling. also i have buttons that perform actions on each list - hard to do when you have just one listview Link to comment Share on other sites More sharing options...
water Posted April 23, 2012 Share Posted April 23, 2012 I change the color of every 2nd listview line to make it easier for the user to read. I see no problem with bottons acting on different columns of a listview. Conclusion: It should be easy to keep everything in one listview My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
gcue Posted April 23, 2012 Share Posted April 23, 2012 ok ill try that - thanks Link to comment Share on other sites More sharing options...
water Posted April 23, 2012 Share Posted April 23, 2012 Code snippet how I fill the LV and change the color of every second line; Create the LV in the GUI Global $hGUIUserList = GUICtrlCreateListView("OrgEinheit|Name|Kurzzeichen", 8, 24, 313, 630, $LVS_SHOWSELALWAYS) ... ; Fill LV _GUICtrlListView_BeginUpdate($hGUIUserList) For $ii = 1 To $asUser[0][0] GUICtrlCreateListViewItem($asUser[$ii][0] & "|" & $asUser[$ii][1] & "|" & $asUser[$ii][3], $hGUIUserList) If Mod($iRec, 2) = 0 Then GUICtrlSetBkColor(-1, 0xD0DEC7) ; Change color of every second line Next _GUICtrlListView_EndUpdate($hGUIUserList) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
gcue Posted April 23, 2012 Share Posted April 23, 2012 cool thanks water! =) Link to comment Share on other sites More sharing options...
water Posted April 23, 2012 Share Posted April 23, 2012 If you have further questions I will be glad to help! My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now