Valnurat

A little advice

12 posts in this topic

What kind og GUI item can I use to show some numbers in?

I would like to have the option not to have scrollbars and if possible have 3 columns and it sould also have the option to sort the content.

What would you suggest?


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

Valnurat,

I would suggest a ListView.

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

Ok, but it dosen't seem that I have any option to not have any scrollbars.


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

Valnurat,

You only get scrollbars if there are too many items to fit into the control - and if you did not have the scrollbars you would not be able to see the items. Why is this such a breaking point?

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

That's true, but in my situation it is not necessary to see them all. Only the top 20 numbers.

Can you change the size of the font in the ListView?


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

Valnurat,

Quote

Can you change the size of the font in the ListView?

Yes, if you create the ListView with GUICtrlCreateListView then GUICtrlSetFont will work.

And if you only want the top 20, then only load that many into the ListView - that way you will avoid scrollbars if you size the control correctly:

#include <GUIConstantsEx.au3>
#include <GUIListView.au3>

$hGUI = GUICreate("Test", 500, 500)

$cLV = GUICtrlCreateListView("Col 0|Col 1|Col 2", 10, 10, 480, 480)

; Size columns
For $i = 0 To 2
    _GUICtrlListView_SetColumnWidth($cLV, $i, Int(480 / 3) - 2) ; avoid horizontal scrollbar by makign columns slightly smaller then total width
Next

; Fill ListView with 20 items
For $i = 0 To 19
    GUICtrlCreateListViewItem(StringFormat("%05i", $i) & "|" & StringFormat("%05i", $i) & "|" & StringFormat("%05i", $i), $cLV)
Next

; Now size ListView vertically
$hHeader = _GUICtrlListView_GetHeader($cLV)
$aSize = WinGetPos($hHeader)
$iHeaderHeight = $aSize[3] ; Header height
$aRect = _GUICtrlListView_GetItemRect($cLV, 0)
$iItemHeight = $aRect[3] - $aRect[1] ; Item height
$iTotalHeight = $iHeaderHeight + (20 * ($iItemHeight + .5)) ; Allow for the inter-item gaps
; Resize ListView
GuiCtrlSetPos($cLV, 10, 10, 480, $iTotalHeight)

GUISetState()

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

#7 ·  Posted (edited)

Thank you M23.

I need to have 3 listview in my project.

1. To have a listview1 with 3 columns with vertical lines to seperate the columns and in designtime have vertical scrollbars and no horizontial. I want to know from the start, how it would look like when numbers are added.

2. To have another listview2 that only show the top 20 numbers out of 90 and when numbers are picked out from LV2 it should be transferred to listview3 and then the next number should be visible. E.g. In your example 0-19 are visible. If 7 is picked, it should still show the top 20 numbers in LV2 and 7 is moved to LV3.

For now it seems that the listview only show scrollbars if it is necessary. Or do you have another suggestion?

Edited by Valnurat

Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

Valnurat,

How about this:

#include <GUIConstantsEx.au3>
#include <GUIListView.au3>

$iMax = 90

Global $aMainArray[$iMax]
For $i = 0 To $iMax - 1
    $aMainArray[$i] = StringFormat("%05i", $i) & "|" & StringFormat("%05i", $i) & "|" & StringFormat("%05i", $i)
Next

$hGUI = GUICreate("Test", 900, 500)

; Create ListView 1
$cLV_1 = GUICtrlCreateListView("Col 0|Col 1|Col 2", 10, 10, 280, 480)
; Size columns
For $i = 0 To 2
    _GUICtrlListView_SetColumnWidth($cLV_1, $i, Int(280 / 3) - 2) ; avoid horizontal scrollbar by making columns slightly smaller then total width
Next

; Fill ListView with all items
For $i = 0 To $iMax - 1
    GUICtrlCreateListViewItem($aMainArray[$i], $cLV_1)
Next

; Now calculate ListView 2 vertical size
$hHeader = _GUICtrlListView_GetHeader($cLV_1)
$aSize = WinGetPos($hHeader)
$iHeaderHeight = $aSize[3] ; Header height
$aRect = _GUICtrlListView_GetItemRect($cLV_1, 0)
$iItemHeight = $aRect[3] - $aRect[1] ; Item height
$iTotalHeight = $iHeaderHeight + (20 * ($iItemHeight + .5)) ; Allow for the inter-item gaps

; Create ListView 2
$cLV_2 = GUICtrlCreateListView("Col 0|Col 1|Col 2", 300, 10, 280, $iTotalHeight)
For $i = 0 To 2
    _GUICtrlListView_SetColumnWidth($cLV_2, $i, Int(280 / 3) - 2)
