Jump to content

GUIListViewEx - Deprecated Version


Melba23
 Share

Recommended Posts

Hi Melba

You make good points.

I was perhaps a bit myopic since the only "editable" column in my application is a 2-element read-only combo!

I think you would understand my request better if you saw my application. If you're interested, let me know whether your environment is 32 or 64 bit I'll send you an EXE in a ~week (going out of town; no coding :)

Link to comment
Share on other sites

I know i must be missing something somewhere but  say i have this Save button

Case $cSave_Button
$aLV_List_Right = _GUIListViewEx_ReturnArray($iLV_Right_Index)


For $i = 0 To UBound($aLV_List_Right) - 1
   $aSplit = StringSplit($aLV_List_Right[$i], "|")
   $test = "video '" & $aSplit[1]  & "'"
   ConsoleWrite($test & @CRLF)
Next

how do i see if no files were selected so i can add a popup saying no files  etc?

Link to comment
Share on other sites

  • Moderators

jrsofsd,

I understand your request perfectly - I am just not prepared, for the reasons I gave above, to add this functionality to the UDF.

dynamitemedia,

The UDF tracks the content of the ListView, not the selection status. If you have checkboxes then the _GUIListViewEx_ReturnArray function can return the overall state of these when you set the $iCheck parameter. If you want to know which rows have been selected, then you need to use the _GUICtrlListView_GetSelectedIndices function in the standard GuiListView UDF.

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...

First time poster so feel feel to correct me if I don't get it quite right.

I am creating a listview based on the results of an SQL Query and then allowing the user to change the data by entering the new data into a set of input boxes that match the Query results. All of input boxes are read when the last input box has been entered and then the lisview is updated using the _GUIListViewEx_ChangeItem () function from Melba's UDF. 

Everything works however I would like to be able to stop the entire listview from repainting after the listview data has been changed. It isn't noticable until the listview contains a large number of items. I suspect I am overlooking something simple but haven't found anything to steer me in the right direction.

Thanks!

This is the section of code I used to create the listview. All of it borrowed from examples posted here.

$hListView = GUICtrlCreateListView("", 200, 94, 700, 140,$LVS_SINGLESEL, BitOR($WS_EX_CLIENTEDGE,

$LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES))
$hListView = GUICtrlGetHandle($hListView)
_GUICtrlListView_SetUnicodeFormat($hListView, True)
_GUIListViewEx_MsgRegister()
$iLV_Index = _GUIListViewEx_Init($hListView, "", 0, Default, 0, 2)
_GUIListViewEx_Insert($aSQLQuery)
_GUIListViewEx_SetActive($iLV_Index)
_GUICtrlListView_ClickItem($hListView, 0)

And the code used to change the listview data.

For $j = 1 To UBound ($aColHeader) - 1
_GUIListViewEx_ChangeItem($iLV_Index, GUICtrlRead($ItemNumber) - 1, $j, GUICtrlRead($aInputBoxID[$j]))
Next
_GUICtrlListView_ClickItem($hListView, GUICtrlRead($ItemNumber) - 1)

 

Link to comment
Share on other sites

  • Moderators

OldNoob,

I would like to be able to stop the entire listview from repainting after the listview data has been changed

It is true that the _GUIListViewEx_ChangeItem function forces a complete rewrite of the ListView each time it is called as, in common with most other UDF functions, it first changes the "shadow" array that the UDF uses to track the ListView content and then rewrites the ListView to match the altered array.  So short of rewriting the whole UDF I do not see a quick fix - but the rewrite function is sandwiched between a pair of  _GUICtrlListView_Begin/EndUpdate calls, so there should be no visual flickering. Just how big a ListView are you creating? And what exactly is the problem that you have found?

M23 (OldMod)

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

Melba23,

One of the things I tried was placing my _GUIListViewEx_ChangeItem  between _GUICtrlListView_Begin/EndUpdate but it didn't make a difference for me.

The size of the list is dependent on the array returned from my SQL Query, it can be as many as 500 records or more but typically under 10.

