Sign in to follow this  
Followers 0
nitekram

_ArrayDisplay

14 posts in this topic

Trying to add some functionality to the command/function _ArrayDisplay, and I am a little stuck...I added the following to Array.au3, can someone help a little, after clicking the header of the display, I am trying to sort them based on the header clicked, I would like to keep the original bracketed numbers to the left of the display. Similar on how it displays now, but when I click it, it removes the first column and shifts everything to the left. I would like it to remain in place. Also, I was thinking that this code, when complete could be added to the _ArrayDisplay command?

This code was added to the Array.au3 file in the main while loop for the function _ArraysDisplay()

Case $hListView
    Local $iIndexClicked = GUICtrlGetState($hListView)
    Local $iColumnNumber = UBound($avArray, 2)
    If $iColumnNumber = 0 Then Return
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_GUI_LVM_DELETEALLITEMS, 0, 0)
    $aSortedArray = $avArray
    ;
    _ArraySort($aSortedArray, 0, 1, 0, $iIndexClicked)
    ;
    Local $avNewArray[UBound($aSortedArray, 1)]
    For $i = 0 To UBound($aSortedArray) - 1
        For $y = 0 To UBound($aSortedArray, 2) - 1
            If $y <> UBound($aSortedArray, 2) - 1 Then
                $avNewArray[$i] &= $aSortedArray[$i][$y] & '|'
            Else
                $avNewArray[$i] &= $aSortedArray[$i][$y]
            EndIf
        Next
    Next
    ;
    For $z = 0 To UBound($avNewArray) - 1
        GUICtrlCreateListViewItem($avNewArray[$z], $hListView)
    Next

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

It would be a lot more efficient to create your own instead of messing around with _ArrayDisplay.

Look in the help file for WM_NOTIFY and _GUICtrlListView_SortItems/_GUICtrlListView_SimpleSort.

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Are you saying I should recreate the wheel? Is there some more functionality if I were to create my own list view?

I guess I will just leave it the way it is...not to many users using it anyway. But I did think that it would be a great addition to the already used _ArrayDisplay, I guess that is a NO?


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

I'm not telling you to recreate the wheel, I'm saying modifying _ArrayDisplay is more pain than it's worth. _ArrayDisplay is for debugging and I'm sure if you search someone has probably already done it.

 

site:autoitscript.com _arraydisplay column sort


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks for that...I did find someone that did it back in 2008. Looks like it will work. Is there a reason (I know that _arraydisplay is used for debugging, but it can also be used) that sorting should not be part of this function? Just wondering as, that would be great for debugging.

In either case I found the page here

It is funny that I could not find the same thing written in autoit, or I guess I might have missed it.

Mine does work...except for the first time it is used, you need to click the column twice and of course as mentioned, it removes the index column and moves everything over to the right.

If someone finds it in pure AutoIt, can you please post it or the link?

EDIT spelling

Edit - added web info

http://produi-repository.googlecode.com/svn/trunk/ProdUISystem/ProdUI/Bridge/NativePatterns/MessageConstants/ListViewConstants.cs

LVM_FIRST = 0x1000,

LVM_ARRANGE = LVM_FIRST + 22,

LVM_DELETEALLITEMS = LVM_FIRST + 9,

LVM_DELETECOLUMN = LVM_FIRST + 28,

LVM_DELETEITEM = LVM_FIRST + 8,

LVM_EDITLABEL = LVM_FIRST + 118,

LVM_ENSUREVISIBLE = LVM_FIRST + 19,

LVM_FINDITEM = LVM_FIRST + 83,

LVM_GETCOLUMN = LVM_FIRST + 95,

LVM_GETCOLUMNORDERARRAY = LVM_FIRST + 59,

LVM_GETCOLUMNWIDTH = LVM_FIRST + 29,

LVM_GETEDITCONTROL = LVM_FIRST + 24,

LVM_GETEMPTYTEXT = LVM_FIRST + 204,

LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55,

LVM_GETHEADER = LVM_FIRST + 31,

LVM_GETIMAGELIST = LVM_FIRST + 2,

LVM_GETISEARCHSTRING = LVM_FIRST + 117,