Next
; Fill with top 20 of array
For $i = 0 To 19
    GUICtrlCreateListViewItem($aMainArray[$i], $cLV_2)
Next

; Create button to move element from ListView 2 to ListView 3
$cMove = GUICtrlCreateButton("Move Selected", 300, 430, 280, 60)

; Create ListView 3
$cLV_3 = GUICtrlCreateListView("Col 0|Col 1|Col 2", 600, 10, 280, 480)
; Size columns
For $i = 0 To 2
    _GUICtrlListView_SetColumnWidth($cLV_3, $i, Int(280 / 3) - 2)
Next

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cMove
            $sText = _GUICtrlListView_GetItemTextString($cLV_2)
            If $sText Then
                ; Add to ListView 3
                GUICtrlCreateListViewItem($sText, $cLV_3)
            EndIf
            ; Find element in main array
            $iIndex = _ArraySearch($aMainArray, $sText)
            If $iIndex <> - 1 Then
                ; Delete it
                _ArrayDelete($aMainArray, $iIndex)
            EndIf
            ; Now clear ListViews 1 & 2
            _GUICtrlListView_BeginUpdate($cLV_1)
            _GUICtrlListView_BeginUpdate($cLV_2)
            _GUICtrlListView_DeleteAllItems($cLV_1)
            _GUICtrlListView_DeleteAllItems($cLV_2)
            ; And reload with all / the top 20 elements in the main array
            $iMax = UBound($aMainArray) - 1
            For $i = 0 To $iMax
                GUICtrlCreateListViewItem($aMainArray[$i], $cLV_1)
                If $i < 20 Then
                    GUICtrlCreateListViewItem($aMainArray[$i], $cLV_2)
                EndIf
            Next
            _GUICtrlListView_EndUpdate($cLV_1)
            _GUICtrlListView_EndUpdate($cLV_2)
    EndSwitch
WEnd

That seems to do what you require.

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

That is awesome.

Is it possible to have vertical lines between the column all the way down in listview 1 and can you sort listview 3?


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Listview1 should have 3 columns, Listview 2 and 3 should only have 1 column.

And it could be nice if there was no header in the listviews.

Edited by Valnurat

Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

Valnurat,

12 hours ago, Valnurat said:

Is it possible to have vertical lines between the column all the way down in listview 1

You can apply the $LVS_EX_GRIDLINES style, but that gives you vertical and horizontal lines.

12 hours ago, Valnurat said:

can you sort listview 3?

Yes, the _GUICtrlListView_SimpleSort example in the Help file shows you how to do it.

1 hour ago, Valnurat said:

Listview1 should have 3 columns, Listview 2 and 3 should only have 1 column

Then amend the code used when you create the ListViews 2 & 3.

1 hour ago, Valnurat said:

And it could be nice if there was no header in the listviews.

Just apply the $LVS_NOCOLUMNHEADER style.

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

Thank you very much. 5 stars.

I learn a lot from your example.


Yours sincerely