I didn't try to describe it as a problem because it does work, what I see happening when the data is updated is the listview begins to repaint from the first item and then stops at the last item.  It seemed like placing _GUIListViewEx_ChangeItem followed by _GUICtrlListViewClickItem between _GUICtrlListView_Begin/EndUpdate should hide the repainting? 

Link to comment
Share on other sites

  • Moderators

OldNoob,

I have already explained that the internal function rewrites the ListView within a pair of  _GUICtrlListView_Begin/EndUpdate calls, so adding another pair will have no effect.  When I edit a ListView with 500 items, I do see the ListView blank for a few seconds while being rewritten but nothing more.

However, if you see the whole ListView rewriting slowly then I believe you are suffering from a problem I resolved with a rewrite of the _GUICtrlListView_DeleteAllItems function back in Oct 2014 - but which has only just seen the light of day in the latest v3.3.13.20 Beta release. I suggest downloading and installing that to see if the problem is resolved.

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...

Melba23,

I was unable to work on my script for a considerable time but wanted to let you know I was finally able to get that part of it working without the slow re-write of the Listview occurring.

Thanks for your help!

Link to comment
Share on other sites

  • Moderators

OldNoob,

Great news!

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...
  • Moderators

[NEW VERSION] - 10 Jul 15

Added: A new function _GUIListViewEx_DragEvent - this allows the detection of items being dragged by the mouse so that any recalculations of the ListView values can take place..

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

Hia! I've been struggling for hours trying to implement your UDF into my code, and for some reason I just cannot get it to work properly. I'm 100% certain that this is due to my lack of AutoIt knowledge. I'm trying to make my $Main List View editable(that's not a word, is it?), and be able to delete rows, without screwing up my code.

Any chance you could take a look at my code and point me in the right direction? I'm posting the "cleanest" version of my code, without any of the testing I did with your UDF.

 

Any help would be greatly appreciated :)

#include <Array.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <StringConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>
#include <GuiListView.au3>
#include "_XMLDomWrapper.au3"
#include <Excel.au3>
#include <TreeViewConstants.au3>

#Region ### START Koda GUI section ### Form=z:\programutvikling\rekneprogram\utvikling\rekneprogram treeview.kxf
$Rekneprogram = GUICreate("Rekneprogram", 1115, 652, -1, -1)
$Meny = GUICtrlCreateMenu("&Meny")
$LastInn = GUICtrlCreateMenuItem("Last Inn", $Meny)
$Lagre = GUICtrlCreateMenuItem("Lagre", $Meny)
;$LagreSom = GUICtrlCreateMenuItem("Lagre Som" & @TAB & "", $Meny)
$LagreOgAvslutt = GUICtrlCreateMenuItem("Lagre og Avslutt" & @TAB & "", $Meny)
$Avslutt = GUICtrlCreateMenuItem("Avslutt" & @TAB & "", $Meny)
$Verktoy = GUICtrlCreateMenu("&Verktøy")
$Arbeidsomrade = GUICtrlCreateMenu("&Arbeidsområde")
$Vegg = GUICtrlCreateMenu("Vegg", $Arbeidsomrade)
$Innervegg = GUICtrlCreateMenuItem("Innervegg" & @TAB & "", $Vegg)
$Yttervegg = GUICtrlCreateMenuItem("Yttervegg" & @TAB & "", $Vegg)
$Tak = GUICtrlCreateMenuItem("Tak" & @TAB & "Ctrl+Alt+F17", $Arbeidsomrade)
$Golv = GUICtrlCreateMenuItem("Golv" & @TAB & "", $Arbeidsomrade)
$Ymse = GUICtrlCreateMenuItem("Ymse" & @TAB & "", $Arbeidsomrade)
$Arbeid = GUICtrlCreateMenuItem("Arbeid" & @TAB & "Ctrl+Alt+F17", $Arbeidsomrade)
$Test = GUICtrlCreateMenuItem("Test" & @TAB & "CAPSLOCK", $Arbeidsomrade)
$Tillegg = GUICtrlCreateMenu("&Tillegg")
$Hjelp = GUICtrlCreateMenu("&Hjelp")
$Pic1 = GUICtrlCreatePic("", 1, 0, 1112, 81, BitOR($GUI_SS_DEFAULT_PIC, $SS_SUNKEN, $WS_BORDER))
$SearchButtonVaregruppe = GUICtrlCreateButton("Søk", 40, 112, 75, 25)
$SearchButton = GUICtrlCreateButton("Søk", 1000, 112, 75, 25)