LVM_GETITEM = LVM_FIRST + 75,

LVM_GETITEMCOUNT = LVM_FIRST + 4,

LVM_GETITEMPOSITION = LVM_FIRST + 16,

LVM_GETITEMSTATE = LVM_FIRST + 44,

LVM_GETITEMTEXT = LVM_FIRST + 115,

LVM_GETORIGIN = LVM_FIRST + 41,

LVM_GETSELECTEDCOLUMN = LVM_FIRST + 174,

LVM_GETSELECTEDCOUNT = LVM_FIRST + 50,

LVM_GETTEXTCOLOR = LVM_FIRST + 35,

LVM_GETTILEINFO = LVM_FIRST + 165,

LVM_GETTILEVIEWINFO = LVM_FIRST + 163,

LVM_GETTOOLTIPS = LVM_FIRST + 78,

LVM_GETTOPINDEX = LVM_FIRST + 39,

LVM_GETVIEW = LVM_FIRST + 143,

LVM_INSERTCOLUMN = LVM_FIRST + 97,

LVM_INSERTITEM = LVM_FIRST + 77,

LVM_ISITEMVISIBLE = LVM_FIRST + 182,

LVM_REDRAWITEMS = LVM_FIRST + 21,

LVM_SCROLL = LVM_FIRST + 20,

LVM_SETCOLUMN = LVM_FIRST + 96,

LVM_SETCOLUMNORDERARRAY = LVM_FIRST + 58,

LVM_SETCOLUMNWIDTH = LVM_FIRST + 30,

LVM_SETINFOTIP = LVM_FIRST + 173,

LVM_SETITEM = LVM_FIRST + 76,

LVM_SETITEMINDEXSTATE = LVM_FIRST + 210,

LVM_SETITEMPOSITION = LVM_FIRST + 15,

LVM_SETITEMPOSITION32 = LVM_FIRST + 49,

LVM_SETITEMSTATE = LVM_FIRST + 43,

LVM_SETITEMTEXT = LVM_FIRST + 116,

LVM_SETSELECTEDCOLUMN = LVM_FIRST + 140,

LVM_SETTEXTCOLOR = LVM_FIRST + 36,

LVM_SETTILEINFO = LVM_FIRST + 164,

LVM_SETTILEVIEWINFO = LVM_FIRST + 162,

LVM_SETTOOLTIPS = LVM_FIRST + 74,

LVM_SETVIEW = LVM_FIRST + 142,

LVM_SORTITEMS = LVM_FIRST + 48,

LVM_SORTITEMSEX = LVM_FIRST + 81,

LVM_UPDATE = LVM_FIRST + 42

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

I finally found what I was looking for

; SPECIAL THANKS

; by picaxe

;Needed for these functions to work
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <File.au3>
#include <WindowsConstants.au3>

;http://www.autoitscript.com/forum/topic/93951-listview-sort-method/?hl=pointer+to+sort#entry675233
; by picaxe

; I broke his apart and changed his example into a function called __ArrayDisplaySort
; just pass your 2D array to the function __ArrayDisplaySort

