Sign in to follow this  
Followers 0
MikahS

Scrolling 3 seperate Listboxes

9 posts in this topic

#1 ·  Posted (edited)

Hello AutoIt community,

I have a question for you all. Now, I know using a multi column listbox could do such as my question will ask, but I would like to know this for only multiple single column listbox's.

I have been able to select all three values and scroll the listbox's (I have 3 side by side) to the appropriate value of each column and match them up (only when an item has been selected). My problem is, I'd like the listboxes to scroll together, rather than independently. I have not tried scripting anything to help me do this, but I have taken a look at _GUIScrollBars which had a function called _GUIScrollBars_GetScrollInfoEx. Could the $tagSCROLLINFO structure be used to do this? It's probably due to ignorance that I think this, but could anyone enlighten me? o:)

EDIT: Maybe with _GUIScrollBars_GetScrollInfoTrackPos and _GUIScrollBars_SetScrollInfoPos? Did not work, as ScrollInfoTrackPos only tracks one scrollbar.

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

MikahS,

How about this for starters? ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListBox.au3>
#include <ScrollBarsConstants.au3>

Global Const $iMax = 40

Global $iPos_1 = 0, $iPos_2 = 0

$hGUI = GUICreate("Synchro Pair", 195, 240)
$cList_2 = GUICtrlCreateList("", 60, 5, 85, 220)

; Dummy to fire when list views are not synced
$cSync = GUICtrlCreateDummy()

GUISetState(@SW_SHOW)

$hGUI_Child = GUICreate("", 50, 220, 10, 5, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
$cList_1 = GUICtrlCreateList("", 0, 0, 85, 220)
GUISetState()

For $i = 1 To $iMax
    _GUICtrlListBox_AddString($cList_1, "1_" & $i)
    _GUICtrlListBox_AddString($cList_2, "2_" & $i)
Next

AdlibRegister("_Synchro")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cSync
            ; Stop Adlib
            AdlibUnRegister("_Synchro")
            ; Scroll List 1
            _GUICtrlListBox_SetTopIndex($cList_1, $iPos_2)
            ; Restart Adlib
            AdlibRegister("_Synchro")
    EndSwitch
WEnd


Func _Synchro()

    ; Get top index of each list
    $iPos_1 = _GUICtrlListBox_GetTopIndex($cList_1)
    $iPos_2 = _GUICtrlListBox_GetTopIndex($cList_2)
    ; Fire dummy
    GUICtrlSendToDummy($cSync)

EndFunc   ;==>_Synchro
There should be a message we can trap rather then using Adlib - I will see what I can develop. :)

M23

Edit:

ListBoxes are primitive beasts - if you wanted to use ListViews it is much more elegant: ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <GuiListView.au3>
#include <Misc.au3>
#include <GuiScrollBars.au3>

Global Const $iMax = 40

Global $iPos_1 = 0, $iPos_2 = 0

$hGUI = GUICreate("Synchro Pair", 195, 240, -1, -1)
$cLV_2 = GUICtrlCreateListView("LV_2", 60, 5, 85, 220)
$hLV_2 = GUICtrlGetHandle($cLV_2)
GUISetState(@SW_SHOW)

$hGUI_Child = GUICreate("", 50, 220, 10, 5, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
$cLV_1 = GUICtrlCreateListView("LV_1", 0, 0, 85, 220)
$hLV_1 = GUICtrlGetHandle($cLV_1)
GUISetState()

For $i = 1 To $iMax
    GUICtrlCreateListViewItem("Item " & $i, $cLV_1)
    GUICtrlCreateListViewItem("Item " & $i, $cLV_2)
Next

Global $aRect = _GUICtrlListView_GetItemRect($hLV_2, 0)
Global Const $iDeltaY = $aRect[3] - $aRect[1]
GUIRegisterMsg($WM_NOTIFY, "_WM_Notify")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _WM_Notify($hWnd, $Msg, $wParam, $lParam)
    Local Const $iLines = _SendMessage($hLV_2, $LVM_GETTOPINDEX) - _SendMessage($hLV_1, $LVM_GETTOPINDEX)
    _SendMessage($hLV_1, $LVM_SCROLL, 0, $iLines * $iDeltaY)
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>_WM_Notify
Credit to UEZ for this. ;) Edited by Melba23
Found a better function

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I will say, very nice Melba :D

