Jump to content

GUIListViewEx - Deprecated Version


Melba23
 Share

Recommended Posts

  • Moderators

mjolnirmarkiv,

The UDF only supports input and combo controls - but there is no reason why it should not be adapted to support date controls as well. :)

And _GUIListViewEx_EditProcess is indeed where you will have to do a lot of work, but do not forget that you will also need to change _GUIListViewEx_Init to determine whether a date control is to be displayed. ;)

Good luck - and do not hesitate to let me know if you need any help. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

  • Moderators

[bUGFIX VERSION] - 11 Dec 13

Fixed: If you dragged items between ListViews and dropped them on blank space the transfer could fail. Thanks to OldCodger for finding the problem. :thumbsup:

New UDF in the first post. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

  • 4 weeks later...

found bug

tried downloading latest au3 from zip and same thing still happens

when in edit mode (by double click)

clicking outside my gui, gui crashes giving me following message in console:

C:Program FilesAutoIt3IncludeGUIListViewEx.au3 (2012) : ==> Subscript used with non-Array variable.:
If $aCInfo[4] <> $cGLVEx_EditID Then
If $aCInfo^ ERROR

when i comment out both entries from GUIListViewEx.au3

;~                  If $aCInfo[4] <> $cGLVEx_EditID Then
;~                      If $fClick_Move Then
;~                          $iKey_Code = 0x02 ; Confirm edit and end process
;~                      Else
;~                          $iKey_Code = 0x01 ; Abandon editing
;~                      EndIf
;~                      ExitLoop
;~                  EndIf
;~          If $aCInfo[4] <> $cGLVEx_EditID Then
;~              $iKey_Code = 0x01
;~              ExitLoop
;~          EndIf

crash doesnt happen.

do i need to attach any files maybe?

BTW im using windows xp sp2 but same thing happens on win 7

Edited by dickjones007
Link to comment
Share on other sites

  • Moderators

dickjones007,

I do not get that error when clicking outside of the GUI - please post a reproducer script so I can see exactly what you are doing. :huh:

 

downloading latest au3 from zip

Which version are you now running? The latest release is 3.3.10.3 and the latest Beta is 3.3.11.1. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

from HELP-->ABOUT

SciTE
Version 3.3.0
    Mar 30 2013 17:50:01

attached two custom includes and main script in RAR

when script is ran click on button "Dodaj u tablicu" which adds an entry into listview below.

then double click to edit any item/subitem in added line

then when in edit mode, click outside GUI

i hope i was detailed enough

twister evidencija.rar

Link to comment
Share on other sites

Not SciTE version, AutoIt version. Don't you know the difference?

MsgBox(4096, '', @AutoItVersion)

Run that please.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_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: 22/04/2018

Link to comment
Share on other sites

  • Moderators

dickjones007,

I see the problem now - looking into it. :)

M23

Edit: Fixed - thanks for the report. Look out for a new version later this evening. :)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

  • Moderators

[bUGFIX VERSION] - 4 Jan 14

Fixed: If you were editing an item and clicked outside the GUI the UDF crashed. Thanks to dickjones007 for finding the problem. :thumbsup:

New UDF in the first post. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

didnt look in all 8 pages of this thread so pardon me if it has been asked.

is it possible in edit mode to keep the entered value without pressing ENTER?

for example if i double click to edit an item and then click somewhere else, without confirming entered value with ENTER, then that value is lost

Link to comment
Share on other sites

  • Moderators

dickjones007,

I sometimes wonder why I bother writing comprehensive function headers: :whistle:

; #FUNCTION# =========================================================================================================
; Name...........: _GUIListViewEx_EditOnClick


;                  Once item edit process started, all other script activity is suspended until following occurs:
;                      {ENTER}  = Current edit confirmed and editing process ended
;                      {ESCAPE} = Current or all edits cancelled and editing process ended
;                      If using Edit control:
;                          If $iEditMode non-zero then {TAB} and arrow keys = Current edit confirmed & continue editing
;                          Click outside edit = Editing process ends and
;                              If $iAdded + 4 : Current edit accepted
;                              Else :           Current edit cancelled
So as you can see you need to add 4 to $iAdded and then the edit will be accepted when you click outside the edit itself. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

>_<