Func __ArrayDisplaySort($aArrayToSort)
    Local $iColumn, $sSortDirection
    Local $iHeight = @DesktopHeight / 1.5, $iWidth = @DesktopWidth / 1.5
    Local $sHeader = ''
    ; create headers for list view
    For $x = 0 To UBound($aArrayToSort, 2) - 2
        ConsoleWrite($x & ' = ' & $aArrayToSort[0][$x] & @CRLF)
        $sHeader &= $aArrayToSort[0][$x] & '|'
    Next
    ;
    #cs
        For $i = 0 To UBound($aArrayToSort, 1) - 1
        For $j = 0 To UBound($aArrayToSort, 2) - 1
        ConsoleWrite("$aArrayToSort[" & $i & "][" & $j & "]:=" & $aArrayToSort[$i][$j] & @LF)
        Next
        ConsoleWrite(@LF)
        Next
    #ce
    ;
    Local $Gui = GUICreate("GCARS", $iWidth + 400, $iHeight + 100)
    ;$hListView = GUICtrlCreateListView("Items|SubItems", 2, 2, 296, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT))
    Local $hListView = GUICtrlCreateListView($sHeader, 10, 10, $iWidth + 390, $iHeight + 90) ;, 296, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_HEADERDRAGDROP))
    ;
    ; making string to parse
    Local $sArrayToString = ''
    ;_ArrayDisplay($aArrayToSort)
    For $x = 1 To UBound($aArrayToSort) - 1
        $sArrayToString &= $aArrayToSort[$x][0] & '%'
        For $y = 1 To UBound($aArrayToSort, 2) - 1
            If $y = UBound($aArrayToSort, 2) - 1 Then
                $sArrayToString &= $aArrayToSort[$x][$y] & '|'
            Else
                If $y <> UBound($aArrayToSort, 2) Then
                    $sArrayToString &= $aArrayToSort[$x][$y] & '%'
                EndIf
            EndIf
        Next
        ;MsgBox('','',$sArrayToString)
    Next

    Local $aFile = StringSplit($sArrayToString, "|")
    Local $iSize = $aFile[0]

    For $x = 1 To $iSize
        Local $aCol = StringSplit($aFile[$x], "%")
        Local $iIndex = _GUICtrlListView_AddItem($hListView, $aCol[1], -1, $x);_GUICtrlListView_GetItemCount($hListView))
        For $y = 2 To $aCol[0]
            _GUICtrlListView_AddSubItem($hListView, $iIndex, $aCol[$y], $y - 1)
        Next
    Next

    GUISetState()

    _GUICtrlListView_RegisterSortCallBack($hListView)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $hListView
                ; use modified sort callback
                __GUICtrlListView_SortItems($hListView, GUICtrlGetState($hListView), GUICtrlRead($iColumn))
                ConsoleWrite("Column: " & $iColumn & "  Sort: " & $sSortDirection & @LF)
        EndSwitch
    WEnd
    _GUICtrlListView_UnRegisterSortCallBack($hListView)
    GUIDelete()
EndFunc   ;==>__ArrayDisplaySort

; modified sort call back from include GuiListView.au3
Func __GUICtrlListView_SortItems($hWnd, $iCol, $iColumn)
    Local $iResult, $iIndex, $pFunction, $hHeader, $iFormat

    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)

    For $x = 1 To $aListViewSortInfo[0][0]
        If $hWnd = $aListViewSortInfo[$x][1] Then
            $iIndex = $x
            ExitLoop
        EndIf
    Next

    $pFunction = DllCallbackGetPtr($aListViewSortInfo[$iIndex][2]) ; get pointer to call back
    $aListViewSortInfo[$iIndex][3] = $iCol ; $nColumn = column clicked
    $aListViewSortInfo[$iIndex][7] = 0 ; $bSet
    $aListViewSortInfo[$iIndex][4] = $aListViewSortInfo[$iIndex][6] ; nCurCol = $nCol
    $iResult = _SendMessage($hWnd, $LVM_SORTITEMS, $hWnd, $pFunction, 0, "hwnd", "ptr")
    If $iResult <> 0 Then
        If $aListViewSortInfo[$iIndex][9] Then ; Use arrow in header
            $hHeader = $aListViewSortInfo[$iIndex][10]
            For $x = 0 To _GUICtrlHeader_GetItemCount($hHeader) - 1
                $iFormat = _GUICtrlHeader_GetItemFormat($hHeader, $x)
                If BitAND($iFormat, $HDF_SORTDOWN) Then
                    _GUICtrlHeader_SetItemFormat($hHeader, $x, BitXOR($iFormat, $HDF_SORTDOWN))
                ElseIf BitAND($iFormat, $HDF_SORTUP) Then
                    _GUICtrlHeader_SetItemFormat($hHeader, $x, BitXOR($iFormat, $HDF_SORTUP))
                EndIf
            Next
            $iFormat = _GUICtrlHeader_GetItemFormat($hHeader, $iCol)
            If $aListViewSortInfo[$iIndex][5] = 1 Then ; ascending
                _GUICtrlHeader_SetItemFormat($hHeader, $iCol, BitOR($iFormat, $HDF_SORTUP))
                $iColumn = $iCol
                Local $sSortDirection = "Ascending"
            Else ; descending
                _GUICtrlHeader_SetItemFormat($hHeader, $iCol, BitOR($iFormat, $HDF_SORTDOWN))
                $iColumn = $iCol
                Local $sSortDirection = "Descending"
            EndIf
        EndIf
    EndIf

    Return $iResult <> 0