I've been playing with it for a bit and a couple things I noticed, you are right it is easier to do this with ListViews instead of Listboxes ;)

The way I had my Listboxes setup was they each were able to independantly scroll (3 of them) of each other. I thought that I would need to think about that, but after staring at it I can see that that might be trying to do to much, and that I need to make it simplier.

I will update the topic soon with what I have decided should be the best way of doing what I think will be the best readable way of showing the data. I'm also thinking you have completely answered my question if I can do what I might be able to accomplish.

I would love if there was a way to make them all scrollable and still be able to scroll each one and then scroll the rest, whether that be list1, list2, or list3.

I will give this a try myself too.

Thank you for this, again :)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Again, Melba thanks for the code. :)

Here is what I used once I played around with it for a bit. I have changed the while loop to make sure the $cList_2 will always have focus, so using the scroll wheel is always possible. Also, I made it so the selection in the first box will match and highlight the second box's text value that matches the selected value in the first box, if no selection has been made in the first box and only in the second listbox then highlight both as well. Also added a check between the selected values and if they are already selected, then scroll only.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListBox.au3>
#include <ScrollBarsConstants.au3>

Global Const $iMax = 40

Global $iPos_1 = 0, $iPos_2 = 0

$hGUI = GUICreate("Synchro Pair", 195, 240)
$cList_2 = GUICtrlCreateList("", 60, 5, 85, 220)

; Dummy to fire when list views are not synced
$cSync = GUICtrlCreateDummy()

GUISetState(@SW_SHOW)
$hGUI_Child = GUICreate("", 50, 220, 10, 5, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
$cList_1 = GUICtrlCreateList("", 0, 0, 85, 220)
GUISetState()

For $i = 1 To $iMax
    _GUICtrlListBox_AddString($cList_1, "1_" & $i)
    _GUICtrlListBox_AddString($cList_2, "2_" & $i)
Next

AdlibRegister("_Synchro")

While 1
    If GUICtrlGetState($cList_2) <> 256 Then GUICtrlSetState($cList_2, $GUI_FOCUS) ; make sure $cList_2 always has focus
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cSync
            ; Stop Adlib
            AdlibUnRegister("_Synchro")
            ; Scroll List 1
            _GUICtrlListBox_SetTopIndex($cList_1, $iPos_2)
            ; Restart Adlib
            AdlibRegister("_Synchro")
    EndSwitch
WEnd

Func _Synchro()
    Local $gs, $ss, $ft

    ; Get top index of each list
    $iPos_1 = _GUICtrlListBox_GetTopIndex($cList_1)
    $iPos_2 = _GUICtrlListBox_GetTopIndex($cList_2)
    If _GUICtrlListBox_GetCurSel($cList_1) = _GUICtrlListBox_GetCurSel($cList_2) Then ; if the selections are the same in both listboxes
        GUICtrlSendToDummy($cSync) ; send the message to scroll (event)
        Return ; get out
    Else
        $gs = _GUICtrlListBox_GetCurSel($cList_1) ; get the current selection in $cList_1
        If $gs = -1 Then ; if there is no selection
            $gs = _GUICtrlListBox_GetCurSel($cList_2) ; check $cList_2
            $ss = _GUICtrlListBox_SetCurSel($cList_1, $gs) ; set the currently selected value in $cList_2 to $cList_1
            GUICtrlSendToDummy($cSync) ; send the message to scroll
            Return ; get out
        EndIf
        $ss = _GUICtrlListBox_SetCurSel($cList_2, $gs) ; set the selection in $cList_2
        ; Fire dummy
        GUICtrlSendToDummy($cSync) ; send the message to scroll (event)
    EndIf
EndFunc   ;==>_Synchro
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

MikahS,

Having seen that I wonder why you do not use a single 2-column ListView - much simpler to code: ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

Global Const $iMax = 40

$hGUI = GUICreate("ListView", 200, 240)

$cLV = GUICtrlCreateListView(" | ", 10, 10, 180, 220, $LVS_NOCOLUMNHEADER)
_GUICtrlListView_SetColumnWidth($cLV, 0, 78)
_GUICtrlListView_SetColumnWidth($cLV, 1, 78)

For $i = 1 To $iMax
    GUICtrlCreateListViewItem("1_" & $i & "|2_" & $i, $cLV)
Next

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hmm. I've actually never used ListViews before, so I was hesitant to redo all my code, but it just seems everything is easier with a ListView ;)

EDIT: converting everything to a listview, thanks Melba :)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