$Copyright = GUICtrlCreateLabel("Copyright Mjømen og Berge Byggverksemd AS | All Rights Reserved", 0, 614, 1113, 17)

;Summeringslinje
$TotalPris = GUICtrlCreateLabel("Total Pris:", 925, 58, 67, 17)
GUICtrlSetFont(-1, 11, 800, 0, "Goudy Old Style")
$TotalPrisSum = GUICtrlCreateLabel("", 992, 58, 100, 17)
GUICtrlSetFont(-1, 11, 800, 0, "Goudy Old Style")
$Arbeidstimer = GUICtrlCreateLabel("Arbeidstimer:", 483, 59, 88, 17)
GUICtrlSetFont(-1, 11, 800, 0, "Goudy Old Style")
$ArbeidstimerSum = GUICtrlCreateLabel("", 571, 59, 100, 17)
GUICtrlSetFont(-1, 11, 800, 0, "Goudy Old Style")
$Bedriftskostnad = GUICtrlCreateLabel("Bedriftskostnad:", 249, 59, 104, 17)
GUICtrlSetFont(-1, 11, 800, 0, "Goudy Old Style")
$BedriftskostnadSum = GUICtrlCreateLabel("", 353, 59, 100, 17)
GUICtrlSetFont(-1, 11, 800, 0, "Goudy Old Style")
$Prosjektnamn = GUICtrlCreateLabel("Prosjektnamn:", 13, 59, 95, 17)
GUICtrlSetFont(-1, 11, 800, 0, "Goudy Old Style")
$TotalInntekt = GUICtrlCreateLabel("Total Forteneste:", 685, 59, 108, 17)
GUICtrlSetFont(-1, 11, 800, 0, "Goudy Old Style")
$TotalInntektSum = GUICtrlCreateLabel("", 793, 59, 100, 17)
GUICtrlSetFont(-1, 11, 800, 0, "Goudy Old Style")
$SearchInput = GUICtrlCreateInput("", 952, 88, 161, 21)

; Main ListView
$Main = GUICtrlCreateListView("", 168, 90, 778, 500)
_GUICtrlListView_InsertColumn($Main, 0, "Arbeidsområde", 100)
_GUICtrlListView_InsertColumn($Main, 1, "Varenamn", 200)
_GUICtrlListView_InsertColumn($Main, 2, "Innpris", 100)
_GUICtrlListView_InsertColumn($Main, 3, "Utpris", 100)
_GUICtrlListView_InsertColumn($Main, 4, "Rabatt", 50)
_GUICtrlListView_InsertColumn($Main, 5, "Arbeidstimer", 80)
_GUICtrlListView_InsertColumn($Main, 6, "Mengde", 143)
; /Main ListView

;Høgre ListView
$HogreVerktoy = GUICtrlCreateListView("Varenamn", 951, 142, 161, 448)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 158)
GUICtrlSetFont(-1, 8, 400, 0, "Times New Roman")
; /Høgre ListView

; Varegrupper ListView
$Varegrupper = GUICtrlCreateListView("Varegruppe", 0, 142, 162, 448, BitOR($GUI_SS_DEFAULT_LISTVIEW, $WS_BORDER))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 158)
GUICtrlSetFont(-1, 8, 400, 0, "Times New Roman")
$SearchInputVaregruppe = GUICtrlCreateInput("", 0, 88, 161, 21)
Dim $Rekneprogram_AccelTable[3][2] = [["^!{F17}", $Tak], ["^!{F17}", $Arbeid], ["{CAPSLOCK}", $Test]]
GUISetAccelerators($Rekneprogram_AccelTable)
; /Varegrupper ListView


GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")


$ExcelFilePathButikk = @ScriptDir & "\Databaser\Varer.xlsx"