EndFunc   ;==>__GUICtrlListView_SortItems

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

I do have another question about the code I pasted, with the use of GUICtrlCreateListView() - is there anyway to make the columns wider? If not, is there a work around?


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

I do have another question about the code I pasted, with the use of GUICtrlCreateListView() - is there anyway to make the columns wider? If not, is there a work around?

You can use _GUICtrlListView_SetColumnWidth to set the column width after it has been created, but there's nothing in the create function that allows it.

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!

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

Share this post


Link to post
Share on other sites

Thank you so much, will look into it.


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

OK, found that command and having some trouble working it into my code...but will get there, while I am doing that, was wondering if anyone would like to help with my follow up questions

Also have a follow up questions:

1. How do you make the listview so that you can copy row/rows? I think I might be able to use the code from the original _ArrayDisplay()?

2. How do you get rid of items that are blank with in the header of the list view - meaning the last index is all blank


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

The only way to get rid of the whitespace at the right side of the listview window is either make the listview narrower or the columns, with data in them, wider. It's a Windows thing, look at Windows Explorer's right hand window for an example of it.


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!

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

Share this post


Link to post
Share on other sites

Sorry for not explaining, there is an extra index - at the end so one row that is blank, I have tried _arraydelete() but have had no luck


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

Post a reproducer script that demonstrates the problem, otherwise I'm guessing.


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!

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

Share this post


Link to post
Share on other sites

If you click on any header, you will see that you get a blank space as the first index. I am wondering how to get rid of it. I have tried to use _arraydelete($namedArray, ubound($namedArray)) and it does not work. Also you can click the row after the numbers and you will see it highlight, but none of rows that are blank do that.

; I broke his apart and changed his example into a function called __ArrayDisplaySort
; just pass your 2D array to the function __ArrayDisplaySort

Local $anArray[3][3] = [['1', 2, 3], ['2', 3, 4], ['3', 4, 5]]
Global $sHeader  = ''

;For $x = 0 To UBound($anArray) -1
;$sHeader &= $anArray[0][0]
;EndIf

__ArrayDisplaySort($anArray)

Func __ArrayDisplaySort($aArrayToSort)
    Local $iColumn, $sSortDirection
    Local $iHeight = @DesktopHeight / 1.5, $iWidth = @DesktopWidth / 1.5
    Local $sHeader = ''
    ; create headers for list view
    For $x = 0 To UBound($aArrayToSort, 2) - 1
        ConsoleWrite($x & ' = ' & $aArrayToSort[$x][0] & @CRLF)
        $sHeader &= 'Header ' & $aArrayToSort[$x][0] & '|'
    Next
    ;
    #cs
        For $i = 0 To UBound($aArrayToSort, 1) - 1
        For $j = 0 To UBound($aArrayToSort, 2) - 1
        ConsoleWrite("$aArrayToSort[" & $i & "][" & $j & "]:=" & $aArrayToSort[$i][$j] & @LF)
        Next
        ConsoleWrite(@LF)
        Next
    #ce
    ;
    Local $Gui = GUICreate("GCARS", $iWidth + 400, $iHeight + 100)
    ;$hListView = GUICtrlCreateListView("Items|SubItems", 2, 2, 296, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT))
    Local $hListView = GUICtrlCreateListView($sHeader, 10, 10, $iWidth + 390, $iHeight + 90) ;, 296, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_HEADERDRAGDROP))
    ;
    ; making string to parse
    Local $sArrayToString = ''
    ;_ArrayDisplay($aArrayToSort)
    For $x = 1 To UBound($aArrayToSort) - 1
        $sArrayToString &= $aArrayToSort[$x][0] & '%'
        For $y = 1 To UBound($aArrayToSort, 2) - 1
            If $y = UBound($aArrayToSort, 2) - 1 Then
                $sArrayToString &= $aArrayToSort[$x][$y] & '|'
            Else
                If $y <> UBound($aArrayToSort, 2) Then
                    $sArrayToString &= $aArrayToSort[$x][$y] & '%'
                EndIf
            EndIf
        Next
        ;MsgBox('','',$sArrayToString)
    Next

    Local $aFile = StringSplit($sArrayToString, "|")
    Local $iSize = $aFile[0]

    For $x = 1 To $iSize
        Local $aCol = StringSplit($aFile[$x], "%")
        ;_GUICtrlListView_SetColumnWidth
        Local $iIndex = _GUICtrlListView_AddItem($hListView, $aCol[1], -1, $x);_GUICtrlListView_GetItemCount($hListView))
        For $y = 2 To $aCol[0]
            _GUICtrlListView_AddSubItem($hListView, $iIndex, $aCol[$y], $y - 1)
        Next
    Next

    GUISetState()

    _GUICtrlListView_RegisterSortCallBack($hListView)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $hListView
                ; use modified sort callback
                __GUICtrlListView_SortItems($hListView, GUICtrlGetState($hListView), GUICtrlRead($iColumn))
                ConsoleWrite("Column: " & $iColumn & "  Sort: " & $sSortDirection & @LF)
        EndSwitch
    WEnd
    _GUICtrlListView_UnRegisterSortCallBack($hListView)
    GUIDelete()