MikahS,

ListViews are complicated beasts to be sure, but they are much more flexible than simple ListBoxes. If you want a taste of what you can do with them, have a play with the examples in my GUIListViewEx UDF. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Bad wording on my part heh, but I will take a look at your UDF Melba and again, thanks for the exemplary help. :D


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

MikahS,

My pleasure, as always. :)

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0

  • Similar Content

    • slidy56fr
      By slidy56fr
      Internet Explorer 11, AutoIt 3.3.14.2
      I want to download many files which are published with hyperlink on a web page. I use AutoIt and when there is a few files, it works even if It's on a website with secured links.
      I have a script to download link items with the object method (I gave a partial sample), but when the number of link exceed the web page, there is not an auto scroll, then the links which are not on displayed without scroll are not downloaded.
      Thank you
      From France
       
       
      EchantillonRecepAnonym.au3
    • mpower
      By mpower
      Hi guys, I have a GUI which requires scrolling, however resizing is a bit of a problem because any time you scroll down/up and then resize, the controls move down/up and blank space is created within the scrollable area. 
      Any help with maintaining scrollable area size to be fixed would be great.
      Here is a reproducer:
      To achieve the undesirable effect I described, simply run the script, scroll down and then resize window. You will notice that new blank space is created either on top or on bottom of the window depending on scrolling/resizing direction. Easiest way to see how bad it is, is to scroll down the page about half-way and then maximise the window. You will notice now a whole bunch of blank space is added to the top of the window and scrolling up simply shows nothing, scrolling down shows controls but they are cut off because of the blank space created on top of the page.
      This is all happening within the yellow bg  child gui. I need to make it so that even if the GUI is resized the contents of the yellow bg child gui do not move and the scrollable area within the child gui remains the same.
      #NoTrayIcon #include-once #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIScroll.au3> #include <SendMessage.au3> Opt("GUIResizeMode", 802) Global $parentgui_w = 880, $parentgui_h = 810, $childgui_w = $parentgui_w - 2, $childgui_h = $parentgui_h - 292 $parentgui = GUICreate("Scrollbar resize problem", $parentgui_w, $parentgui_h, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetBkColor(0xFFFFFF, $parentgui) $childgui = GUICreate("", $childgui_w, $childgui_h, -5, 263, $WS_POPUP, $WS_EX_MDICHILD, $parentgui) GUISetBkColor(0xFFF123, $childgui) Dim $buttons[25] For $i = 0 to 24 If $i > 0 Then $cPos = ControlGetPos($childgui, "", $buttons[$i - 1]) $buttons[$i] = GUICtrlCreateButton("Button " & $i + 1, ($childgui_w - 200) / 2, $cPos[1] + $cPos[3] + 50, 200, 80) Else $buttons[$i] = GUICtrlCreateButton("Button " & $i + 1, ($childgui_w - 200) / 2, 20, 200, 80) EndIf Next Scrollbar_Create($childgui, $SB_VERT, 130 * 25) Scrollbar_Step(15, $childgui, $SB_VERT) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_NCACTIVATE, "WM_NCACTIVATE") GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") GUISetState(@SW_SHOW, $parentgui) GUISetState(@SW_SHOWNOACTIVATE, $childgui) While 1 $msg = GUIGetMsg(1) Switch $msg[1] Case $parentgui Switch $msg[0] Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_RESTORE $pPos = WinGetPos($parentgui) WinMove($parentgui, "", Default, Default, $pPos[2]+1, $pPos[3]+1) WinMove($parentgui, "", Default, Default, $pPos[2]-1, $pPos[3]-1) EndSwitch EndSwitch WEnd Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) Local $iMw = BitShift($wParam, 16) $scroll_lines = 5 If $iMw > 0 Then For $i = 0 to $scroll_lines _SendMessage($childgui, $WM_VSCROLL, $SB_LINEUP) Next Else For $i = 0 to $scroll_lines _SendMessage($childgui, $WM_VSCROLL, $SB_LINEDOWN) Next EndIf Return $GUI_RUNDEFMSG EndFunc Func WM_SIZE($hwnd, $uMsg, $wParam, $lParam) If $hwnd = $parentgui Then $wPos = WinGetPos($parentgui) $pgui_wdiff = ($wPos[2] - $parentgui_w) / 2 $pgui_hdiff = ($wPos[3] - $parentgui_h) / 2 If $pgui_wdiff > 7 Then If $pgui_hdiff <> 0 Then If $wPos[2] > $parentgui_w Then WinMove($childgui, "", $wPos[0] + 2 + $pgui_wdiff, Default, $parentgui_w - 2, $wPos[3] - 306) Else WinMove($childgui, "", $wPos[0] + 2 + $pgui_wdiff, Default, $wPos[2] - 16, $wPos[3] - 306) EndIf Else WinMove($childgui, "", $wPos[0] + 2 + $pgui_wdiff, Default) EndIf ElseIf $pgui_wdiff < 7 Then If $wPos[0] <> -32000 Then WinMove($childgui, "", $wPos[0] + 8, Default, $wPos[2] - 16, $wPos[3] - 306) EndIf ElseIf $pgui_hdiff > 42 Then WinMove($childgui, "", Default, Default, Default, $wPos[3] - 306) EndIf EndIf Return 0 EndFunc Func WM_NCACTIVATE($hwnd, $imsg, $wparam) If $hwnd = $parentgui Then If NOT $wparam Then Return 1 EndIf Return $gui_rundefmsg EndFunc  
    • Herb191
      By Herb191
      How can you scroll to the end of a text area in IE without using focus/ControlSend? I have tried several solutions (see code below) but I can't seem to get them to work.
      Test HTML (test.html)
      <!DOCTYPE html> <html> <body> <textarea id="textarea-test" rows="4" cols="50"> </textarea> </body> </html>  
      AutoIt Test Code:
      #RequireAdmin #include <IE.au3> $oIE = _IECreate(@ScriptDir & "\test.html") Local $hWnd = _IEPropertyGet($oIE, "hwnd") Local $oTextarea = _IEGetObjById($oIE, "textarea-test") Local $sText = "" For $i = 1 To 30 $sText &= $i & "&#13;&#10;" _IEPropertySet($oTextarea, "innerhtml", $sText) ;NOT WORKING ;$oTextarea.document.parentwindow.scroll(0, 99999) ;_IEAction($oTextarea, "scrollintoview") ;NOT WORKING ;$iDocHeight = $oTextarea.document.body.scrollHeight() ;$oTextarea.document.parentwindow.scrollTo(0, $iDocHeight) ;NOT WORKING ;$oTextarea.document.parentwindow.scrollTo(0, 99999) ;NOT WORKING ;$oTextarea.scrollintoview() ;WORKING _IEAction($oTextarea, "focus") ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "^{end}") Sleep(100) Next  
       
    • vkrisz81
      By vkrisz81
      hello! how it possible, i load a siote, i send a scroll (send up) or simpley scroll by scrollbar, and the after and pre datas are same?
      i mean
      ;~ l(_IEPropertyGet($l,"browsery"))
      ;~ l(_IEPropertyGet($l,"screeny"))
      ;~ l(_IEPropertyGet($l,"top"))
      so these parameters dont change after effect.. is it possible?
      $l is a html element on page! i wanted to scroll up to be visible, but i cant check its coordniates because those dont change!!!
      and if i try mousewheel lthere is not happen any, only in my editor scrolling but ie window dont!
      can i check anyway that given html element is in the lookable area and if not i scrolll and is it succesfull?
      i tried this only.
      TY
    • Servant
      By Servant
      Could you please show me or refer me to the documents how to do these things:
      Remap the {LEFT CLICK} to letter A. Remap the {RIGHT CLICK} to letter B. Remap the {MIDDLE CLICK} to letter C. Remap every single {SCROLL UP} to number 1. Remap every single {SCROLL DOWN} to number 2. It looks like it's hard to remap the mouse' elements..