; Create application object and open an example workbook
Local $oAppl = _Excel_Open()
If @error Then Exit MsgBox(0, "", "Error creating the Excel application object.")
Local $oWorkbook = _Excel_BookOpen($oAppl, $ExcelFilePathButikk)
If @error Then
    MsgBox(0, "", "Error opening workbook")
    _Excel_Close($oAppl)
    Exit
EndIf

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $LastInn
            $sFileOpenDialog = FileOpenDialog("Velg fil", @ScriptDir & "\Mal", "Text Dokument (*.txt)")
            If @error Then
                ; Display the error message.
                MsgBox($MB_SYSTEMMODAL, "", "Ingen fil lagra")
            Else
                ; Retrieve the filename from the filepath e.g. Example.au3.
                Local $sFileName = StringTrimLeft($sFileOpenDialog, StringInStr($sFileOpenDialog, "\", $STR_NOCASESENSE, -1))

                ; Check if the extension .au3 is appended to the end of the filename.
                Local $iExtension = StringInStr($sFileName, ".", $STR_NOCASESENSE)

                ; If a period (dot) is found then check whether or not the extension is equal to .au3.
                If $iExtension Then
                    ; If the extension isn't etqual to .au3 then append to the end of the filepath.
                    If Not (StringTrimLeft($sFileName, $iExtension - 1) = ".txt") Then $sFileOpenDialog &= ".txt"
                Else
                    ; If no period (dot) was found then append to the end of the file.
                    $sFileOpenDialog &= ".txt"
                EndIf
            EndIf
            _GUICtrlListView_DeleteAllItems($Main)
            _GUICtrlListView_OpenText($Main, $sFileOpenDialog)


        Case $Lagre
            $sFileSaveDialog = FileSaveDialog("Velg filnamn", @ScriptDir & "\Mal", "Text Dokument (*txt)")
            If @error Then
                ; Display the error message.
                MsgBox($MB_SYSTEMMODAL, "", "Ingen fil lagra")
            Else
                ; Retrieve the filename from the filepath e.g. Example.au3.
                Local $sFileName = StringTrimLeft($sFileSaveDialog, StringInStr($sFileSaveDialog, "\", $STR_NOCASESENSE, -1))

                ; Check if the extension .au3 is appended to the end of the filename.
                Local $iExtension = StringInStr($sFileName, ".", $STR_NOCASESENSE)

                ; If a period (dot) is found then check whether or not the extension is equal to .au3.
                If $iExtension Then
                    ; If the extension isn't etqual to .au3 then append to the end of the filepath.
                    If Not (StringTrimLeft($sFileName, $iExtension - 1) = ".txt") Then $sFileSaveDialog &= ".txt"
                Else
                    ; If no period (dot) was found then append to the end of the file.
                    $sFileSaveDialog &= ".txt"
                EndIf
            EndIf

            _GUICtrlListView_SaveTxt($Main, $sFileSaveDialog)




        Case $Avslutt
            Exit


        Case $SearchButton
            _GUICtrlListView_DeleteAllItems($HogreVerktoy)
            $SearchInput2 = GUICtrlRead($SearchInput)
            _ArrayDisplay(_ExcelSearchVare($ExcelFilePathButikk, $SearchInput2))

        Case $SearchButtonVaregruppe
            _GUICtrlListView_DeleteAllItems($Varegrupper)
            $SearchInputVaregruppe2 = GUICtrlRead($SearchInputVaregruppe)
            _ArrayDisplay(_ExcelSearchVaregruppe($ExcelFilePathButikk, $SearchInputVaregruppe2))


    EndSwitch
WEnd


Func _ExcelSearchVare($ExcelFilePathButikk, $SearchInput2)

    $count = 0

    Local $aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("B:C"))
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Error", "Feil ved innlasting av Excel ark." & @CRLF & "@error = " & @error & ", @extended = " & @extended)


    For $i = 0 To UBound($aResult) - 1 ; loop though array
        If StringInStr($aResult[$i][0], $SearchInput2) Then
            ;$aResult[$i][0] = $SearchInput2 Then ==> This would be an exact search
            _GUICtrlListView_AddItem($HogreVerktoy, $aResult[$i][0])

            $count = 1
        EndIf
    Next

    If $count = 0 Then MsgBox(0, '', "Ingen treff på '" & $SearchInput2 & "'")


EndFunc   ;==>_ExcelSearchVare

Func _ExcelSearchVaregruppe($ExcelFilePathButikk, $SearchInputVaregruppe2)

    $count = 0

    Local $aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:C"))
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Error", "Feil ved innlasting av Excel ark." & @CRLF & "@error = " & @error & ", @extended = " & @extended)


    For $i = 0 To UBound($aResult) - 1 ; loop though array
        If StringInStr($aResult[$i][0], $SearchInputVaregruppe2) Then
            ;$aResult[$i][0] = $SearchInput2 Then ==> This would be an exact search
            _GUICtrlListView_AddItem($Varegrupper, $aResult[$i][2])

            $count = 1
        EndIf
    Next

    If $count = 0 Then MsgBox(0, '', "Ingen treff på '" & $SearchInputVaregruppe2 & "'")



EndFunc   ;==>_ExcelSearchVaregruppe

;Func _XMLSearch($File, $SearchInput2)
;
;
;   Local $aArray
;   Local $count = 0
;   _FileReadToArray($File, $aArray)
;
;   For $i = 0 To UBound($aArray) - 1
;       If StringInStr($aArray[$i], $SearchInput2) Then
;
;           _GUICtrlListView_AddItem($HogreVerktoy, StringTrimRight(StringTrimLeft(StringStripWS($aArray[$i], 1), 13), 14))
;
;           $count = 1
;       EndIf
;   Next
;
;   If $count = 0 Then MsgBox(0, '', "Ingen treff på '" & $SearchInput2 & "'")
;
;EndFunc   ;==>_XMLSearch


;Copyright © Mjømen og Berge Byggverksemd AS | All rights reserved

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)

    Local $hWndFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $HogreVerktoy
    If Not IsHWnd($HogreVerktoy) Then $hWndListView = GUICtrlGetHandle($HogreVerktoy)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $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
                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)

                    $Index = DllStructGetData($tInfo, "Index")

                    $subitemNR = DllStructGetData($tInfo, "SubItem")


                    ; make sure user clicks on the listview & only the activate
                    ;If $Index <> -1 Then

                    ; col1 ITem index
                    $item = StringSplit(_GUICtrlListView_GetItemTextString($HogreVerktoy, $Index), '|')
                    $item = $item[1]

                    Local $aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:H"))
                    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Error", "Feil ved innlasting av Excel ark." & @CRLF & "@error = " & @error & ", @extended = " & @extended)


                    $RowNumber = _GUICtrlListView_GetItemCount($Main)
                    For $i = 0 To UBound($aResult) - 1 ; loop though array
                        ;If StringInStr($aResult[$i][2], $item) Then
                        If $aResult[$i][1] = $item Then ;==> This would be an exact search
                            ;_GUICtrlListView_AddItem($Main, $aResult[$i][1])
                            _GUICtrlListView_AddItem($Main, $aResult[$i][5])
                            _GUICtrlListView_AddSubItem($Main, $RowNumber, $aResult[$i][1], 1)
                            _GUICtrlListView_AddSubItem($Main, $RowNumber, $aResult[$i][3], 2)
                            ;_GUICtrlListView_AddSubItem($Main, $RowNumber, $aResult[$i][4], 3)
                            _GUICtrlListView_AddSubItem($Main, $RowNumber, $aResult[$i][4], 3)
                            _GUICtrlListView_AddSubItem($Main, $RowNumber, $aResult[$i][6], 5)

                            $PrisEndring = GuiCtrlRead($TotalPrisSum)
                            $TotalInntektEndring = GUICtrlRead($TotalInntektSum)
                            $ArbeidstimerEndring = GUICtrlRead($ArbeidstimerSum)
                            $BedriftskostnadEndring = GUICtrlRead($BedriftskostnadSum)

                            GUICtrlSetData($TotalPrisSum, $PrisEndring + $aResult[$i][4])
                            GUICtrlSetData($TotalInntektSum, $TotalInntektEndring + $aResult[$i][4] - $aResult[$i][3])
                            GUICtrlSetData($ArbeidstimerSum, $ArbeidstimerEndring + $aResult[$i][6])
                            GUICtrlSetData($BedriftskostnadSum, $BedriftskostnadEndring + $aResult[$i][3])


                            $count = 1
                        EndIf
                    Next

                    If $count = 0 Then MsgBox(0, '', "Feil ved lasting av vare. '" & $Index & "'")

            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY



Func _GUICtrlListView_SaveTxt($hListView, $sFilePath, $sDelimiter = '|')
    If $sDelimiter = Default Then
        $sDelimiter = '|'
    EndIf

    Local Const $iColumnCount = _GUICtrlListView_GetColumnCount($hListView) - 1
    Local Const $iItemCount = _GUICtrlListView_GetItemCount($hListView) - 1
    Local $sReturn = ''
    For $i = 0 To $iItemCount
        For $j = 0 To $iColumnCount
            $sReturn &= _GUICtrlListView_GetItemText($hListView, $i, $j)
            If $j < $iColumnCount Then
                $sReturn &= $sDelimiter
            EndIf
        Next
        $sReturn &= @CRLF
    Next

    Local $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE)
    If $hFileOpen = -1 Then
        Return SetError(1, 0, False)
    EndIf
    FileWrite($hFileOpen, $sReturn)
    FileClose($hFileOpen)
    Return True