Kenneth.

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

  • Similar Content

    • Ascer
      By Ascer
      1. Description
      Anti-bot system to avoid spam. Vector graphic style generates 4 random numbers from 0-9 and create a picture. 2. Requirements
      .NET Framework 1.1 - 4.5 (on this version Microsoft destroy old rules) 3. Possibilities.

      4. Downloads.
      Source package Capatcha.rar
    • Valnurat
      By Valnurat
      How can I get combobox value by using  the ENTER key?
    • vyperhand
      By vyperhand
      I'm struggling to launch a VBS file via autoit using RunWait.  Due to the nature of the deployment tool I am using for said script, I only know that the .vbs files will be in the same directory as my AutoIt-generated .exe, but not what that path will be.  The path will look something like this:
      c:\programdata\vendor\lots\of\folders\randomnumber
      This is generated during deployment and I have no way of predicting the path - therefore, I am not sure how to call back to "same directory" in order to successfully launch the .vbs.
      This line is as close as I have gotten - this fires off the cmd window, but it closes immediately with out information, and the .vbs is not launched.
      RunWait (@ComSpec & " /c" & 'cscript.exe WORKPLEASE.vbs ALL /Q /NoCancel') I thought /c might be the problem, but leaving out the /c element causes me not to even see the momentary CMD window flash by.  Any help will be greatly appreciated, and thanks in advance.
    • Valnurat
      By Valnurat
      I have a ComboBox and I want, when I start writting in it, that it will show me what is the first in the list.
      Like, is I start writting:
      "pe" it  should show me "peter" if that is the first in the list.
      How can I do that?
       
      While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idClos ExitLoop Case $idComboBox $sComboRead = GUICtrlRead($idComboBox) Local $iIdx = _ArraySearch($aResult,$sComboRead,0,0,0,0,1,1) Local $aComputerOwner = _AD_GetObjectsInOU("OU=al,DC=AD,DC=AL,DC=ORG","(&(objectclass=computer)(managedby=" & $aResult[$iIdx][0] & "))",Default,"cn") _ArrayDelete($aComputerOwner,0) _GUICtrlListView_SetItemCount($idMylist,UBound($aComputerOwner)) If IsArray($aComputerOwner) Then For $i = 0 To UBound($aComputerOwner) - 1 GUICtrlCreateListViewItem($aComputerOwner[$i], $idMylist) Next Else GUICtrlSetData($idMylist, "No computer|") EndIf EndSwitch WEnd  
    • Valnurat
      By Valnurat
      Hi.
      I'm trying to add an array to my gui listview, but it fails with
      "C:\Program Files (x86)\AutoIt3\Include\GuiListView.au3" (473) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: DllStructSetData($tBuffer, "Text", $aItems[$iI][0]) DllStructSetData($tBuffer, "Text", ^ ERROR My code is:
      #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <WindowsConstants.au3> #include <ComboConstants.au3> #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #Include <AD.au3> #include <Array.au3> Opt('MustDeclareVars', 1) Global $aResult[0][2] Local $aNames[4] = ["DKSO","DKKO","SELU","SEES"] Local Const $iWidth = 300, $iHeight = 250, $iW = 85, $iH = 25 Local $hGUI = GUICreate("Find Computer Owner", $iWidth, $iHeight) ; Create a combobox control. Local $idComboBox = GUICtrlCreateCombo("", 2, 2, 296, 20, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL, $CBS_SORT)) ;$WS_VSCROLL Local $idMylist = GUICtrlCreateListView("", 2, 114, 296, 100) Local $idClos = GUICtrlCreateButton("Close", ($iWidth - $iW) / 2, ($iHeight - $iH) - 7 , $iW, $iH) _AD_Open() Local $sFill = "" For $i = 0 to UBound($aNames) -1 Local $aUserInfo = _AD_GetObjectsInOU("OU=Al,DC=ad,DC=al,DC=org","(&(objectCategory=Person)(objectclass=user)(sAMAccountName=" & $aNames[$i] & "*))","","distinguishedName,cn") if @error Then MsgBox(0,@error,@extended) Exit EndIf For $x = $aUserInfo[0][0] To 1 Step -1 If $aUserInfo[$x][0] = "" Or StringInStr($aUserInfo[$x][0], "Resources") > 0 Or StringInStr($aUserInfo[$x][0], "Leavers") > 0 Or StringInStr($aUserInfo[$x][0], "Administration") > 0 Then _ArrayDelete($aUserInfo, $x) EndIf Next _ArrayConcatenate($aResult, $aUserInfo, 1) Next for $i = 0 To UBound($aResult) -1 If $aResult[$i][0] <> "" Then $sFill &= $aResult[$i][1] & "|" EndIf Next _ArrayDisplay($aResult, 'AD ' & UBound($aResult)) $sFill = StringTrimRight($sFill, 1) _GUICtrlComboBox_BeginUpdate($idComboBox) GUICtrlSetData($idComboBox, $sFill, "") _GUICtrlComboBox_EndUpdate($idComboBox) GUISetState(@SW_SHOW, $hGUI) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _GUICtrlListView_AddColumn($idMylist, "Computername", 296) Local $sComboRead = "" ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idClos ExitLoop Case $idComboBox $sComboRead = GUICtrlRead($idComboBox) Local $iIdx = _ArraySearch($aResult,$sComboRead,0,0,0,0,1,1) Local $aComputerOwner = _AD_GetObjectsInOU("OU=al,DC=AD,DC=AL,DC=ORG","(&(objectclass=computer)(managedby=" & $aResult[$iIdx][0] & "))",Default,"cn") _ArrayDelete($aComputerOwner,0) _ArrayDisplay($aComputerOwner) _GUICtrlListView_SetItemCount($idMylist,UBound($aComputerOwner)) If IsArray($aComputerOwner) Then MsgBox(0,"Test",$sComboRead) _GUICtrlListView_AddArray($idMylist, $aComputerOwner) ; <---- it fails Else GUICtrlSetData($idMylist, "No computer|") EndIf EndSwitch WEnd _AD_Close() ; Delete the previous GUI and all controls. GUIDelete($hGUI) Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo ; Local $tBuffer $hWndListView = $idMylist If Not IsHWnd($idMylist) Then $hWndListView = GUICtrlGetHandle($idMylist) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ; No return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @CRLF & _ "+======================================================" & @CRLF & _ "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _ "+======================================================" & @CRLF) EndFunc ;==>_DebugPrint Do I do it wrong?
       
      Thank you in advanced.