EndFunc   ;==>__ArrayDisplaySort

; modified sort call back from include GuiListView.au3
Func __GUICtrlListView_SortItems($hWnd, $iCol, $iColumn)
    Local $iResult, $iIndex, $pFunction, $hHeader, $iFormat

    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)

    For $x = 1 To $aListViewSortInfo[0][0]
        If $hWnd = $aListViewSortInfo[$x][1] Then
            $iIndex = $x
            ExitLoop
        EndIf
    Next

    $pFunction = DllCallbackGetPtr($aListViewSortInfo[$iIndex][2]) ; get pointer to call back
    $aListViewSortInfo[$iIndex][3] = $iCol ; $nColumn = column clicked
    $aListViewSortInfo[$iIndex][7] = 0 ; $bSet
    $aListViewSortInfo[$iIndex][4] = $aListViewSortInfo[$iIndex][6] ; nCurCol = $nCol
    $iResult = _SendMessage($hWnd, $LVM_SORTITEMS, $hWnd, $pFunction, 0, "hwnd", "ptr")
    If $iResult <> 0 Then
        If $aListViewSortInfo[$iIndex][9] Then ; Use arrow in header
            $hHeader = $aListViewSortInfo[$iIndex][10]
            For $x = 0 To _GUICtrlHeader_GetItemCount($hHeader) - 1
                $iFormat = _GUICtrlHeader_GetItemFormat($hHeader, $x)
                If BitAND($iFormat, $HDF_SORTDOWN) Then
                    _GUICtrlHeader_SetItemFormat($hHeader, $x, BitXOR($iFormat, $HDF_SORTDOWN))
                ElseIf BitAND($iFormat, $HDF_SORTUP) Then
                    _GUICtrlHeader_SetItemFormat($hHeader, $x, BitXOR($iFormat, $HDF_SORTUP))
                EndIf
            Next
            $iFormat = _GUICtrlHeader_GetItemFormat($hHeader, $iCol)
            If $aListViewSortInfo[$iIndex][5] = 1 Then ; ascending
                _GUICtrlHeader_SetItemFormat($hHeader, $iCol, BitOR($iFormat, $HDF_SORTUP))
                $iColumn = $iCol
                Local $sSortDirection = "Ascending"
            Else ; descending
                _GUICtrlHeader_SetItemFormat($hHeader, $iCol, BitOR($iFormat, $HDF_SORTDOWN))
                $iColumn = $iCol
                Local $sSortDirection = "Descending"
            EndIf
        EndIf
    EndIf

    Return $iResult <> 0

EndFunc   ;==>__GUICtrlListView_SortItems

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

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