EndFunc   ;==>_GUICtrlListView_SaveTxt

Func _GUICtrlListView_OpenText($hList, $sFile, $sDeliminator = "|")
    Local $hFile = FileOpen($sFile, $FO_READ)
    If @error Then Return SetError(1, 0, False)

    Local $sRow, $asSubItems, $iIndex
    While 1
        $sRow = FileReadLine($hFile)
        If @error Then ExitLoop

        If $sRow <> "" Then
            $asSubItems = StringSplit($sRow, $sDeliminator)

            $iIndex = _GUICtrlListView_AddItem($hList, $asSubItems[1])

            For $i = 2 To $asSubItems[0]
                _GUICtrlListView_AddSubItem($hList, $iIndex, $asSubItems[$i], $i - 1)
            Next
        EndIf
    WEnd

    Return True
EndFunc   ;==>_GUICtrlListView_OpenText

 

varer.xlsx

Edited by Mrcoconut
Added snippet of database for testing purposes
Link to comment
Share on other sites

  • Moderators

Mrcoconut,

Welcome to the AutoIt forums.

I will certainly take a look, but as I do not have Excel nor speak Norwegian it will take a little time to work out exactly what the script does, so do not hold your breath.

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

Thanks for the warm welcome :)

 

I've managed to work around most of the issues using other methods, so you don't have to spend your time figuring out my problems for me ;)  I'm just a bit sleep deprived and forgot to think about solving the issues using other methods.