srry, but to tell you the truth it was the last thing on my mind to look for help in the UDF itself. but now im thinking differently :)

right now im in the process of writing help file for my finished app and honestly i ask my self the same question. is it worth the trouble?

Link to comment
Share on other sites

  • Moderators

dickjones007,

 

honestly i ask my self the same question. is it worth the trouble?

In my opinion: most definitely yes. If nothing else it focusses your mind on how the code is to be used. Quite often I have altered the way I was going to implement a feature because I found it too difficult to explain simply in the function header how it was to be invoked. After all if you cannot explain it, how will the user ever understand how to use it? So I would suggest you write as good a help file as you can. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

  • Moderators

dickjones007,

Adding 4 to $iAdded only affects the behaviour of the editable ListView items - not the header. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

Hi Melba

Thanks again for this great include.

I think I have found a few small issues (but more likely am using it incorrectly), viz:

Firstly, when I define a listbox, then set column widths using _GUICtrlListView_SetColumnWidth, if I then load data into the listbox using firstly _GUIListViewEx_Insert and then _GUIListViewEx_ReadToArray to feed it back into the on screen listbox, the column widths that were previously set are not honoured.  This can be overcome by resetting the column widths after the _GUIListViewEx_ReadToArray.

Secondly, the listbox sorting mechanism does not seem to take listview subitems into account.  For example, I am using _GUICtrlListView_AddSubItem to add icons into my listview, but when sorting the listview the icons do not move.  This is probably a limitation rather than a bug, but I wonder if it can be fixed (or you can tell me what to do to make it work.

Lastly, I am using the following line to create the listbox:

$lvMain = GUICtrlCreateListView("# |CRM ID   |Name/Description    |BU   |Defect #|PO Number|Provider Ref |Provider    |Rdy|Att|Notes",8, 200, 950, 396, BitOr($LVS_SORTASCENDING,$LVS_SINGLESEL),BitOR($LVS_EX_FULLROWSELECT,$LVS_EX_DOUBLEBUFFER, $LVS_EX_SUBITEMIMAGES))

If I add a $LVS_EX_BORDERSELECT into the last BitOR (i.e. Listview Extended Styles), I get the following error from your include:

C:Program Files (x86)AutoIt3IncludeGUIListViewEx.au3 (166) : ==> Array variable subscript badly formatted.:

Local $aLVSortState[_GUICtrlListView_GetColumnCount($hLV)]

Thanks again.

Link to comment
Share on other sites

  • Moderators

Clark,

No idea about the column widths changing. I will look into it based on your description but how about providing me with some code that shows the problem so that I can see what is happening.

The icon problem does not surprise me - there is no provision in the UDF for reordering icons as there is for checkboxes. I will take a look at how it might be added, but I make no promises about adding such a functionality.

I have always found it best to set the extended ListView styles via the _GUICtrlListView_SetExtendedListViewStyle function. Several of the $LVS_EX_### styles share numeric values with $WS_EX_### extended window styles (an MS decision and nothing to do with AutoIt) which can produce unwanted results as the API will apply the $WS_EX_### style in preference to the desired $LVS_EX_### one. Try using the function to set the extended styles and see if that resolves the problem - if not then post some code which shows the error so I can try to determine why it is happening.

I know it appears that I do not believe that there are problems by asking you to provide reproducer code, but unless I can see exactly what you are doing with the ListView control it is almost impossible for me to write a script that approaches your actual code. ListViews are complicated beasts and there are far too many ways to do things and create difficulties for the UDF unless I can follow some actual code that misbehaves and do some proper debugging. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

  • Moderators

Clark,

Does this demonstrate the "column width" problem? Insert a few rows into the left ListView and then press the swap button:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include "GUIListViewEx.au3"

Global $iCount_Left = 0, $iCount_Right = 0

; Create GUI
$hGUI = GUICreate("Test", 640, 510)

; Create Left ListView
$cListView_Left = GUICtrlCreateListView("Tom|Dick|Harry", 10, 40, 300, 300, $LVS_SHOWSELALWAYS)
_GUICtrlListView_SetExtendedListViewStyle($cListView_Left, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($cListView_Left, 0, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 1, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 2, 93)

; Initiate LVEx
$iLV_Left_Index = _GUIListViewEx_Init($cListView_Left)

; Create Right ListView
$cListView_Right = GUICtrlCreateListView("Peter|Paul|Mary", 430, 40, 200, 300, $LVS_SHOWSELALWAYS)
_GUICtrlListView_SetExtendedListViewStyle($cListView_Right, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($cListView_Right, 0, 20)
_GUICtrlListView_SetColumnWidth($cListView_Right, 1, 20)
_GUICtrlListView_SetColumnWidth($cListView_Right, 2, 20)

; Initiate LVEx
$iLV_Right_Index = _GUIListViewEx_Init($cListView_Right)

; Create buttons
$cInsert_L_Button = GUICtrlCreateButton("Insert Left", 10, 350, 200, 30)
$cInsert_R_Button = GUICtrlCreateButton("Insert Right", 10, 390, 200, 30)
$cSwap_Button = GUICtrlCreateButton("Swap", 10, 430, 200, 30)
$cExit_Button = GUICtrlCreateButton("Exit", 430, 390, 200, 110)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cExit_Button
            Exit
        Case $cInsert_L_Button
            _GUIListViewEx_SetActive($iLV_Left_Index)
            _GUIListViewEx_Insert("Item 0" & $iCount_Left & "|SubItem 1" & $iCount_Left & "|SubItem 2" & $iCount_Left)
            $iCount_Left += 1
        Case $cInsert_R_Button
            _GUIListViewEx_SetActive($iLV_Right_Index)
            GUICtrlCreateListViewItem("Bidule 0" & $iCount_Right & "|SubBidule 1" & $iCount_Right & "|SubBidule 2" & $iCount_Right, $cListView_Right)
            $iCount_Right += 1
        Case $cSwap_Button
            $aArray_Return = _GUIListViewEx_ReturnArray($iLV_Left_Index)
            _GUIListViewEx_SetActive($iLV_Right_Index)
            For $i = 0 To UBound($aArray_Return) - 1
                _GUIListViewEx_Insert($aArray_Return[$i])
            Next
    EndSwitch
WEnd
Then run the script again and insert some rows into the right ListView - this does not use the UDF at all and shows the same behaviour. So I blame Windows and not my UDF. :D

I will look at how I might get around this problem (and the icon sorting) this afternoon. :)

M23

Edit:

And the same thing does not happen with UDF-created ListViews:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include "GUIListViewEx.au3"

Global $iCount_Left = 0, $iCount_Right = 0

; Create GUI
$hGUI = GUICreate("Test", 640, 510)

; Create Left ListView
$cListView_Left = GUICtrlCreateListView("Tom|Dick|Harry", 10, 40, 300, 300, $LVS_SHOWSELALWAYS)
_GUICtrlListView_SetExtendedListViewStyle($cListView_Left, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($cListView_Left, 0, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 1, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 2, 93)

; Initiate LVEx
$iLV_Left_Index = _GUIListViewEx_Init($cListView_Left)

; Create Right ListView
$hListView_Right = _GUICtrlListView_Create($hGUI, "", 430, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($hListView_Right, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_AddColumn($hListView_Right, "Peter", 20)
_GUICtrlListView_AddColumn($hListView_Right, "Paul", 20)
_GUICtrlListView_AddColumn($hListView_Right, "Mary", 20)

; Initiate LVEx
$iLV_Right_Index = _GUIListViewEx_Init($hListView_Right)

; Create buttons
$cInsert_L_Button = GUICtrlCreateButton("Insert Left", 10, 350, 200, 30)
$cInsert_R_Button = GUICtrlCreateButton("Insert Right", 10, 390, 200, 30)
$cSwap_Button = GUICtrlCreateButton("Swap", 10, 430, 200, 30)
$cExit_Button = GUICtrlCreateButton("Exit", 430, 390, 200, 110)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cExit_Button
            Exit
        Case $cInsert_L_Button
            _GUIListViewEx_SetActive($iLV_Left_Index)
            _GUIListViewEx_Insert("Item 0" & $iCount_Left & "|SubItem 1" & $iCount_Left & "|SubItem 2" & $iCount_Left)
            $iCount_Left += 1
        Case $cInsert_R_Button
            _GUIListViewEx_SetActive($iLV_Right_Index)

            $iIndex = _GUICtrlListView_AddItem($hListView_Right, "Bidule 0" & $iCount_Right)
            _GUICtrlListView_AddSubItem ( $hListView_Right, $iIndex, "SubBidule 1" & $iCount_Right, 1)
            _GUICtrlListView_AddSubItem ( $hListView_Right, $iIndex, "SubBidule 2" & $iCount_Right, 2)
            $iCount_Right += 1
        Case $cSwap_Button
            $aArray_Return = _GUIListViewEx_ReturnArray($iLV_Left_Index)
            _GUIListViewEx_SetActive($iLV_Right_Index)
            For $i = 0 To UBound($aArray_Return) - 1
                _GUIListViewEx_Insert($aArray_Return[$i])
            Next
    EndSwitch
WEnd
Another thing to think about. :) Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

  • Moderators

Clark,

Here is a modified _GUIListViewEx_Insert_Mod function which optionally retains the column widths in native ListViews after data insertion. Add the function at the end of this script to yours and then use it with the extra parameter when you call it as shown by the <<<<<<< line:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include "GUIListViewEx.au3"

Global $iCount_Left = 0, $iCount_Right = 0

; Create GUI
$hGUI = GUICreate("Test", 640, 510)

; Create Left ListView
$cListView_Left = GUICtrlCreateListView("Tom|Dick|Harry", 10, 40, 300, 300, $LVS_SHOWSELALWAYS)
_GUICtrlListView_SetExtendedListViewStyle($cListView_Left, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($cListView_Left, 0, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 1, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 2, 93)

; Initiate LVEx
$iLV_Left_Index = _GUIListViewEx_Init($cListView_Left)

; Create Right ListView
$cListView_Right = GUICtrlCreateListView("Peter|Paul|Mary", 430, 40, 200, 300, $LVS_SHOWSELALWAYS)
_GUICtrlListView_SetExtendedListViewStyle($cListView_Right, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($cListView_Right, 0, 20)
_GUICtrlListView_SetColumnWidth($cListView_Right, 1, 20)
_GUICtrlListView_SetColumnWidth($cListView_Right, 2, 20)

; Initiate LVEx
$iLV_Right_Index = _GUIListViewEx_Init($cListView_Right)

; Create buttons
$cInsert_L_Button = GUICtrlCreateButton("Insert Left", 10, 350, 200, 30)
$cInsert_R_Button = GUICtrlCreateButton("Insert Right", 10, 390, 200, 30)
$cSwap_Button = GUICtrlCreateButton("Swap", 10, 430, 200, 30)
$cExit_Button = GUICtrlCreateButton("Exit", 430, 390, 200, 110)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cExit_Button
            Exit
        Case $cInsert_L_Button
            _GUIListViewEx_SetActive($iLV_Left_Index)
            _GUIListViewEx_Insert("Item 0" & $iCount_Left & "|SubItem 1" & $iCount_Left & "|SubItem 2" & $iCount_Left)
            $iCount_Left += 1
        Case $cInsert_R_Button
            _GUIListViewEx_SetActive($iLV_Right_Index)
            GUICtrlCreateListViewItem("Bidule 0" & $iCount_Right & "|SubBidule 1" & $iCount_Right & "|SubBidule 2" & $iCount_Right, $cListView_Right)
            $iCount_Right += 1
        Case $cSwap_Button
            $aArray_Return = _GUIListViewEx_ReturnArray($iLV_Left_Index)
            _GUIListViewEx_SetActive($iLV_Right_Index)
            For $i = 0 To UBound($aArray_Return) - 1
                _GUIListViewEx_Insert_Mod($aArray_Return[$i], 1) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Next
    EndSwitch
WEnd

Func _GUIListViewEx_Insert_Mod($vData, $fRetainWidth = 0)

    Local $vInsert

    ; Set data for active ListView
    Local $iArray_Index = $aGLVEx_Data[0][1]
    ; If no ListView active then return
    If $iArray_Index = 0 Then Return SetError(1, 0, "")

    ; Load active ListView details
    $hGLVEx_SrcHandle = $aGLVEx_Data[$iArray_Index][0]
    $cGLVEx_SrcID = $aGLVEx_Data[$iArray_Index][1]

    ; Copy array for manipulation
    $aGLVEx_SrcArray = $aGLVEx_Data[$iArray_Index][2]

    ; Create Local array for checkboxes (if no checkboxes makes no difference)
    Local $aCheck_Array[UBound($aGLVEx_SrcArray)]
    For $i = 1 To UBound($aCheck_Array) - 1
        $aCheck_Array[$i] = _GUICtrlListView_GetItemChecked($hGLVEx_SrcHandle, $i - 1)
    Next

    ; Get selected item in ListView
    Local $iIndex = _GUICtrlListView_GetSelectedIndices($hGLVEx_SrcHandle)

    Local $iInsert_Index = $iIndex
    ; If no selection
    If $iIndex = "" Then $iInsert_Index = -1
    ; Check for multiple selections
    If StringInStr($iIndex, "|") Then
        Local $aIndex = StringSplit($iIndex, "|")
        ; Use first selection
        $iIndex = $aIndex[1]
        ; Cancel all other selections
        For $i = 2 To $aIndex[0]
            _GUICtrlListView_SetItemSelected($hGLVEx_SrcHandle, $aIndex[$i], False)
        Next
    EndIf

    Local $aCol_Width, $iColCount
    ; If width retain required and native ListView
    If $fRetainWidth And $cGLVEx_SrcID Then
        $iColCount = _GUICtrlListView_GetColumnCount($hGLVEx_SrcHandle)
        ; Store column widths
        Local $aCol_Width[$iColCount]
        For $i = 1 To $iColCount - 1
            $aCol_Width[$i] = _GUICtrlListView_GetColumnWidth($hGLVEx_SrcHandle, $i)
        Next
    EndIf

    ; If empty array insert at 0
    If $aGLVEx_SrcArray[0][0] = 0 Then $iInsert_Index = 0
    ; Get data into array format for insert
    If IsArray($vData) Then
        $vInsert = $vData
    Else
        Local $aData = StringSplit($vData, "|")
        Switch $aData[0]
            Case 1
                $vInsert = $aData[1]
            Case Else
                Local $vInsert[$aData[0]]
                For $i = 0 To $aData[0] - 1
                    $vInsert[$i] = $aData[$i + 1]
                Next
        EndSwitch
    EndIf
    ; Increase count
    $aGLVEx_SrcArray[0][0] += 1

    ; Insert data into arrays
    If $iIndex = "" Then
        _GUIListViewEx_Array_Add($aGLVEx_SrcArray, $vInsert)
        _GUIListViewEx_Array_Add($aCheck_Array, False)
    Else
        _GUIListViewEx_Array_Insert($aGLVEx_SrcArray, $iInsert_Index + 2, $vInsert)
        _GUIListViewEx_Array_Insert($aCheck_Array, $iInsert_Index + 2, False)
    EndIf

    ; Rewrite ListView
    _GUIListViewEx_ReWriteLV($hGLVEx_SrcHandle, $cGLVEx_SrcID, $aGLVEx_SrcArray, $aCheck_Array, $iArray_Index)

    ; Set highlight
    If $iIndex = "" Then
        _GUIListViewEx_Highlight($hGLVEx_SrcHandle, $cGLVEx_SrcID, _GUICtrlListView_GetItemCount($hGLVEx_SrcHandle) - 1)
    Else
        _GUIListViewEx_Highlight($hGLVEx_SrcHandle, $cGLVEx_SrcID, $iInsert_Index + 1)
    EndIf

    ; Restore column widths if required
    If $fRetainWidth And $cGLVEx_SrcID Then
        For $i = 1 To $iColCount - 1
            $aCol_Width[$i] = _GUICtrlListView_SetColumnWidth($hGLVEx_SrcHandle, $i, $aCol_Width[$i])
        Next
    EndIf

    ; Store amended array
    $aGLVEx_Data[$iArray_Index][2] = $aGLVEx_SrcArray
    ; Delete copied array
    $aGLVEx_SrcArray = 0
    ; Return amended array
    Return _GUIListViewEx_ReturnArray($iArray_Index)

EndFunc   ;==>_GUIListViewEx_Insert_Mod
You can see that inserting data without the UDF still expands the subitem columns. I am undecided as to whether this is a bug - it seems to me that either all columns should be expanded on none of them so the current behaviour is less than perfect. :wacko:

I hope this solves your problem and that I have not been chasing a red herring all morning! :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...