Hope I didn't waste too much of your time!

Mrcoconut

varer.xlsx

Edited by Mrcoconut
Typos, tired.
Link to comment
Share on other sites

  • Moderators

Mrcoconut,

I've managed to work around most of the issues using other methods

So I have just completely wasted the past 3 hours trying to understand your script and seeing how to integrate my UDF? Well thanks for nothing - try sleeping before posting next time.

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

Mrcoconut,

No - I was just a bit annoyed last night, but all is forgotten today.

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...
  • Moderators

[NEW VERSION] - 10 Aug 15

Added: A new function _GUIListViewEx_EditWidth to set the width of the edit/combo control when editing. In particular, this allows combo items to be wider than the ListView column.

Added: As items can now be wider then columns, the user can specify that a tooltip appear when a column is clicked to display the full item content. The new functions are _GUIListViewEx_ToolTipInit which defines the column(s) to display a tooltip when clicked and _GUIListViewEx_ToolTipShow which when placed in the idle loop displays the tooltips themselves.

Thanks to bourny for the ideas.

New UDF in the first post - Example 2 shows the new features in action.

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

  • 2 weeks later...

@Melba23, I've got a problem

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

#include "GUIListViewEx.au3"

$hGUI = GUICreate("Test", 400, 400) ; Example 5

; Create ListViews
$cLV_Tom = GUICtrlCreateListView("Tom|U|V", 10, 30, 180, 160)
_GUICtrlListView_SetColumnWidth($cLV_Tom, 0, 100)
$cLV_Dick = GUICtrlCreateListView("Dick|D", 210, 30, 180, 160)
_GUICtrlListView_SetColumnWidth($cLV_Dick, 0, 100)
$cLV_Harry = GUICtrlCreateListView("Harry", 10, 230, 180, 160)
_GUICtrlListView_SetColumnWidth($cLV_Harry, 0, 140)
$cLV_Fred = GUICtrlCreateListView("Fred", 210, 230, 180, 160)
_GUICtrlListView_SetColumnWidth($cLV_Fred, 0, 140)

; Create arrays and fill ListViews
Global $aTom[5], $aDick[5], $aHarry[5], $aFred[5]
For $i = 0 To 4
    $aTom[$i] = "Tom " & $i & "|U" & $i& "|V" & $i
    GUICtrlCreateListViewItem($aTom[$i], $cLV_Tom)
    $aDick[$i] = "Dick " & $i & "|D" & $i
    GUICtrlCreateListViewItem($aDick[$i], $cLV_Dick)
    $aHarry[$i] = "Harry " & $i
    GUICtrlCreateListViewItem($aHarry[$i], $cLV_Harry)
    $aFred[$i] = "Fred " & $i
    GUICtrlCreateListViewItem($aFred[$i], $cLV_Fred)
Next

; Initiate ListViews and set differing external drag/drop states
GUICtrlCreateLabel("Normal", 10, 10, 180, 20)
;$iLV_Tom = _GUIListViewEx_Init($cLV_Tom, $aTom, 0, 0, True) ; External drag & drop - items deleted on drag

$iLV_Tom = _GUIListViewEx_Init($cLV_Tom, $aTom, 0, 0, True, 2, "1") ; <-- my change should edit column "U" on double-click

GUICtrlCreateLabel("No external drag", 210, 10, 180, 20)
$iLV_Dick = _GUIListViewEx_Init($cLV_Dick, $aDick, 0, 0, True, 64) ; No external drag, will accept drop
GUICtrlCreateLabel("No external drop", 10, 210, 180, 20)
$iLV_Harry = _GUIListViewEx_Init($cLV_Harry, $aHarry, 0, 0, True, 128) ; No external drop, will drag to others
GUICtrlCreateLabel("No delete && no drop", 210, 210, 180, 20)
$iLV_Fred = _GUIListViewEx_Init($cLV_Fred, $aFred, 0, 0, True, 128 + 256) ; No external drop, will drag to others - items NOT deleted on drag

GUISetState()

_GUIListViewEx_MsgRegister()

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

on column U I'd like to edit but is not working for me. Can you help me. Thanks

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

  • Moderators

argumentum,

You need to look for the edit by adding the _GUIListViewEx_EditOnClick function in the idle loop:

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    _GUIListViewEx_EditOnClick()
WEnd

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 Melba23,

thanks a lot for that useful UDF! 

Sometimes I am still tapping a bit in the dark, though. Do I understand correctly that if I want to use my own WM_NOTIFY handler the basic setup would be something like this (red is your UDFs):

GUICreate
GUICtrlCreateListView
_GUIListViewEx_ReadToArray
_GUIListViewEx_Init
_GUIListViewEx_MsgRegister()

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState(@SW_SHOW)

LOOP
  GUIGetMsg
        Message Processing
  _GUIListViewEx_EditOnClick
        Simple Edit Processing

ENDLOOP

_GUIListViewEx_Close
GUIDelete
Exit

WM_NOTIFY Handler-Function
   Switch OwnMessages
      Message Processing
   _GUIListViewEx_WM_NOTIFY_Handler (with no further commands following)
ENDFUNCTION

 

My goal is to use your glorious UDF to simply implement Combos and SubItem-Edit-Processing (which already works great). On the other hand I want to use some subitem coloring and all solutions that I have found depend on WM_NOTIFY. So I kind of have to combine these two ways.

Could you please confirm that this is in theory correct? Or do you prefer to read actual code?

Thanks a lot and keep up the great work!

Jan

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...