Jump to content

how to creat this type listview?


Recommended Posts

What you are displaying with that image is an Excel worksheet. It can be re-created using a ListView control but you will not get exactly the same appearance.

Look at the Excel UDF, you may be able to create an embedded Excel object.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

or use this as a start:

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

$Form1 = GUICreate("Form1", 600, 400)
$Obj1 = ObjCreate("OWC10.Spreadsheet.10");this is for office 2k3; for office 2k7 change 10 with 11
With $Obj1
.AllowPropertyToolbox = False
.DisplayOfficeLogo = False
.DisplayToolbar = True
.DisplayTitleBar = True
.TitleBar.Caption = "My Custom List"
.CSVURL = "c:\sps.csv" ;change this to your needs
.ActiveSheet.Activate
EndWith
$Obj1_ctrl = GUICtrlCreateObj($Obj1, 10, 10, 580, 300)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

[EDIT] I have modified to load a csv at start

Edited by taietel
Link to comment
Share on other sites

Now that's a fine piece of work taietel

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Thank you, George!  :mellow: Not only for what you've wrote above, but also for your scripts (I've learned a lot and still do!)

ZwinnyRolnik, For merging cells you should do something like

...

.ActiveSheet.Range("A1", "A2").Merge ;this merge cells A1 and A2

[EDIT] And for changing colours,

.ActiveCell.Font.Color = 0xFF0000
.ActiveCell.Interior.Color = 0x00FF00

[EDIT again] There are a lot of properties/methods in that .dll. When I will have much time (I have 82 pages to write till tomorrow, for my school and... there are a lot of medical terms which slows me down... :P ), I will give more details. 

Edited by taietel
Link to comment
Share on other sites

Thx for answer... but i don't need it in excel(excel udf)... i need it in my listview like:

global $ListView = GUICtrlCreateListView("", 110, 80, $guiw - 220, $guih - 100)
    
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

It's possible to do it with styles or something else in listview udf?

Link to comment
Share on other sites

I'm thinking the answer is no. I don't know of any ListView styles that will give you that appearance.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Even if the answer is NO, I will post here a modified version of a previous post. This is not make use of Excel UDF.

At start is a sample with merged cells, hyperlink etc. Then you can load a CSV file (I've put a button on the form):

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

$Form1 = GUICreate("Form1", 600, 400)
$btn = GUICtrlCreateButton("Load CSV", 500,330,90,40)
$Obj1 = ObjCreate("OWC10.Spreadsheet.10");this is for office XP, 2k3; for office 2k7 change 10 with 11
With $Obj1
;==== This is for Protection ====
#cs
.ActiveSheet.Protection.AllowDeletingColumns = False
.ActiveSheet.Protection.AllowDeletingRows = False
.ActiveSheet.Protection.AllowFiltering = False
.ActiveSheet.Protection.AllowFormattingColumns = False
.ActiveSheet.Protection.AllowFormattingRows = False
.ActiveSheet.Protection.AllowHeadingRename = False
.ActiveSheet.Protection.AllowInsertingColumns = False
.ActiveSheet.Protection.AllowInsertingRows = False
.ActiveSheet.Protection.AllowSorting = True
#ce
.ActiveSheet.Protection.Enabled = False; if you protec, put this at the end (otherwise you can not make any changes!)

.AllowPropertyToolbox = False
.DisplayOfficeLogo = False
.DisplayToolbar = True
.DisplayTitleBar = True

.TitleBar.Caption = "My Custom List"
.TitleBar.Interior.Color = 0xFF0000
.ActiveSheet.Range("A1", "D1").Merge
.Range("A1").Value = "Hyperlink to this post"
.ActiveCell.ColumnWidth = "10"
.ActiveCell.Hyperlink.Address = "http://www.autoitscript.com/forum/index.php?showtopic=115142"
.ActiveCell.Interior.Color = 0xFF0000
.ActiveCell.Font.Color = 0xFFFFFF
.ActiveCell.Font.Bold = "1"
.ActiveCell.Font.Size = "20"
.ActiveCell.Font.Name = "Garamond"
.ActiveCell.Font.Italic = "1"
.ActiveCell.Font.Underline = "1"
.Range("A2", "D2").Interior.Color = 0x00ff00
.Range("A2", "D2").Font.Color = 0x000000
.Range("A2", "D2").Font.Bold = "1"
.Range("A3", "D5").Font.Color = 0x003366
.Range("A3", "D5").Interior.Color = 0xCCFFFF
.Range("A2").Value = "Name"
.Range("B2").Value = "Adress"
.Range("C2").Value = "User"
.Range("D2").Value = "Func SUM(1+1)"
.Range("A3").Value = "oiuoiu"
.Range("B3").Value = "ytrytr"
.Range("C3").Value = "kjhkjh"
.Range("D3").Formula = "=SUM(1+1)"
.Range("D3").Select
.ActiveCell.ColumnWidth = "15"
.Range("A2", "D5").Borders.Value = 1
.ActiveCell(4, 1) = "Sample ExcelObj";this is relative to cell D3
.ActiveCell(5, 1) = "Just for testing";
.ActiveCell(6, -2) = "To load csv: .CSVURL = 'path\sample.csv'"
.EnableEvents = True
.Range("A1").Select
EndWith
$Obj1_ctrl = GUICtrlCreateObj($Obj1, 10, 10, 580, 300)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn
            Local $titluopen = "Choose file..."
            Local $var = FileOpenDialog($titluopen, @ScriptDir & "\", "Text file (*.csv)", 1)
            If @error Then
                MsgBox(48, "Error", "Houston, we have a problem!...")
            Else
                With $Obj1
                    .CSVURL = $var ;enter your path to a csv file
                    .ActiveSheet.Columns.AutoFit ;if the text in the cells is too big
                EndWith
            EndIf
    EndSwitch
WEnd
Edited by taietel
Link to comment
Share on other sites

I can't start it, I think there is a problem with this:

$Form1 = GUICreate("Form1", 600, 400)

$btn = GUICtrlCreateButton("Load CSV", 500,330,90,40)

$Obj1 = ObjCreate("OWC10.Spreadsheet.10");this is for office XP, 2k3; for office 2k7 change 10 with 11

because I have polish version of program.

I don't know what should I set here... This error is shown:

Only Object-type variables allowed in a "With" statement.:

With $Obj1

With ^ ERROR

but thx for Your help :mellow:

Link to comment
Share on other sites

Maybe you do not have installed Office Web Components (it uses OWC10.dll). For Office 2003 you can download from here: http://www.microsoft.com/downloads/detai...f72-97a5-e0fd290d4b76&amp;displaylang=en

Put this after $Obj1 = ...

If Not IsObj($Obj1) Then
    MsgBox(0,"Error", "Can not create object!")
Else
With $Obj1


...........

EndWith
EndIf

I've deleted that accidentally when I modified my code...

Here is a print screen of the list (you can disable the toolbar - see the code):

Posted Image

Edited by taietel
Link to comment
Share on other sites

I don't edit my post because, when I did few minutes ago, all the formatting was disappear! :mellow:

The advantage of using Excel, in your case, is that you can merge cells, just like you've posted in the first place.

Link to comment
Share on other sites

Great example. What a shame I didn't know about this way from the beginning, because I have already a huge listview with many functions and only cell divide is left. I can't join this script with my own listview, can I?

Edited by ZwinnyRolnik
Link to comment
Share on other sites

ZwinnyRolnik,

if you can post part of your code, so we can work with, I'll say we should give it a try!   :mellow:

What a shame I didn't know about this way from the beginning

I didn't knew either!

Edited by taietel
Link to comment
Share on other sites

it's my prog...

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#include <Constants.au3>
#include <FontConstants.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <_EIPListView.au3>

Opt("GUICloseOnESC", 0);turn off exit on esc.







Global $wartosc[100][100]
Global $Checkbox1, $Checkbox2, $HelpContext, $bProgressShowing, $Tab1;,$Status1,$Status2
Global $hFont, $defColLV = 0x000000, $defBkColLV = 0xFFFFFF
load()



Func _Main()
    

    global $guiw = 800
    global $guih = 400
    
    global $deskh = @DesktopHeight - _GetTaskBarHeight()
    global $aWinPos[4] = [(@DesktopWidth - $guiw) / 2, ($deskh - $guih) / 2, 800, 400]
    $Gui = GUICreate("Edit", $aWinPos[2], $aWinPos[3], $aWinPos[1], $aWinPos[0], BitOR($GUI_SS_DEFAULT_GUI, $WS_CLIPSIBLINGS));, 424, 280, 200, 110)
    GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")
    GUISetBkColor(0xCECECE)
    
    
    
    
    
    $tab = GUICtrlCreateTab(110, 60, $guiw - 220, $guih - 80)
    $tab0 = GUICtrlCreateTabItem("Karta")
    
    GUICtrlCreateLabel("Ilość partnerów", 130,100,60,40)
    Global $PL = GUICtrlCreateCombo("0", 200, 102, 100, 40, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "1|2|3", "0") 
    GUICtrlCreateLabel("Koszty poÅ›rednie rozliczane:", 130,150,60,40)
    Global $partn = GUICtrlCreateCombo("RyczaÅ‚towo", 200, 160, 270, 40, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "Na podstawie rzeczywiście poniesionych wydatków", "Ryczałtowo") 
    
    Global $PP = GuiCtrlCreateCheckbox("Pomoc Publiczna", 130, 200, 150, 20)
    
    
    
    
    
    $tab1 = GUICtrlCreateTabItem("Budzet")
    
    
    ;   ======>>> set the type of control for each column <<<======
    ;0= ignore, 1= edit, 2= combo, 4= calendar, 256= use callback.
    Global $LVcolControl[40] = [1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] ;left click actions
    ;0 = ignore, 1= use context callback
    Global $LVcolRControl[40] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ; right click actions

    
    
    global $ListView = GUICtrlCreateListView("", 110, 80, $guiw - 220, $guih - 100)
    
    GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
    $__LISTVIEWCTRL = $ListView
    
    
For $i = 0 To 20
    if $i = 2 Then
        ContinueLoop
    EndIf
    
    _GUICtrlListView_AddColumn($ListView, $wartosc[$i][0], "",2)
    _GUICtrlListView_SetColumnWidth($ListView, $i, 100)
Next
    

    _GUICtrlListView_SetBkColor($ListView, $CLR_MONEYGREEN)
    _GUICtrlListView_SetTextColor($ListView, $CLR_BLACK)
    _GUICtrlListView_SetTextBkColor($ListView, $CLR_MONEYGREEN)

    
    
    
    
    Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($ListView)]
    Global $maxColumn = _GUICtrlListView_GetColumnCount($ListView)
    Global $aIParam[1][$maxColumn+1][5]
    Global $oParamSearch = ObjCreate('Scripting.Dictionary') ; store for faster search (iParam, arrayIndex)
    
    
; itemy
    
    GUICtrlSetOnEvent($__LISTVIEWCTRL, "lvListViewHandler")
    global $cccc
    $cccc = StringTrimRight("L|P|0|1|2|", 1)
    
For $i = 1 To 99
    
     _GUICtrlListView_AddItem($ListView, $wartosc[0][$i])
Next

For $i = 1 To 99
    
    
    For $j = 1 To 10
        if $j = 4 then 
             
            ContinueLoop
        EndIf
        if $j > 4 then 
              _GUICtrlListView_AddSubItem($ListView, $i - 1, $wartosc[$j][$i], $j-1)
            ContinueLoop
        EndIf
    _GUICtrlListView_AddSubItem($ListView, $i - 1, $wartosc[$j][$i], $j)

    Next    
Next    

; przyciski

$usun = GUICtrlCreateButton("Usun", 100, 0, 60, 40)
GUICtrlSetOnEvent($usun, "usuwanie")
$load = GUICtrlCreateButton("load", 170, 0, 60, 40)
GUICtrlSetOnEvent($load, "load")
$dodaj = GUICtrlCreateButton("Dodaj poz", 240, 0, 60, 40)
GUICtrlSetOnEvent($dodaj, "dodaj")
$do = GUICtrlCreateButton("save", 310, 0, 60, 40)
GUICtrlSetOnEvent($do, "save")
$dod = GUICtrlCreateButton("Dodaj Zad", 380, 0, 60, 40)
GUICtrlSetOnEvent($dod, "zadanie")


    
Local $liczebka[99]
Local $rzym[99]

    For $k = 1 to 19
                $liczebka[$k] = IniRead($lokacja2, "section-2", $k, "")
            Next
            For $s = 1 to 19 step 2
                $rzym[$s] = IniRead($lokacja2, "section-1", $s, "")
            Next
            
                    
                    For $f = 1 To 99
                    _GUICtrlListView_SetItemText($listview, $f-1, $f-3)
                    Next
                    
                    for $d = 1 to 19 step 2
                    
                        _GUICtrlListView_SetItemText($listview, $liczebka[$d]-1, $rzym[$d])
                            
                    Next
                    
                    _GUICtrlListView_SetItemText($listview, 0, "-")
                    _GUICtrlListView_SetItemText($listview, 1, "-") 
            $liczebka[0] = IniRead($lokacja2, "section-2", 0, "")   
GUICtrlCreateTabItem("") 




for $d = 0 to 98
    IniWrite(@ScriptDir&"\plik.ini", "section-1", $d, $rzym[$d])
    IniWrite(@ScriptDir&"\plik.ini", "section-2", $d, $liczebka[$d])
Next
        IniWrite(@ScriptDir&"\plik.ini", "section-2", 0, $liczebka[0])

FileSetAttrib(@ScriptDir&"\plik.ini", "+H")                     
    

for $i = 0 to 10
    _guictrllistview_setcolumn($listview, $i, $wartosc[$i][0], 100,2)
    next

$iLV_Width = 17
For $i = 0 To 11
    if $i = 1 Then
        ContinueLoop
    EndIf
    _GUICtrlListView_SetColumnWidth($ListView, $i, $LVSCW_AUTOSIZE_USEHEADER)
    $iHeader_Width = _GUICtrlListView_GetColumnWidth($ListView, $i)
   
    _GUICtrlListView_SetColumnWidth($ListView, $i, $LVSCW_AUTOSIZE)
    $iData_Width = _GUICtrlListView_GetColumnWidth($ListView, $i)
  
    If $iHeader_Width > $iData_Width Then
        _GUICtrlListView_SetColumnWidth($ListView, $i, $iHeader_Width)
        $iLV_Width += $iHeader_Width
    Else
        $iLV_Width += $iData_Width
    EndIf
Next






    GUISetState(@SW_SHOW, $Gui)
    
    
    _InitEditLib ("", "", "", "", $Gui);

    GUICtrlSetData($lvCombo, $cccc)
    

    $bLVEDITondblclick = True
    $bInitiated = True
    $bLVUPDATEonfocusCHANGE = True
    
    
    While 1
    
        _MonitorEditState ($editCtrl, $editFlag, $__LISTVIEWCTRL, $LVINFO);<<<======  add this in your message loop<<<======
        If $bCALLBACK_EVENT = True Then
            $bCALLBACK_EVENT = False
            
            Call($LVCALLBACK, $LVINFO)
        EndIf
        Switch GUIGetMsg()
        Case $usun
            usuwanie()
        Case $load
            load()
        Case $dodaj
            dodaj()
        Case $do
            save()
        Case $dod
            zadanie()
        
            
            Case $PP
            _PP()
            
            Case $tab
            Switch GUICtrlRead($tab)
                Case 0
                    
                Case 1
                   _PL() 
            EndSwitch
        EndSwitch
    WEnd

    
    
    _TermEditLib ();<<<====== add this after your message loop<<<======
EndFunc


Func _PL()

    If GUICtrlRead($PL) = 0 Then
_GUICtrlListView_BeginUpdate($ListView)
        If GUICtrlRead($PP) = 1 Then
                if _GUICtrlListView_GetItemText($listview, 1, 5) = $wartosc[5][2] then
                    _GUICtrlListView_DeleteColumn($listview, 5)
            
                    Global $LVcolControl[40] = [1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] ;left click actions
                    ;0 = ignore, 1= use context callback
                    Global $LVcolRControl[40] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ; right click actions
                EndIf
        Else

                    if _GUICtrlListView_GetItemText($listview, 1, 4) = $wartosc[5][2] then
                    _GUICtrlListView_DeleteColumn($listview, 4)
                        
                    Global $LVcolControl[40] = [1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] ;left click actions
                    ;0 = ignore, 1= use context callback
                    Global $LVcolRControl[40] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ; right click actions
                EndIf
        EndIf       
        for $i = 0 to 10
            _guictrllistview_setcolumn($listview, $i, $wartosc[$i][0], 100,2)
        next

$iLV_Width = 17
For $i = 0 To 11
    if $i = 1 Then
        ContinueLoop
    EndIf
    _GUICtrlListView_SetColumnWidth($ListView, $i, $LVSCW_AUTOSIZE_USEHEADER)
    $iHeader_Width = _GUICtrlListView_GetColumnWidth($ListView, $i)
   
    _GUICtrlListView_SetColumnWidth($ListView, $i, $LVSCW_AUTOSIZE)
    $iData_Width = _GUICtrlListView_GetColumnWidth($ListView, $i)
  
    If $iHeader_Width > $iData_Width Then
        _GUICtrlListView_SetColumnWidth($ListView, $i, $iHeader_Width)
        $iLV_Width += $iHeader_Width
    Else
        $iLV_Width += $iData_Width
    EndIf
Next
            
    Else
        
            
    
    EndIf
_GUICtrlListView_EndUpdate($ListView)
EndFunc



Func _PP()
    _GUICtrlListView_BeginUpdate($ListView)
    If GUICtrlRead($PP) = 1 Then
            For $i = 1 to 1
            _GUICtrlListView_InsertColumn($listview, 4, "")
            For $j = 1 To 99
                _GUICtrlListView_AddSubItem($ListView, $j-1, $wartosc[4][$j], 4)
                
            Next
        Next    
    If _GUICtrlListView_GetItemText($listview, 1, 5) = $wartosc[5][2] or _GUICtrlListView_GetItemText($listview, 1, 4) = $wartosc[5][2] then
        Global $LVcolControl[40] = [1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] ;left click actions
            ;0 = ignore, 1= use context callback
        Global $LVcolRControl[40] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ; right click actions
    Else
        Global $LVcolControl[40] = [1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] ;left click actions
            ;0 = ignore, 1= use context callback
        Global $LVcolRControl[40] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ; right click actions
    EndIf
for $i = 0 to 10
    _guictrllistview_setcolumn($listview, $i, $wartosc[$i][0], 100,2)
    next

$iLV_Width = 17
For $i = 0 To 11
    if $i = 1 Then
        ContinueLoop
    EndIf
    _GUICtrlListView_SetColumnWidth($ListView, $i, $LVSCW_AUTOSIZE_USEHEADER)
    $iHeader_Width = _GUICtrlListView_GetColumnWidth($ListView, $i)
   
    _GUICtrlListView_SetColumnWidth($ListView, $i, $LVSCW_AUTOSIZE)
    $iData_Width = _GUICtrlListView_GetColumnWidth($ListView, $i)
  
    If $iHeader_Width > $iData_Width Then
        _GUICtrlListView_SetColumnWidth($ListView, $i, $iHeader_Width)
        $iLV_Width += $iHeader_Width
    Else
        $iLV_Width += $iData_Width
    EndIf
Next
            
    Else
            _GUICtrlListView_DeleteColumn($listview, 4)
            
    If _GUICtrlListView_GetItemText($listview, 1, 5) = $wartosc[5][2] or _GUICtrlListView_GetItemText($listview, 1, 4) = $wartosc[5][2] then
        Global $LVcolControl[40] = [1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] ;left click actions
            ;0 = ignore, 1= use context callback
        Global $LVcolRControl[40] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ; right click actions
    Else
        Global $LVcolControl[40] = [1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] ;left click actions
            ;0 = ignore, 1= use context callback
        Global $LVcolRControl[40] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        ; right click actions
    EndIf
for $i = 0 to 10
    _guictrllistview_setcolumn($listview, $i, $wartosc[$i][0], 100,2)
    next

$iLV_Width = 17
For $i = 0 To 11
    if $i = 1 Then
        ContinueLoop
    EndIf
    _GUICtrlListView_SetColumnWidth($ListView, $i, $LVSCW_AUTOSIZE_USEHEADER)
    $iHeader_Width = _GUICtrlListView_GetColumnWidth($ListView, $i)
   
    _GUICtrlListView_SetColumnWidth($ListView, $i, $LVSCW_AUTOSIZE)
    $iData_Width = _GUICtrlListView_GetColumnWidth($ListView, $i)
  
    If $iHeader_Width > $iData_Width Then
        _GUICtrlListView_SetColumnWidth($ListView, $i, $iHeader_Width)
        $iLV_Width += $iHeader_Width
    Else
        $iLV_Width += $iData_Width
    EndIf
Next
    EndIf
    _GUICtrlListView_EndUpdate($ListView)
EndFunc







Func zadanie()

Global $GUI1 = GUICreate("Nowe zdanie", 300, 200, -1, -1, "", "", $GUI)
Global $label = GUICtrlCreateLabel("Wstaw zadanie w miejsce zadania: ", 10, 20, 120, 40)
Global $mojecombo = GUICtrlCreateCombo("1", 130, 20, 100, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "2|3|4|5|6|7|8", "I") 
Global $label2 = GUICtrlCreateLabel("z", 40, 70, 10, 40)
Global $pozycje = GUICtrlCreateInput("1", 60, 70, 40, 20)
Global $label2 = GUICtrlCreateLabel("pozycjami", 110, 70, 120, 40)


Global $sss = GUICtrlCreateButton("Dodaj", 20, 120, 60, 40)

Global $ssss = GUICtrlCreateButton("Wyjdz", 220, 120, 60, 40)



GUISetState()
While 1

                Switch GUIGetMsg()
        Case $sss
            dodajzad()
        Case $ssss
            wylaz()
            ExitLoop    
    EndSwitch
                
            Wend    
EndFunc


func dodajzad()
    Local $liczebka[20]
    Local $rzym[20] 
_GUICtrlListView_BeginUpdate($ListView)
    For $i = 1 to 19
                $liczebka[$i] = IniRead(@ScriptDir&"\plik.ini", "section-2", $i, "")
            Next
            $liczebka[0] = IniRead(@ScriptDir&"\plik.ini", "section-2", 0, "")
    $ile = GUICtrlRead($mojecombo)
    $ile2 = GUICtrlRead($pozycje)
    
    Local $iles = $ile + $ile + 1
    $liczebka[0] = $liczebka[0] + 2
    
    For $j = $iles to 19
        
                     IniWrite(@ScriptDir&"\plik.ini", "section-2", $j, $liczebka[$j-2]+$ile2+1)
                     if $j >= $liczebka[0] + 2 Then
                         IniWrite(@ScriptDir&"\plik.ini", "section-2", $j, "")
                     EndIf
                     
                        
                         
    Next
    
    IniWrite(@ScriptDir&"\plik.ini", "section-2", $iles-1, $liczebka[$iles-2]+$ile2)
    IniWrite(@ScriptDir&"\plik.ini", "section-2", 0, $liczebka[0])
    
    
    
    
    
            
            ; wstawienie wiersza
        for $i = $liczebka[$iles-2] to $liczebka[$iles-2] + $ile2
            _GUICtrlListView_InsertItem($listview, "", $i-1)
            For $j = 1 To 40
                _GUICtrlListView_AddSubItem($ListView, $i-1, "", $j)
            Next
        Next    
            
            
            For $i = 1 to 19
                $liczebka[$i] = IniRead(@ScriptDir&"\plik.ini", "section-2", $i, "")
            Next
            For $i = 1 to 19 step 2
                $rzym[$i] = IniRead(@ScriptDir&"\plik.ini", "section-1", $i, "")
            Next
            Local $b = 2
            $liczebka[0] = IniRead(@ScriptDir&"\plik.ini", "section-2", 0, "")  
                    For $f = 1 To 17 step 2
                        For $z = $liczebka[$f] to $liczebka[$f+1]
                    _GUICtrlListView_SetItemText($listview, $z, $z-$b)
                        Next
                        $b = $b + 1
                        if $f = $liczebka[0] Then
                            For $zz = $liczebka[$f+1] to 99
                                _GUICtrlListView_SetItemText($listview, $zz, $zz-6)
                            Next
                            ExitLoop
                        EndIf
                        
                    Next
                    
                    for $i = 1 to 19 step 2
                    
                        _GUICtrlListView_SetItemText($listview, $liczebka[$i]-1, $rzym[$i])
                            
                    Next
                    _GUICtrlListView_SetItemText($listview, 0, "-")
                    _GUICtrlListView_SetItemText($listview, 1, "-") 
            
            _GUICtrlListView_EndUpdate($ListView)
            
    
EndFunc



Func wylaz()
    
    GUIDelete($gui1)
EndFunc


Func dodaj()
Local $liczebka[20]
Local $rzym[20]
            Global $HotItem = _GUICtrlListView_GetSelectedIndices($listview)

            For $i = 1 to 10
                $liczebka[$i] = IniRead(@ScriptDir&"\plik.ini", "section-2", $i, "")
            Next
if $hotitem = 0 or $hotitem = 1 or $hotitem = $liczebka[1]-1 or $hotitem = $liczebka[3]-1 or $hotitem = $liczebka[5]-1 or $hotitem = $liczebka[7]-1 or $hotitem = $liczebka[9]-1 or $hotitem = $liczebka[11]-1 then
    Return
EndIf       
        
        _GUICtrlListView_BeginUpdate($ListView)
            
            ; wstawienie wiersza
            _GUICtrlListView_InsertItem($listview, "", $HotItem)
            For $j = 1 To 40
                _GUICtrlListView_AddSubItem($ListView, $HotItem, "", $j)
            Next
        
            
            $hotitem = $hotitem + 1
            for $i = 1 to 19 step +2
                if $hotitem >= $liczebka[$i] and $hotitem <= $liczebka[$i+1] Then
                    $zadanie = $i
                    
                    
                    
                    For $j = $zadanie+1 to 19
                        if $liczebka[$j] = "" Then
                            ContinueLoop
                        EndIf
                     IniWrite(@ScriptDir&"\plik.ini", "section-2", $j, $liczebka[$j]+1)
                    Next
                    
        For $i = 1 to 19
                $liczebka[$i] = IniRead(@ScriptDir&"\plik.ini", "section-2", $i, "")
            Next
            For $i = 1 to 19 step 2
                $rzym[$i] = IniRead(@ScriptDir&"\plik.ini", "section-1", $i, "")
            Next
            Local $b = 2
            $liczebka[0] = IniRead(@ScriptDir&"\plik.ini", "section-2", 0, "")  
                    For $f = 1 To 17 step 2
                        For $z = $liczebka[$f] to $liczebka[$f+1]
                    _GUICtrlListView_SetItemText($listview, $z, $z-$b)
                        Next
                        $b = $b + 1
                        if $f = $liczebka[0] Then
                            For $zz = $liczebka[$f+1] to 99
                                _GUICtrlListView_SetItemText($listview, $zz, $zz-6)
                            Next
                            ExitLoop
                        EndIf
                        
                    Next
                    
                    for $i = 1 to 19 step 2
                    
                        _GUICtrlListView_SetItemText($listview, $liczebka[$i]-1, $rzym[$i])
                            
                    Next
                    _GUICtrlListView_SetItemText($listview, 0, "-")
                    _GUICtrlListView_SetItemText($listview, 1, "-") 
                    
                    
                    
                    
                    ExitLoop
                EndIf
            Next
    
            _GUICtrlListView_EndUpdate($ListView)
            
        

EndFunc




    
func a()
    ;cii
     Global $lokacja = FileSaveDialog( "Zapisz plik...", @ScriptDir, "Pliki tekstowe (*.ini)|Skrypty (*.aut;*.au3)", 2+16, $czas, $GUI)
        If $lokacja <> 1 Then
            EndIf
        EndFunc
        



func save()
    

        $date = @YEAR & "-" & @MON & "-" & @MDAY
        $godzina = @HOUR & "-" & @MIN & "-" & @SEC
        $czas = $date&"  "&$godzina&".ini"
        
        

For $c = 0 To 10    
            $colu = _guictrllistview_getcolumn($listview, $c)
            IniWrite($lokacja2, "section0", $c, $colu[5])
            
            For $k = 0 To 99
            IniWrite($lokacja2, "section"&$c+1, $k, _GUICtrlListView_GetItemText($listview, $k, $c))
            Next
        Next

Local $liczebka[99]
Local $rzym[99]
For $i = 1 to 98
                $liczebka[$i] = IniRead(@ScriptDir&"\plik.ini", "section-2", $i, "")
Next
            For $i = 1 to 98 step 2
                $rzym[$i] = IniRead(@ScriptDir&"\plik.ini", "section-1", $i, "")
            Next
$liczebka[0] = IniRead(@ScriptDir&"\plik.ini", "section-2", 0, "")


for $d = 1 to 98
    IniWrite($lokacja2, "section-1", $d, $rzym[$d])
    IniWrite($lokacja2, "section-2", $d, $liczebka[$d])
Next
IniWrite($lokacja2, "section-2", 0, $liczebka[0])


EndFunc


    
Func usuwanie()
Local $liczebka[20]
Local $czyjest = False
Local $rzym[20]

        $HotItem = _GUICtrlListView_GetSelectedIndices($listview)
if $hotitem = 0 or $hotitem = 1 then
    Return
EndIf

            For $i = 1 to 19
                $liczebka[$i] = IniRead(@ScriptDir&"\plik.ini", "section-2", $i, "")
            Next
        
            for $i = 1 to 19 step 2
                if $hotitem+1 = $liczebka[$i] Then
                    $tekstt = MsgBox(1,"???","Usunąć caÅ‚e zadanie wraz z jego pozycjami?",$gui)
                
                    $czyjest = True
                If $tekstt = 1 Then 
                    for $j = 1 to 19 step 2
                        if $hotitem+1 = $liczebka[$j] Then
                    
                            
                        _GUICtrlListView_BeginUpdate($ListView)
                        ; nizej usuwanie itemow od wiekszej np 4 do 3
                        for $z = $liczebka[$j+1] to $liczebka[$j] step -1
                    
                            _GUICtrlListView_DeleteItem(GUICtrlGetHandle($ListView), $z-1)
                        Next
                
                $liczebka[0] = IniRead(@ScriptDir&"\plik.ini", "section-2", 0, "")
                    $liczebka[0] = $liczebka[0] - 2
                    ; ustawienie reszty jak ma byc
                    for $i = $j to $liczebka[0] step 2
                    $liczebka[$i+1] = $liczebka[$i] + ( $liczebka[$i+3] - $liczebka[$i+2] )
                    $liczebka[$i+2] = $liczebka[$i+1] + 1
                    
                    if $i = $liczebka[0] Then
                        $liczebka[$i+2] = ""
                    EndIf
                    
                Next
            
                
                    ;to poki co niewazne
                    For $i = $j to $liczebka[0] + 2
                    IniWrite(@ScriptDir&"\plik.ini", "section-2", $i, $liczebka[$i])
                Next
                for $i = $liczebka[0] + 2 to 12
                IniWrite(@ScriptDir&"\plik.ini", "section-2", $i, "")
                next
                
                IniWrite(@ScriptDir&"\plik.ini", "section-2", 0, $liczebka[0])
                
            
                    For $i = 1 to 19
                $liczebka[$i] = IniRead(@ScriptDir&"\plik.ini", "section-2", $i, "")
            Next
            For $i = 1 to 19 step 2
                $rzym[$i] = IniRead(@ScriptDir&"\plik.ini", "section-1", $i, "")
            Next
            Local $b = 2
            $liczebka[0] = IniRead(@ScriptDir&"\plik.ini", "section-2", 0, "")  
                    For $f = 1 To 17 step 2
                        For $z = $liczebka[$f] to $liczebka[$f+1]
                    _GUICtrlListView_SetItemText($listview, $z, $z-$b)
                        Next
                        $b = $b + 1
                        if $f = $liczebka[0] Then
                            For $zz = $liczebka[$f+1] to 99
                                _GUICtrlListView_SetItemText($listview, $zz, $zz-6)
                            Next
                            ExitLoop
                        EndIf
                        
                    Next
                    
                    for $i = 1 to 19 step 2
                    
                        _GUICtrlListView_SetItemText($listview, $liczebka[$i]-1, $rzym[$i])
                            
                    Next
                    _GUICtrlListView_SetItemText($listview, 0, "-")
                    _GUICtrlListView_SetItemText($listview, 1, "-") 
                    _GUICtrlListView_EndUpdate($ListView)
                    
                    
                    ExitLoop
                    
                EndIf
            Next
                
                
                
                
                
                
                ExitLoop
            EndIf
            endif
        Next
        
        if $czyjest = False Then
        
        $tekst = MsgBox(1,"???","Usunąć zaznaczony wiersz","",$gui)
            
            
            If $tekst = 1 Then 
                
                
                
            
                _GUICtrlListView_BeginUpdate($ListView)
            
            
            _GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($ListView))
            $hotitem = $hotitem + 1
            for $i = 1 to 19 step +2
                if $hotitem >= $liczebka[$i] and $hotitem <= $liczebka[$i+1] Then
                    $zadanie = $i
                    
                    
                    
                    For $i = $zadanie+1 to 19
                        if $liczebka[$i] = "" Then
                            ContinueLoop
                        EndIf
                    IniWrite(@ScriptDir&"\plik.ini", "section-2", $i, $liczebka[$i]-1)
                    Next
                    
        For $i = 1 to 19
                $liczebka[$i] = IniRead(@ScriptDir&"\plik.ini", "section-2", $i, "")
            Next
            For $i = 1 to 19 step 2
                $rzym[$i] = IniRead(@ScriptDir&"\plik.ini", "section-1", $i, "")
            Next
            Local $b = 2
            $liczebka[0] = IniRead(@ScriptDir&"\plik.ini", "section-2", 0, "")  
                    For $f = 1 To 17 step 2
                        For $z = $liczebka[$f] to $liczebka[$f+1]
                    _GUICtrlListView_SetItemText($listview, $z, $z-$b)
                        Next
                        $b = $b + 1
                        if $f = $liczebka[0] Then
                            For $zz = $liczebka[$f+1] to 99
                                _GUICtrlListView_SetItemText($listview, $zz, $zz-6)
                            Next
                            ExitLoop
                        EndIf
                        
                    Next
                    
                    for $i = 1 to 19 step 2
                    
                        _GUICtrlListView_SetItemText($listview, $liczebka[$i]-1, $rzym[$i])
                            
                    Next
                    _GUICtrlListView_SetItemText($listview, 0, "-")
                    _GUICtrlListView_SetItemText($listview, 1, "-")                 
                    ExitLoop
                EndIf
            Next
            
    
EndIf

EndIf
_GUICtrlListView_EndUpdate($ListView)
$czyjest = False
EndFunc
    
    
Func load()

Global $lokacja2 = FileOpenDialog("Wczytaj plik...", @ScriptDir, "Pliki tekstowe (*.ini)|Skrypty (*.aut;*.au3)", 1 + 2 + 8, "", $GUI)
        
        If $lokacja2 <> "" Then
            Global $hmm4 = MsgBox(33,"Otworzyć plik...?",$lokacja2,"",$GUI)
            
            If $hmm4 = 1 Then
                For $z = 0 To 90
            
                    $wartosc[$z][0] = IniRead($lokacja2, "section0", $z, "")
            
                For $d = 1 To 99
            
                    $wartosc[$z][$d] = IniRead($lokacja2, "section"&$z+1, $d-1, "")
                Next        
            Next
            
                GUIDelete($gui)
                    _Main()
            EndIf
        EndIf
    
    

        
EndFunc
    
    
    
    
    
    
    
    
    
    
    
Func OnExit()
    save()
    
    if FileExists(@ScriptDir&"\plik.ini") Then
        FileDelete(@ScriptDir&"\plik.ini")
    EndIf
    
    
    
    _TermEditLib ()
    Exit
EndFunc   ;==>OnExit
    
    
Func _GetTaskBarHeight()
    global $oldOpt = Opt("WinTitleMatchMode", 4)
    global $TrayPos = WinGetPos("classname=Shell_TrayWnd")
    Opt("WinTitleMatchMode", $oldOpt)
    Return $TrayPos[3]
EndFunc   ;==>_GetTaskBarHeight

there is include _EIPListView.au3

#include-once
#include <GuiConstantsEx.au3>
#include <GuiListview.au3>
#Include <GuiComboBox.au3>
#Include <GuiListview.au3>
#include <windowsconstants.au3>
#include <editconstants.au3>
#include <datetimeconstants.au3>

;this is a modified version of my original script.  It creates a popup
;window for the control as a child window to workaround issues related to
;listviews on tabs.
;
; ------------------------------------------------------------------------------
;
; AutoIt Version:   3.0
; Language:         English
; Description: Multi-column editable Listview  (EditInPlace)
;                   Stephen Podhajecki <gehossafats at netmdc.com/> Gary Frost <gafrost at charter dot net/>
;                   pdm for control array concept
;                   see http://www.autoitscript.com/forum/index.php?showtopic=42694&st=0&gopid=322551&#entry322551
;==============================================================================
;   ######>>> set the type of control for each column <<<######
;   0 = Input/edit  1 = combobox 2 = date control
;   Global $LVcolControl[4]=[0,0,1,2]
;   _InitEditLib();######>>>  add this after you create your main gui<<<######
;   _MonitorEditState($Gui, $editCtrl, $editFlag, $__LISTVIEWCTRL, $LVINFO, $LVcolControl);######>>>  add this in your message loop<<<######
;   _TermEditLib();######>>>  add this after your message loop when exiting the script<<<######
; $__LISTVIEWCTRL = $ListView1 ######>>> Set this to your ListView control <<<######
;==============================================================================
Global  $DebugIt = 0
;Global Const $WM_NOTIFY = 0x004E
;Global Const $WM_KEYDOWN = 0x0100
;Global Const $WM_COMMAND = 0x0111
Global Const $WM_MOVING = 0x0216
;Global Const $WM_MOVE = 0x0003
;Global Const $WM_KILLFOCUS = 0x0008
;Global Const $WM_SETFOCUS = 0x0007
;Global Const $WM_ACTIVATE = 0x0006
Global Const $WM_CAPTURECHANGED = 0x0215

Global Const $HD_FIRST = -300
;Global Const $HDN_TRACK = ($HDN_FIRST - 8)
;Global Const $HDN_TRACKW = ($HDN_FIRST - 28)

Global Const $LBN_SELCHANGE = 1
Global Const $LBN_DBLCLK = 2
Global Const $LBN_SETFOCUS= 4
Global Const $LBN_KILLFOCUS = 5
;Global Const $EN_SETFOCUS =0x0100  
;Global Const $EN_KILLFOCUS = 0x0200
;Global Const $EN_CHANGE =0x0300
;Global Const $EN_UPDATE =0x0400

Global Const $DT_FIRST = -760
;Global Const $DTN_DATETIMECHANGE = $DTN_FIRST + 1 ; the systemtime has changed
;~ Global Const $DTN_USERSTRINGA = $DTN_FIRST + 2    ; the user has entered a string
Global Const $DTN_WMKEYDOWNA = $DTN_FIRST + 3     ; modify keydown on app format field (X)
;~ Global Const $DTN_FORMATA = $DTN_FIRST + 4        ; query display for app format field (X)
;~ Global Const $DTN_FORMATQUERYA = $DTN_FIRST + 5   ; query formatting info for app format field (X)
;Global Const $DTN_DROPDOWN = $DTN_FIRST + 6       ; MonthCal has dropped down
;Global Const $DTN_CLOSEUP = $DTN_FIRST + 7        ; MonthCal is popping up
;Global Const $CBN_SELCHANGE         = 1;
;Global Const $CBN_DBLCLK            = 2;
;Global Const $CBN_SETFOCUS            = 3;
;Global Const $CBN_KILLFOCUS         = 4;
;Global Const $CBN_EDITCHANGE         = 5;
;Global Const $CBN_EDITUPDATE         = 6;
;Global Const $CBN_DROPDOWN            = 7;
;Global Const $CBN_CLOSEUP            = 8;
;Global Const $CBN_SELENDOK            = 9;
;Global Const $CBN_SELENDCANCEL         = 10;
  

;Global Const $NM_FIRST = 0
;Global Const $NM_CLICK   = ($NM_FIRST - 2)
;Global Const $NM_DBLCLK  = ($NM_FIRST - 3)
;Global Const $NM_RCLICK  = ($NM_FIRST - 5)
;Global Const $NM_RDBLCLK = ($NM_FIRST - 6)
;Global Const $NM_SETFOCUS = ($NM_FIRST - 7)
;Global Const $NM_KILLFOCUS = ($NM_FIRST - 8)

;Global Const $LVS_SHAREIMAGELISTS = 0x0040

;~ Global Const $LVM_FIRST = 0x1000
;~ Global Const $LVM_SETIMAGELIST = ($LVM_FIRST + 3)
;~ Global Const $LVM_GETITEM = ($LVM_FIRST + 5)
;~ Global Const $LVM_SETITEM = ($LVM_FIRST + 6)
;~ Global Const $LVM_GETNEXTITEM = ($LVM_FIRST + 12)
;~ Global Const $LVM_ENSUREVISIBLE = ($LVM_FIRST + 19)
;~ Global Const $LVM_SETITEMSTATE = ($LVM_FIRST + 43)
;Global Const $LVN_FIRST = -100

;Global Const $LVN_ENDLABELEDITA = (-106)
;Global Const $LVN_ITEMCHANGING = ($LVN_FIRST - 0)
;Global Const $LVN_ITEMCHANGED = ($LVN_FIRST - 1)
;Global Const $LVN_INSERTITEM = ($LVN_FIRST - 2)
;Global Const $LVN_DELETEITEM = ($LVN_FIRST - 3)
;Global Const $LVN_DELETEALLITEMS = ($LVN_FIRST - 4)

;Global Const $LVN_COLUMNCLICK = ($LVN_FIRST - 8)
;Global Const $LVN_BEGINDRAG = ($LVN_FIRST - 9)
;Global Const $LVN_BEGINRDRAG = ($LVN_FIRST - 11)

;Global Const $LVN_ODCACHEHINT = ($LVN_FIRST - 13)    
;Global Const $LVN_ITEMACTIVATE = ($LVN_FIRST - 14)
;Global Const $LVN_ODSTATECHANGED = ($LVN_FIRST - 15)

;Global Const $LVN_HOTTRACK = ($LVN_FIRST - 21)

;Global Const $LVN_KEYDOWN = ($LVN_FIRST - 55)
;Global Const $LVN_MARQUEEBEGIN = ($LVN_FIRST - 56)   

Global Const $GUILOSTFOCUS = -1
Global $LVCALLBACK = "_CancelEdit"  ; default to cancel edit 
Global $LVCONTEXT = "_CancelEdit"  ; defalut to cancel edit
Global $bCALLBACK = False ;a call-back has been executed.
Global $bCALLBACK_EVENT = False
Global $bLVUPDATEonfocusCHANGE = 1 ;save editing if another cell is clicked
Global $bLVDBLCLICK = False;
Global $bLVITEMCHECKED = False;
Global $bLVEDITondblclick = False ;Must dblclick to edit
Global $bDATECHANGED = False;
Global $bPROGRESSSHOWING =False;
Global $bInitiated = False
Global $LVCHECKEDCNT = 0;
Global $old_col
Global $__LISTVIEWCTRL = -999
Global $Gui, $editFlag
Global $bCanceled = False
Global $editHwnd ;= the Hwnd of the editing control.
Global $editCtrl ;= the CtrlId of the editing control.
;;array dim to number of cols, value of each element determines control.
Global $LVcolControl[1] = [0]  ;0= ignore, 1= edit, 2= combo, 4= calendar, 8 = list, 256 use callback.
Global $LVcolRControl[1] = [0] ;0= ignore, 256 = context callback.
Global $lvControlGui , $lvEdit, $lvCombo, $lvDate , $lvList
Global $LVINFO[11];
Opt("GUICloseOnESC", 0);turn off exit on esc.
;===============================================================================
; Function Name:    _InitEditLib
; Description:      Create the editing controls and registers WM_NOTIFY handler.
; Parameter(s):
; Requirement(s):
; Return Value(s):
; User CallTip:
; Author(s):
; Note(s):      Call this BEFORE you create your listview.
;===============================================================================
Func _InitEditLib($lvEditStart="",$lvComboStart="",$lvDataStart="",$lvListStart="",$hParent=0)
    _TermEditLib()
    $lvControlGui = GuiCreate("LVCONTROL",0,0,1,1,$WS_POPUP,-1,$hParent)
    $lvEdit = GUICtrlCreateInput($lvEditStart, 0, 0, 1, 1, BitOR($ES_AUTOHSCROLL, $ES_NOHIDESEL, $WS_BORDER), 0)
    GUICtrlSetState($lvEdit, $GUI_HIDE)
    GuiCtrlSetFont($lvEdit,8.5)
    $lvCombo = GUICtrlCreateCombo($lvComboStart, 0, 0, 1, 1,-1,$WS_EX_TOPMOST)
    GUICtrlSetState($lvCombo, $GUI_HIDE)
    $lvDate = GUICtrlCreateDate($lvDataStart,0, 0, 1, 1,BitOR($GUI_SS_DEFAULT_DATE, $DTS_SHORTDATEFORMAT),BitOr($WS_EX_CLIENTEDGE,$WS_EX_TOPMOST ))
    GUICtrlSetState($lvDate, $GUI_HIDE)
    $lvList = GUICtrlCreateList($lvListStart, 0, 0, 1, 1,-1,$WS_EX_TOPMOST)
    GUICtrlSetState($lvList, $GUI_HIDE)
    GuiSetState(@SW_SHOW)
    GUIRegisterMsg($WM_ACTIVATE,"WM_ACTIVATE")
    GUIRegisterMsg($WM_MOVE,"WM_MOVE_EVENT") 
    GUIRegisterMsg( $WM_MOVING,"WM_Notify_Events")
    GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
    GUIRegisterMsg($WM_COMMAND,"WM_Command_Events")
EndFunc   ;==>_InitEditLib
;===============================================================================
; Function Name:    _TermEditLib
; Description:      Deletes the editing controls and un-registers WM_NOTIFY handler.
; Parameter(s):
; Requirement(s):
; Return Value(s):
; User CallTip:
; Author(s):
; Note(s):      Call this when close your gui if switching to another gui.
;===============================================================================
Func _TermEditLib()
    GUICtrlDelete($lvEdit)
    GUICtrlDelete($lvCombo)
    GUICtrlDelete($lvDate)
    GuiCtrlDelete($lvList)
    GUIRegisterMsg($WM_ACTIVATE,"")
    GUIRegisterMsg($WM_MOVE,"")
    GUIRegisterMsg($WM_MOVING,"")
    GUIRegisterMsg($WM_NOTIFY, "")
    GUIRegisterMsg($WM_COMMAND,"")
EndFunc   ;==>_TermEditLib
;===============================================================================
; Function Name:    ListView_Click
; Description:  Called from WN_NOTIFY event handler.
; Parameter(s):
; Requirement(s):
; Return Value(s):
; User CallTip:
; Author(s):        Stephen Podhajecki <gehossafats at netmdc.com/>
; Note(s):
;===============================================================================
Func _ListView_Click()
ConsoleWrite(_DebugHeader("_ListView_Click"))
ConsoleWrite("$editFlag="&$editFlag&@lf)
ConsoleWrite("$bLVUPDATEonfocusCHANGE = "&$bLVUPDATEonfocusCHANGE &@LF)
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then
        If $DebugIt Then ConsoleWrite(_DebugHeader("_ListView_Click"))
    EndIf
    ;----------------------------------------------------------------------------------------------
    If $editFlag = 1 Then
        If $bLVUPDATEonfocusCHANGE = True Then
                If $editCtrl = $lvDate Then
                    If $bDATECHANGED = False Then 
                        _CancelEdit()
                        Return
                    EndIf
                EndIf
                _LVUpdate($editCtrl, $__LISTVIEWCTRL, $LVINFO[6], $LVINFO[7])
                    
    $iLV_Width = 17
For $i = $LVINFO[7] To $LVINFO[7]
    if $i = 1 Then
        ContinueLoop
    EndIf
    
    _GUICtrlListView_SetColumnWidth($ListView, $i, $LVSCW_AUTOSIZE_USEHEADER)
    $iHeader_Width = _GUICtrlListView_GetColumnWidth($ListView, $i)
   
    _GUICtrlListView_SetColumnWidth($ListView, $i, $LVSCW_AUTOSIZE)
    $iData_Width = _GUICtrlListView_GetColumnWidth($ListView, $i)
  
    If $iHeader_Width > $iData_Width Then
        _GUICtrlListView_SetColumnWidth($ListView, $i, $iHeader_Width)
    EndIf
Next
        Else
                _CancelEdit()
            EndIf
    Else
        If $bLVEDITondblclick = False Then
            sleep(10)
            _InitEdit($LVINFO, $LVcolControl)
        EndIf
    EndIf
EndFunc   ;==>ListView_Click
;===============================================================================
; Function Name:    ListView_RClick
; Description:  Called from WN_NOTIFY event handler.
; Parameter(s):
; Requirement(s):
; Return Value(s):
; User CallTip:
; Author(s):        Stephen Podhajecki <gehossafats at netmdc.com/>
; Note(s):
;===============================================================================
Func _ListView_RClick()
    If $editFlag = 1 Then
        Return 0
    Else
        If $LVINFO[0] < 0 Or $LVINFO[1] < 0 Then Return 0
        If $LVcolRControl[$LVINFO[1]] = 256 Then Call($LVCONTEXT,$LVINFO) ;call context call back function.
        _CancelEdit()
    EndIf
    ToolTip("")
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then ConsoleWrite(_DebugHeader("$NM_RCLICK"))
    ;----------------------------------------------------------------------------------------------
EndFunc   ;==>ListView_RClick
;===============================================================================
; Function Name:    ListView_DoubleClick
; Description:  Called from WN_NOTIFY event handler.
; Parameter(s):
; Requirement(s):
; Return Value(s):
; User CallTip:
; Author(s):
; Note(s):          Initiates the edit process on a DblClick
;===============================================================================
Func _ListView_DoubleClick()
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then ConsoleWrite(_DebugHeader("$NM_DBLCLICK"))
    ;----------------------------------------------------------------------------------------------
    If $editFlag = 0 Then
        _InitEdit($LVINFO, $LVcolControl)
    Else
        _CancelEdit()
    EndIf
EndFunc   ;==>ListView_DoubleClick
; WM_NOTIFY event handler
;===============================================================================
; Function Name:    _MonitorEditState
; Description:      Handles {enter} {esc} and {f2}
; Parameter(s): $h_gui          - IN/OUT -
;                       $editCtrl       - IN/OUT -
;                       $editFlag       - IN/OUT -
;                       $__LISTVIEWCTRL - IN/OUT -
;                       $LVINFO         - IN/OUT -
;                       $LVcolControl   - IN -
; Requirement(s):
; Return Value(s):
; User CallTip:
; Author(s):
; Note(s):
;===============================================================================
Func _MonitorEditState(ByRef $editCtrl, ByRef $editFlag, ByRef $__LISTVIEWCTRL, ByRef $LVINFO)
    Local $pressed = _vKeyCheck()
    If $editFlag And $pressed = 13 Then; pressed enter
        _LVUpdate($editCtrl, $__LISTVIEWCTRL, $LVINFO[0], $LVINFO[1])
        
    $iLV_Width = 17
For $i = $LVINFO[1] To $LVINFO[1]
    if $i = 1 Then
        ContinueLoop
    EndIf
    _GUICtrlListView_SetColumnWidth($ListView, $i, $LVSCW_AUTOSIZE_USEHEADER)
    $iHeader_Width = _GUICtrlListView_GetColumnWidth($ListView, $i)
   
    _GUICtrlListView_SetColumnWidth($ListView, $i, $LVSCW_AUTOSIZE)
    $iData_Width = _GUICtrlListView_GetColumnWidth($ListView, $i)
  
    If $iHeader_Width > $iData_Width Then
        _GUICtrlListView_SetColumnWidth($ListView, $i, $iHeader_Width)
    EndIf
Next
    ElseIf $editFlag And $pressed = 27 Then; pressed esc
        _CancelEdit()
    ElseIf Not $editFlag And $pressed = 113 Then; pressed f2
        MouseClick("primary") ;workaround work all the time (if mouse is over the control)
        MouseClick("primary")
    EndIf
EndFunc   ;==>_MonitorEditState
Func Enter()
    ; just a dummy function
EndFunc   ;==>Enter
;===============================================================================
; Function Name:    _LVUpdate
; Description:      Put the new data in the Listview
; Parameter(s): $editCtrl        - IN/OUT -
;                       $__LISTVIEWCTRL  - IN/OUT -
;                       $iRow                - IN -
;                       $iCol                - IN -
;
; Requirement(s):
; Return Value(s):
; User CallTip:
; Author(s):
; Note(s):
;===============================================================================
Func _LVUpdate(ByRef $editCtrl, ByRef $__LISTVIEWCTRL, $iRow, $iCol)
    If $DebugIt Then ConsoleWrite("_LVUpdate>>"&@LF)
    if $bCanceled then Return
    Local $newText = GUICtrlRead($editCtrl)
    If $editCtrl = $lvList or $editCtrl = $lvCombo Then
        If $newText <> "" Then
        _GUICtrlListView_SetItemText($__LISTVIEWCTRL, $iRow, $newText, $iCol)
        EndIf
    Else
        _GUICtrlListView_SetItemText($__LISTVIEWCTRL, $iRow, $newText, $iCol)
    EndIf
    $LVINFO[6] = $iRow
    $LVINFO[7] = $iCol
    _CancelEdit()
EndFunc   ;==>_LVUpdate
;===============================================================================
; Function Name:    _GUICtrlListViewGetSubItemRect
; Description:   Get the bounding rect of a listview item
; Parameter(s): $h_listview - IN -
;                       $row            - IN -
;                       $col            - IN -
;                       $aRect      - IN/OUT -
;
; Requirement(s):
; Return Value(s):
; User CallTip:
; Author(s):
; Note(s):
;===============================================================================
Func _GUICtrlListViewGetSubItemRect($h_listview, $row, $col, ByRef $aRect)
    Local $rectangle, $rv,$ht[4]
    $rectangle = DllStructCreate("int;int;int;int") ;left, top, right, bottom
    DllStructSetData($rectangle, 1, $LVIR_BOUNDS)
    DllStructSetData($rectangle, 2, $col)
    If IsHWnd($h_listview) Then
        Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_listview, "int", $LVM_GETSUBITEMRECT, "int", $row, "ptr", DllStructGetPtr($rectangle))
        $rv = $a_ret[0]
    Else
        $rv = GUICtrlSendMsg($h_listview, $LVM_GETSUBITEMRECT, $row, DllStructGetPtr($rectangle))
    EndIf
        ReDim $aRect[4]
        $aRect = $ht
        $aRect[0] = DllStructGetData($rectangle, 1)
        $aRect[1] = DllStructGetData($rectangle, 2)
        $aRect[2] = DllStructGetData($rectangle, 3)
        $aRect[3] = DllStructGetData($rectangle, 4) - $aRect[1]
    $rectangle = 0
    Sleep(10)
    Return $rv
EndFunc   ;==>_GUICtrlListViewGetSubItemRec
;===============================================================================
; Function Name:    _InitEdit
; Description:      Bring forth the editing control and set focus on it.
; Parameter(s): $LVINFO         - IN -
;                       $LVcolControl   - IN -
;
; Requirement(s):
; Return Value(s):
; User CallTip:
; Author(s):
; Note(s):
;===============================================================================
Func _InitEdit($LVINFO, $LVcolControl)
    If $bPROGRESSSHOWING = True Then Return
    ;ConsoleWrite("_InitEdit>>"&@LF)
    If $bCanceled  Then
        $bCanceled = False
        Return
    EndIf
    if $bCALLBACK Then
        _CancelEdit()
        $bCALLBACK = False
    EndIf
    
    If $editFlag = 1 Then _CancelEdit()
    Local $CtrlType
    If $LVINFO[0] < 0 Or $LVINFO[1] < 0 Then Return 0
    If UBound($LVcolControl) - 1 < $LVINFO[1] Then
        $CtrlType = 0
    Else
        $CtrlType = $LVcolControl[$LVINFO[1]]
    EndIf
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then ConsoleWrite(_DebugHeader("$CtrlType:" & $CtrlType))
    ;----------------------------------------------------------------------------------------------
    Switch $CtrlType
        Case 1
            GUICtrlSetData($lvEdit, "")
            $editCtrl = $lvEdit
        Case 2
            $editCtrl = $lvCombo
        Case 4
            $editCtrl = $lvDate
        Case 8
            $editCtrl = $lvList
        Case 256
            $bCALLBACK= True
        Case Else
            Return
    EndSwitch
    If $bCALLBACK Then
        $bCALLBACK = False
        $bCALLBACK_EVENT =True
    Else
        ;----------------------------------------------------------------------------------------------
        If $DebugIt Then ConsoleWrite(_DebugHeader("Classname="&_GetClassName($editCtrl)))
        ;----------------------------------------------------------------------------------------------
        Local $editCtrlPos = _CalcEditPos($__LISTVIEWCTRL,$LVINFO)
        Local $x1 , $y1
        ClientToScreen($Gui,$x1,$y1)
        WinMove($lvControlGui,"", $editCtrlPos[0]+($x1-1),$editCtrlPos[1]+($y1-1), $editCtrlPos[2],$editCtrlPos[3])
;       GUICtrlSetPos($editCtrl, $editCtrlPos[0],$editCtrlPos[1], $editCtrlPos[2],$editCtrlPos[3])
        GUICtrlSetPos($editCtrl, 0,0, $editCtrlPos[2],$editCtrlPos[3])
        Local $oldText = _GUICtrlListView_GetItemText($__LISTVIEWCTRL, $LVINFO[0], $LVINFO[1])
        If $DebugIt Then ConsoleWrite($oldText&@LF)
        GUICtrlSetState($__LISTVIEWCTRL,$GUI_NOFOCUS)
        If $DebugIt Then ConsoleWrite(_GetClassName($editCtrl)&@LF)
        Switch $editCtrl
            Case $lvList
                If $oldText <> "" Then  GUICtrlSetData($editCtrl, $oldText)
            Case $lvCombo
                If $oldText <> "" Then
                    Local $index = _GUICtrlCombobox_FindString($editCtrl,$oldText)
                    If $DebugIt Then ConsoleWrite("index="&@LF)
                    If ($index = -1) Then $index = _GUICtrlComboBox_AddString($editCtrl,$oldText)
                    _GUICtrlComboBox_SetCurSel($editCtrl,$index)
                    GUICtrlSetState($editCtrl,$GUI_ONTOP)
                EndIf
            Case Else   
                GUICtrlSetData($editCtrl, $oldText)
        EndSwitch
        $editFlag = 1
        
        GUICtrlSetState($__LISTVIEWCTRL,$GUI_NOFOCUS)
        If $DebugIt Then ConsoleWrite("Set pos"&@LF)
        WinMove($lvControlGui,"", $editCtrlPos[0]+($x1-1),$editCtrlPos[1]+($y1-1), $editCtrlPos[2]+1,$editCtrlPos[3]+1)
        WinSetOnTop($lvControlGui,"",1)
        GUISetState(@SW_SHOW,$lvControlGui)
;~  GUICtrlSetPos($editCtrl, $editCtrlPos[0],$editCtrlPos[1], $editCtrlPos[2],$editCtrlPos[3])
;~  GUICtrlSetState($editCtrl, $GUI_SHOW)
        GUICtrlSetPos($editCtrl, 0,0, $editCtrlPos[2],$editCtrlPos[3])
        GUICtrlSetState($editCtrl, $GUI_SHOW)
        GUICtrlSetState($editCtrl, $GUI_FOCUS)
;       GUIRegisterMsg($WM_ACTIVATE,"WM_ACTIVATE")
        EndIf
        If $DebugIt Then ConsoleWrite("Leaving _InitEdit()"&@LF)
        EndFunc   ;==>_InitEdit

Func _MoveControl()
        If $bInitiated =  True Then
            Local $editCtrlPos = _CalcEditPos($__LISTVIEWCTRL,$LVINFO)
            Local $x1 , $y1
            ClientToScreen($Gui,$x1,$y1)
            If $editCtrlPos[0]>0 Then 
                WinMove($lvControlGui,"", $editCtrlPos[0]+($x1-1),$editCtrlPos[1]+($y1-1), $editCtrlPos[2],$editCtrlPos[3])
            Else
                WinMove($lvControlGui,"", $x1+1,$editCtrlPos[1]+($y1-1), $editCtrlPos[2]-Abs($editCtrlPos[0]),$editCtrlPos[3])
            EndIf
            ;GUICtrlSetPos($editCtrl, 0,0, $editCtrlPos[2],$editCtrlPos[3])
        EndIf
EndFunc
Func _CalcEditPos($nLvCtrl,$aINFO)
       Local $pos[4]
        Local $ctrlSize = ControlGetPos($Gui,"",$nLvCtrl)
        Local $ERR = @error 
        $pos[0] = $aINFO[2]
        $pos[1] = $aINFO[3]+3
        $pos[2] = $aINFO[4]
        $pos[3] = $aINFO[5]-4
        If $ERR Then
            ConsoleWrite("NoControlPos"&@LF)
            Return $pos
        EndIf
        If $aINFO[2]+$aINFO[4] > $ctrlSize[2] Then
            $pos[0] = $aINFO[2] - (($aINFO[2]+$aINFO[4])- $ctrlSize[2])
        EndIf
        If $editCtrl = $lvList Then
            ;make the list fit inside the ListView.
            Local $initH = (_GUICtrlListView_GetItemCount($lvList)*14.5)*(_GUICtrlListView_GetItemCount($lvList)*14.5 >0)
            Local $y1 = $ctrlSize[3] - $aINFO[3] -21 
            $y1 =  $y1* ($y1>21)
            If $initH < $y1 Then
                $pos[3]= $initH
            Else
                $pos[3] =$y1
            EndIf
            
        EndIf
        If _LvHasCheckStyle($__LISTVIEWCTRL) And $aINFO[1]= 0 And $editCtrl = $lvEdit  Then
            ;compensate for check box
            $pos[2] = $aINFO[4]-21
            $pos[0] = $aINFO[2]+21
        EndIf
    Return $pos
EndFunc

;===============================================================================
; Function Name:    _CancelEdit
; Description:      Cancels the editing process, and kills the hot keys.
; Parameter(s):
; Requirement(s):
; Return Value(s):
; User CallTip:
; Author(s):
; Note(s):
;===============================================================================
Func _CancelEdit()
    ConsoleWrite("_CancelEdit>>"&@LF)
    HotKeySet("{Enter}")
    HotKeySet("{Esc}")
    if $editFlag = 1 then Send("{Enter}");quit edit mode
    $editFlag = 0
    GUISetState(@SW_Hide,$lvControlGui); additionally hide it
    WinSetOnTop($lvControlGui,"",0); remove topmost attrib
    WinMove($lvControlGui,"",1024,768,1,1);move to bottom right corner
    GUICtrlSetState($editCtrl, $GUI_HIDE)
    GUICtrlSetPos($editCtrl, 0,0, 1, 1)
    $bCanceled = True
    $bDATECHANGED = False
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then ConsoleWrite(_DebugHeader("_CancelEdit()"))
    ;----------------------------------------------------------------------------------------------
    ;if Not(WinActive($Gui,"")) Then WinActivate($Gui,"")
EndFunc   ;==>_CancelEdit
;===============================================================================
; Function Name:    _FillLV_Info
; Description:      This fills the passed in array with row col and rect info for
;                       used by the editing controls
; Parameter(s): $__LISTVIEWCTRL - IN/OUT -
;                       $iRow               - IN -
;                       $iCol               - IN -
;                       $aLVI               - IN/OUT -
;
; Requirement(s):
; Return Value(s):
; User CallTip:
; Author(s):
; Note(s):
;===============================================================================
Func _FillLV_Info(ByRef $nLvCtrl, $iRow, $iCol, ByRef $aLVI,$iFlag = 1)
    If $iFlag Then
        $aLVI[6] = $aLVI[0] ;set old row
        $aLVI[7] = $aLVI[1] ;set old col
        $aLVI[0] = $iRow        ;set new row
        $aLVI[1] = $iCol        ;set new col
    EndIf
    If $iRow < 0 Or $iCol < 0 Then Return 0
    Local $lvi_rect[4], $pos = ControlGetPos($Gui, "", $nLvCtrl)
    _GUICtrlListViewGetSubItemRect($nLvCtrl, $iRow, $iCol, $lvi_rect)
    $aLVI[2] = $pos[0] + $lvi_rect[0] + 5
    $aLVI[3] = $pos[1] + $lvi_rect[1]
    $aLVI[4] = _GUICtrlListView_GetColumnWidth($nLvCtrl, $iCol) - 4
    $aLVI[5] = $lvi_rect[3] + 5
    Sleep(10)
    Return 1
EndFunc   ;==>_FillLV_Info

Func WM_ACTIVATE($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGui,$MsgID,$wParam, $lParam
    ;Local $wa = _LoWord($wParam)
    Local $hActive = DllCall("user32.dll","hwnd","GetForegroundWindow")
    If $lParam = 0 And $editFlag = 1  Then
        _CancelEdit()
    EndIf
    If IsArray($hActive) Then
        WinSetOnTop($hActive[0],"",1)
        WinSetOnTop($hActive[0],"",0)
    EndIf
   Return 0
EndFunc

;===============================================================================
; Function Name:    WM_Notify_Events
; Description:      Event handler for windows WN_NOTIFY messages
; Parameter(s): $hWndGUI         - IN -
;                       $MsgID       - IN -
;                       $wParam      - IN -
;                       $lParam      - IN -
;
; Requirement(s):
; Return Value(s):
; User CallTip:
; Author(s):
; Note(s):
;===============================================================================
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    
    Global $View_multiline_ToolTip = True
    Global $Baloon_ToolTip = 1 ; should be 0 or 1
    Global $Fly_Over = False
    Global $iLastItem = -1, $iLastsubitemNR = -1
    Global $hGUI_Multiline, $View_Multiline, $ColName ; Multiline cell viewer window
    
    
    Local $tagNMHDR, $pressed,$event, $retval = $GUI_RUNDEFMSG ;, $idFrom
    $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)
    If @error Then
        $tagNMHDR =0
        Return
    EndIf
;~  $from = DllStructGetData($tagNMHDR, 1)
;~  $idFrom = DllStructGetData($tagNMHDR,2)
    ;ConsoleWrite("idFrom="&$idFrom&@LF)
    $event = DllStructGetData($tagNMHDR, 3)
    Select
        Case ($event = $HDN_TRACK or $event = $HDN_TRACKW)
            ;column dragging
            _CancelEdit()
        Case $MsgID = $WM_MOVING
            _MoveControl()
        Case $wParam = $__LISTVIEWCTRL
            Select
                Case $event = $LVN_ITEMCHANGED
                Local $ckcount = _LvGetCheckedCount($__LISTVIEWCTRL)
                    If $LVCHECKEDCNT <> $ckcount Then
                        $LVCHECKEDCNT = $ckcount
                        $bLVITEMCHECKED = True
                        _CancelEdit()
                        
                    EndIf

                    
                
                    
                Case $event = $LVN_COLUMNCLICK
                    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                __GUICtrlListView_SimpleSort($ListView, $B_DESCENDING, DllStructGetData($tInfo, "SubItem"))



                Case $event = $NM_CUSTOMDRAW
                    If Not _GUICtrlListView_GetViewDetails($ListView) Then Return $GUI_RUNDEFMSG
                    Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
                    Local $iDrawStage, $iItem, $iSubitem, $hDC, $tRect
                    $iDrawStage = DllStructGetData($tCustDraw, 'dwDrawStage')
                    Switch $iDrawStage
                        Case $CDDS_ITEMPREPAINT
                            Return $CDRF_NOTIFYSUBITEMDRAW
                        Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM)
                            $iItem = DllStructGetData($tCustDraw, 'dwItemSpec')
                            $iSubitem = DllStructGetData($tCustDraw, 'iSubItem')
                         
                    EndSwitch





                Case $event = $NM_CLICK
                    If $bLVEDITondblclick = True Then
                        _LVGetInfo($lParam)
                        ;scroll column into view.
                        Switch $LVINFO[1]
                        Case 0
                            _GUICtrlListView_Scroll ( $__LISTVIEWCTRL, -$LVINFO[4], 0 )
                            _FillLV_Info($__LISTVIEWCTRL, $LVINFO[8], $LVINFO[9], $LVINFO,0)
                            ;_LVGetInfo($lParam)
                        Case Else
                            Local $ctrlSize = ControlGetPos("","",$__LISTVIEWCTRL)
                            If $LVINFO[2]+$LVINFO[4] > $ctrlSize[2] Then
                            _GUICtrlListView_Scroll ( $__LISTVIEWCTRL, $LVINFO[4], 0 )
                            _FillLV_Info($__LISTVIEWCTRL, $LVINFO[8], $LVINFO[9], $LVINFO,0)
                            EndIf
                        EndSwitch
                        if Not $bLVITEMCHECKED Then 
                            _ListView_Click()
                        EndIf
                    Else
                        if $editFlag = 1 Then _CancelEdit()
                    EndIf
                    
                    
                    
                        
                      Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    Local $iItem = DllStructGetData($tInfo, "Item")
                    Local $subitemNR = DllStructGetData($tInfo, "SubItem")
                    $Column_attribute =_GUICtrlListView_GetColumn($ListView, $subitemNR)
                    ; if no cell change return without doing anything
                    If $iLastItem = $iItem And $iLastsubitemNR = $subitemNR Then Return 0
                    $iLastItem = $iItem
                    $iLastsubitemNR = $subitemNR
                    
                    Local $sToolTipData = _GUICtrlListView_GetItemText($ListView, $iItem,$subitemNR)
                    $Mypos = StringInStr ( $sToolTipData, @CRLF )
                
                    
                    
                    If $Mypos = 0 Then 
                        If $View_multiline_ToolTip = True Then
                            ToolTip($sToolTipData, MouseGetPos(0) + 15, MouseGetPos(1) + 15,"",0,$Baloon_ToolTip)                       
                        EndIf
                        ;ConsoleWrite("R" & $iItem & "C" & $subitemNR & " No tip" & @CR)
                    Else    
                        ToolTip("")
                    EndIf
                
                    If _GUICtrlListView_GetItemText($listview, 1, $subitemNR) = "L/P" Then
                    GUICtrlSetData($lvCombo, "")    
                    GUICtrlSetData($lvCombo, "L|P1|P2|P3|P4")
                    EndIf
                    If _GUICtrlListView_GetItemText($listview, 1, $subitemNR) = "PP" Then
                    GUICtrlSetData($lvCombo, "")    
                    GUICtrlSetData($lvCombo, "20%|25%|30%|35%|40%|45%|50%|100%")
                    EndIf
                    If _GUICtrlListView_GetItemText($listview, 1, $subitemNR) = "Koszty personelu" Then
                    GUICtrlSetData($lvCombo, "")    
                    GUICtrlSetData($lvCombo, "TAK|NIE")
                    EndIf
                    If _GUICtrlListView_GetItemText($listview, 1, $subitemNR) = "Pozycja skalowana" Then
                    GUICtrlSetData($lvCombo, "")    
                    GUICtrlSetData($lvCombo, "TAK|NIE")
                    EndIf










                $bLVITEMCHECKED = False;
                Case $event = $NM_DBLCLK
                   ConsoleWrite("$NM_DBLCLK"&@LF)
                    _LVGetInfo($lParam)
                    _ListView_DoubleClick()
                Case $event = $NM_RCLICK
                    _LVGetInfo($lParam)
                    _ListView_RClick()
                Case $event = -180
                    If $DebugIt Then ConsoleWrite("LVEVENT=-180"&@LF)
                    If $editFlag = 1 Then
                        Send("{Esc}")
                        _CancelEdit()
                        $retval = 0
                    EndIf
                Case $event = -181
                    If $DebugIt Then ConsoleWrite("LVEVENT=-181"&@LF)
                    _FillLV_Info($__LISTVIEWCTRL, $LVINFO[0], $LVINFO[1], $LVINFO,0)
                Case $event= -121
                    If $DebugIt Then ConsoleWrite("LVEVENT=-121"&@LF)
                    _LVGetInfo($lParam,1)
                Case Else
                    If $DebugIt Then ConsoleWrite("LV_EVENT>>"&$event&@LF)
            EndSelect
        Case $lvDate
            Select
                Case $event = $DTN_DROPDOWN
                    $bCanceled = False
                    $bDATECHANGED = False
                Case $event = $DTN_WMKEYDOWNA
                    $pressed = _vKeyCheck()
                    If $pressed = 27 Then _CancelEdit()
                Case $event = $DTN_DATETIMECHANGE
                    If $DebugIt Then ConsoleWrite("DTN_DATETIMECHANGE"&@LF)                 
                    If $bDATECHANGED = False Then $bDATECHANGED = True
                    $pressed = _vKeyCheck()
                    if $pressed = 27 Then
                        _CancelEdit()
                        $bDATECHANGED = False
                    EndIf
                Case $event = $DTN_CLOSEUP
                    If $DebugIt Then ConsoleWrite("DTN_CLOSEUP"&@LF)            
                    if $bCanceled or ($bDATECHANGED = False) Then 
                        Send("{Esc}")
                        $bDATECHANGED = False
                    Else
;                       If $bLVUPDATEonfocusCHANGE = True Then
                            Send("{Enter}")
                            $bDATECHANGED = True
;                       Else
;                           Send("{Esc}")
;                       EndIf
                    EndIf
                case $event = -7
                    If $DebugIt Then ConsoleWrite("dtn $event="&$event&@LF)
                    $bCanceled = False
                    $bDATECHANGED = False
                Case $event = -8
                    If $DebugIt Then ConsoleWrite("dtn $event="&$event&" , ")
                    If $DebugIt Then ConsoleWrite("$bCanceled="&$bCanceled&@LF)
                    If $DebugIt Then ConsoleWrite("$bDATECHANGED="&$bDATECHANGED&@LF)
                    if $bCanceled = True Then
                        ;or ($bDATECHANGED = False) Then 
                        Send("{Esc}")
                        $bDATECHANGED = False
                        $bCanceled = False
                    Else
                        $bDATECHANGED = True
                    EndIf
            EndSelect
        Case $event = -326
            ConsoleWrite("HDN Notification: "&$event&@LF)
            if $editFlag Then _CancelEdit()
        Case $MsgID = $WM_KEYDOWN
            ;----------------------------------------------------------------------------------------------
            If $DebugIt Then ConsoleWrite(_DebugHeader("Keydown"))
            ;----------------------------------------------------------------------------------------------
        Case Else
            If $DebugIt Then ConsoleWrite("WPARAM = "&$wParam&@LF)
                    ;;uncomment the following line to have the edit _LVUpdate if the mouse moves
            ;;off of the listview.
            If $editFlag And Not(_HasFocus($editCtrl)) Then _LVUpdate($editCtrl, $__LISTVIEWCTRL, $LVINFO[0], $LVINFO[1])
    EndSelect
    If $DebugIt Then
        If $wParam <> $__LISTVIEWCTRL Then
            ConsoleWrite($hWndGUI &" "& $event&@LF)
        EndIf
    EndIf
    
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
    Return $retval
EndFunc   ;==>WM_Notify_Events

Func WM_MOVE_EVENT($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGuI,$MsgID,$wParam,$lParam
    If $editFlag Then _MoveControl()
    Return True
EndFunc

;===============================================================================
; Function Name:    WM_Command_Events
; Description:      Event handler for windows WN_Command messages
; Parameter(s): $hWndGUI         - IN -
;                       $MsgID       - IN -
;                       $wParam      - IN -
;                       $lParam      - IN -
;
; Requirement(s):
; Return Value(s):
; User CallTip:
; Author(s):
; Note(s):
;===============================================================================
Func WM_Command_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $nNotifyCode, $nID,$hCtrl
    Local $retval = $GUI_RUNDEFMSG 
    $nNotifyCode    = BitShift($wParam, 16)
    $nID            = BitAnd($wParam, 0x0000FFFF)
    $hCtrl          = $lParam
       Switch $nID 
          Case  $lvList
            Switch $nNotifyCode  
                Case $LBN_DBLCLK
                    $bLVDBLCLICK = True
                    ;Send("{Enter}")
                    _SendMessage($lvControlGui,$WM_COMMAND,_MakeLong($editCtrl,$LBN_SELCHANGE),$lParam)
                    _LVUpdate($editCtrl, $__LISTVIEWCTRL, $LVINFO[0], $LVINFO[1])
                    Return $GUI_RUNDEFMSG
                Case $LBN_SELCHANGE
                If $DebugIt Then ConsoleWrite("$LBN_SELCHANGE"&@LF)
                    If Not $bLVDBLCLICK Then Return 0 
                Case $LBN_SETFOCUS
                    If $DebugIt Then ConsoleWrite("$LBN_SETFOCUS"&@LF)
                Case $LBN_KILLFOCUS
                    If $DebugIt Then ConsoleWrite("$LBN_KILLFOCUS"&@LF) 
                Case Else
                    If $DebugIt Then ConsoleWrite("ListBox>>"&$nNotifyCode&@LF)
            EndSwitch
        Case $lvCombo
            Switch $nNotifyCode
                Case $CBN_SELCHANGE
                    If $DebugIt Then ConsoleWrite("$CBN_SELCHANGE"&@LF)
                    Send("{Enter}")
            EndSwitch
        Case Else
            If $DebugIt Then ConsoleWrite("$nId="&$nId&@lf)
    EndSwitch
    If $hCtrl = _GetComboInfo($lvCombo) And $DebugIt Then ConsoleWrite("$MsgID="&$MsgID&@LF)
    If $bCanceled  then
        $bCanceled = 0 
        $retval = 0
    EndIf
                    
Return $retval
EndFunc

;===============================================================================
; Function Name :   _MakeLong
; Description       :   Converts two 16 bit values into on 32 bit value
; Parameter(s)      :   $LoWord      16bit value 
;                       :   $HiWord      16bit value
; Return Value(s)   :   Long value
; Note(s)           :   
;===============================================================================
Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

;===============================================================================
; Function Name :   _LVGetInfo
; Description       :   
; Parameter(s)      :   $lParam      Pointer to $tagNMITEMACTIVE struct
;                           $iFlag       Optional value 0 (default)= fill all fields
;                                                                1 = fill just the latest click location.                                                
; Requirement(s)    :   
; Return Value(s)   :   
; User CallTip      :   
; Author(s)         :   
; Note(s)           :   
;===============================================================================
Func _LVGetInfo($lParam,$iFlag =0 )
    Local $tagNMITEMACTIVATE = DllStructCreate("int;int;int;int;int;int;int;int;int", $lParam)
    Local $clicked_row = DllStructGetData($tagNMITEMACTIVATE, 4)
    Local $clicked_col = DllStructGetData($tagNMITEMACTIVATE, 5)
    if $clicked_col < -1 then $clicked_col = -1 
    if $clicked_row < -1 then $clicked_row = -1 
    if $clicked_col > _GUICtrlListView_GetColumnCount($__LISTVIEWCTRL) then $clicked_col = -1 
    if $clicked_row > _GUICtrlListView_GetItemCount($__LISTVIEWCTRL) then $clicked_row = -1 
    $tagNMITEMACTIVATE = 0
    if $iFlag =0 then
        _FillLV_Info($__LISTVIEWCTRL, $clicked_row, $clicked_col, $LVINFO)
        $old_col = $clicked_col
    EndIf
        $LVINFO[8] = $clicked_row
        $LVINFO[9] = $clicked_col
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then ConsoleWrite(_DebugHeader("Col:" & $clicked_col))
    If $DebugIt Then ConsoleWrite(_DebugHeader("Row:" & $clicked_row))
    ;----------------------------------------------------------------------------------------------

EndFunc


;===============================================================================
; Function Name:    _DebugHeader
; Description:      Gary's console debug header.
; Parameter(s):         $s_text      - IN -
;
; Requirement(s):
; Return Value(s):
; User CallTip:
; Author(s):
; Note(s):
;===============================================================================
Func _DebugHeader($s_text)
    Return _
            "!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF
        EndFunc   ;==>_DebugHeader
        
;===============================================================================
; Function Name:    _GetClassName
; Description:      get the classname of a ctrl
; Parameter(s): $nCtrl       the ctrlId of to get classname for. 
; Requirement(s):       
; Return Value(s):  Classname or 0 on failure
; User CallTip: 
; Author(s):        Stephen Podhajecki <gehossafats at netmdc.com/>
; Note(s):          Strips trailing numbers from classname.
;===============================================================================
Func _GetClassName($nCtrl)
    Local $ret, $struct = DllStructCreate("char[128]"),$classname = 0
    $ret = DllCall("user32.dll","int","GetClassName","hwnd",GUICtrlGetHandle($nCtrl),"ptr",DllStructGetPtr($struct),"int",DllStructGetSize($struct))
    If IsArray($ret) Then
        $classname = DllStructGetData($struct,1)
        ;ConsoleWrite("Classname="&$classname&@LF)
    EndIf
    $struct =0 
    Return $classname
EndFunc
;===============================================================================
; Function Name:    vKeyCheck  alias for __IsPressedMod
; Description:  Gets a key press
; Parameter(s):         $dll         - IN/OPTIONAL -
; Requirement(s):
; Return Value(s): Return the key that is pressed or 0
; User CallTip:
; Author(s):
; Note(s):
;===============================================================================
Func _vKeyCheck($dll = "user32.dll")
    Local $aR, $hexKey, $i
    Local $vkeys[4]=[1,13,27,113];leftmouse,enter,esc,f2
    For $i =0 to UBound($vkeys)-1
        $hexKey = '0x'&Hex($vkeys[$i],2)
        $aR = DllCall($dll, "int", "GetAsyncKeyState", "int", $hexKey)
        If $aR[0] <> 0 Then Return $vkeys[$i]
        Sleep(5)
    Next
    Return 0
EndFunc   ;==>__IsPressedMod

;===============================================================================
; Function Name :   _HasFocus
; Description       :   Return true if control has focus
; Parameter(s)      :   $nCtrl Ctrlid to check
; Return Value(s)   :   True is ctrl has focus, false otherwise.
; User CallTip      :   
; Author(s)         :   Stephen Podhajecki <gehossafats at netmdc.com/>
; Note(s)           :   
;===============================================================================
Func _HasFocus($nCtrl)
;   If $DebugIt Then ConsoleWrite("_HasFocus>>"&@LF)
Local $hwnd
    if $nCtrl = $lvCombo Then
        $hwnd = _GetComboInfo($nCtrl,0)
    Else
        $hwnd = GUICtrlGetHandle($nCtrl)
    EndIf
    Return ($hwnd = ControlGetHandle($Gui,"",ControlGetFocus($Gui,"")))
EndFunc

;===============================================================================
; Function Name :   _SetLVCallBack
; Description       :   
; Parameter(s)      :   $CallBack   Function to use for(primary button) call back defaults to _CancelEdit() 
; Return Value(s)   :   None.
; Author(s)         :   Stephen Podhajecki <gehossafats at netmdc.com/>
; Note(s)           :   This is used to open other controls and dialogs
;===============================================================================
Func _SetLVCallBack($CallBack = "_CancelEdit")
    If $CallBack <> "" Then $LVCALLBACK = $CallBack
EndFunc
    
;===============================================================================
; Function Name :   _SetLVContext
; Description       :   
; Description       :   
; Parameter(s)      :   $CallBack   Function to use for (secondary button) contexts defaults to _CancelEdit() 
; Return Value(s)   :   None.
; Author(s)         :   Stephen Podhajecki <gehossafats at netmdc.com/>
; Note(s)           :   This is used to open other controls and dialogs (context menus)
;===============================================================================
Func _SetLVContext($Context = "_CancelEdit")
    if $Context <> "" Then $LVCONTEXT = $Context
EndFunc
;===============================================================================
; Function Name :   _LvHasCheckStyle
; Description       :   
; Parameter(s)      :   $hCtrl      Listview control to check for $LVS_EX_CHECKBOXES style
;
; Requirement(s)    :   
; Return Value(s)   :   
; User CallTip      :   
; Author(s)         :   Stephen Podhajecki <gehossafats at netmdc.com/>
; Note(s)           :   
;===============================================================================
Func _LvHasCheckStyle($hCtrl)
    Local $style =  _GUICtrlListView_GetExtendedListViewStyle($hCtrl)
    if (BitAnd($style,$LVS_EX_CHECKBOXES) = $LVS_EX_CHECKBOXES) Then Return True
    Return False
EndFunc

;===============================================================================
; Function Name :   _LvGetCheckedCount
; Description       :   
; Parameter(s)      :   $nCtrl       Listview control to get checked checkbox count.
;
; Requirement(s)    :   
; Return Value(s)   :   number of checked checkboxes, or zero.
; User CallTip      :   
; Author(s)         :   Stephen Podhajecki <gehossafats at netmdc.com/>
; Note(s)           :   
;===============================================================================
Func _LvGetCheckedCount($nCtrl)
    if _LvHasCheckStyle($nCtrl) Then
        Local $count =0
        For $x =0 to _GUICtrlListView_GetItemCount($nCtrl)-1
            If _GUICtrlListView_GetItemChecked($nCtrl,$x) Then $count += 1
        Next
        Return $count
    EndIf
    Return 0
EndFunc

;===============================================================================
; Function Name :   _GetComboInfo
; Description       :   
; Parameter(s)      :   $nCtrl      ComboBox control to get info for
;                           $type           0= return edit hwnd, 1=  return list hwnd 
;
; Requirement(s)    :   
; Return Value(s)   :   return either the combos edit or list hwnd, or zero otherwise
; User CallTip      :   
; Author(s)         :   Stephen Podhajecki <gehossafats at netmdc.com/>
; Note(s)           :   
;===============================================================================
Func _GetComboInfo($nCtrl,$type =0)
    ;ConsoleWrite(" _GetClassName:"&_GetClassName($nCtrl)&@LF)
    If _GetClassName($nCtrl) <> "ComboBox" Then Return 0
    Local $ret, $cbInfo ,$v_ret
    $cbInfo = DllStructCreate("int;int[4];int[4];int;int;int;int")
    DllStructSetData($cbInfo,1,DllStructGetSize($cbInfo))
    $v_ret = DllCall("user32.dll","int","GetComboBoxInfo","hwnd",GUICtrlGetHandle($nCtrl),"ptr",DllStructGetPtr($cbInfo))
    if IsArray($v_ret) Then 
        if $type = 0 Then
            $ret= DllStructGetData($cbInfo,6);edit handle
            ;ConsoleWrite("Text ="&WinGetText($ret)&@LF)
        Elseif $type =1 Then 
            $ret = DllStructGetData($cbInfo,7);list handle
        EndIf
    EndIf
    $cbInfo =0
    Return $ret
EndFunc
Func _InvalidateRect($hWnd)
    Local $v_ret =  DllCall("user32.dll", "int", "InvalidateRect","hwnd",$hWnd,"ptr", 0,"int",1)
    return $v_ret[0]
EndFunc

Func _UpdateWindow($hWnd)
    Local $v_ret = DllCall("user32.dll", "int", "UpdateWindow", "hwnd", $hWnd)
    Return $v_ret[0]
EndFunc  ;==>UpdateWindow
;;;ripped from help file.
; Convert the client (GUI) coordinates to screen (desktop) coordinates
Func ClientToScreen($hWnd, ByRef $x, ByRef $y)
    Local $stPoint = DllStructCreate("int;int")
    DllStructSetData($stPoint, 1, $x)
    DllStructSetData($stPoint, 2, $y)
    DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint))
    $x = DllStructGetData($stPoint, 1)
    $y = DllStructGetData($stPoint, 2)
    ; release Struct not really needed as it is a local 
    $stPoint = 0
EndFunc
Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc   ;==>_HiWord

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc   ;==>_LoWord

    
        
    
    
    
    
    
    
    
    
    
    



Func __GUICtrlListView_SimpleSort($hWnd, ByRef $vDescending, $iCol) ; modified to sort also IParam
    If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd)
    Global $x, $Y, $Z, $b_desc, $columns, $items, $v_item, $temp_item, $iFocused = -1
    Global $SeparatorChar = Opt('GUIDataSeparatorChar')
    If _GUICtrlListView_GetItemCount($hWnd) Then
        If (IsArray($vDescending)) Then
            $b_desc = $vDescending[$iCol]
        Else
            $b_desc = $vDescending
        EndIf
        $columns = _GUICtrlListView_GetColumnCount($hWnd)
        $items = _GUICtrlListView_GetItemCount($hWnd)
        For $x = 1 To $columns
            $temp_item = $temp_item & " " & $SeparatorChar
        Next
        $temp_item = StringTrimRight($temp_item, 1)
;~      Global $a_lv[$items][$columns + 1], $i_selected
        Global $a_lv[$items][$columns + 2], $i_selected ; add column for IParam  ### MODIFIED ###

        $i_selected = StringSplit(_GUICtrlListView_GetSelectedIndices($hWnd), $SeparatorChar)
        For $x = 0 To UBound($a_lv) - 1 Step 1
            If $iFocused = -1 Then
                If _GUICtrlListView_GetItemFocused($hWnd, $x) Then $iFocused = $x
            EndIf
            _GUICtrlListView_SetItemSelected($hWnd, $x, False)
;~          _GUICtrlListView_SetItemState($hWnd, $x, 0, BitOR($LVIS_SELECTED, $LVIS_FOCUSED))
;~          For $Y = 0 To UBound($a_lv, 2) - 2 Step 1
            For $Y = 0 To UBound($a_lv, 2) - 3 Step 1  ;  ### MODIFIED ###
                $v_item = StringStripWS(_GUICtrlListView_GetItemText($hWnd, $x, $Y), 2)
                If (StringIsFloat($v_item) Or StringIsInt($v_item)) Then
                    $a_lv[$x][$Y] = Number($v_item)
                Else
                    $a_lv[$x][$Y] = $v_item
                EndIf
            Next
            $a_lv[$x][$Y] = $x
            $a_lv[$x][$Y+1] = _GUICtrlListView_GetItemParam($hWnd, $x)  ;  ### NEW ###
        Next
        _ArraySort($a_lv, $b_desc, 0, 0, $iCol)
        For $x = 0 To UBound($a_lv) - 1 Step 1
;~          For $Y = 0 To UBound($a_lv, 2) - 2 Step 1
            For $Y = 0 To UBound($a_lv, 2) - 3 Step 1  ;  ### MODIFIED ###
;~              _GUICtrlListViewSetItemText($hWnd, $x, $Y, $a_lv[$x][$Y])
                _GUICtrlListView_SetItemText($hWnd, $x, $a_lv[$x][$Y], $Y)
            Next
            _GUICtrlListView_SetItemParam($hWnd, $x, $a_lv[$x][$Y+1])  ;  ### NEW ###
            For $Z = 1 To $i_selected[0]
;~              If $a_lv[$x][UBound($a_lv, 2) - 1] = $i_selected[$Z] Then
                If $a_lv[$x][UBound($a_lv, 2) - 2] = $i_selected[$Z] Then  ;  ### MODIFIED ###
;~                  If $a_lv[$x][UBound($a_lv, 2) - 1] = $iFocused Then
                    If $a_lv[$x][UBound($a_lv, 2) - 2] = $iFocused Then  ;  ### MODIFIED ###
                        _GUICtrlListView_SetItemSelected($hWnd, $x, True, True)
                    Else
                        _GUICtrlListView_SetItemSelected($hWnd, $x, True)
                    EndIf
;~                  _GUICtrlListView_SetItemState($hWnd, $x, $LVIS_SELECTED, BitOR($LVIS_SELECTED, $LVIS_FOCUSED))
;~                  If $a_lv[$x][UBound($a_lv, 2) - 1] = $iFocused Then _GUICtrlListView_SetItemState($hWnd, $x, $LVIS_FOCUSED, $LVIS_FOCUSED)
                    ExitLoop
                EndIf
            Next
        Next
        If (IsArray($vDescending)) Then
            $vDescending[$iCol] = Not $b_desc
        Else
            $vDescending = Not $b_desc
        EndIf
    EndIf
EndFunc   ;==>__GUICtrlListView_SimpleSort

there is load file (name "2010-05-20 14-54-43.ini")

[section0]
0=
1=A
2=B
3=C
4=D
5=E
6=F
7=G
8=H
9=I
10=J
[section1]
0=-
1=-
2=---I---
3=1
4=2
5=3
6=4
7=5
8=6
9=7
10=8
11=9
12=10
13=11
14=12
15=13
16=14
17=15
18=16
19=17
20=18
21=19
22=---II---
23=21
24=22
25=23
26=24
27=25
28=26
29=27
30=28
31=---III---
32=30
33=31
34=32
35=33
36=34
37=35
38=36
39=37
40=---IV---
41=39
42=40
43=41
44=42
45=43
46=44
47=45
48=46
49=---V---
50=48
51=49
52=50
53=51
54=52
55=53
56=54
57=55
58=56
59=57
60=58
61=59
62=60
63=61
64=62
65=63
66=64
67=65
68=66
69=67
70=68
71=69
72=70
73=71
74=72
75=73
76=74
77=75
78=76
79=77
80=78
81=79
82=80
83=81
84=82
85=83
86=84
87=85
88=86
89=87
90=88
91=89
92=90
93=91
94=92
95=93
96=94
97=95
98=96
99=
[section2]
0=Koszty
1=Bezposrednie
2=Zadanie nr 1 Zarzadzanie Projektem
3=Przygotowanie materialów promocyjnych (projekt, druk) - plakaty informacyjne
4=Przygotowanie materialów promocyjnych (projekt,druk) - foldery informacyjne
5=Wykonanie strony internetowej projektu
6=Zakup materiałów promocyjnych - ramy na plakaty
7=Wynagrodzenie administratora strony www projektu (os. samozatrudniona)e
8=Wynagrodzenie specjalistów ds. rekrutacji (osoby samozatrudnione); 3 dni/rekrutację x 32 rekrutacje
9=Koszty podróży specjalistów ds. rekrutacji; 32 rekrutacje
10=Noclegi specjalistów ds. rekrutacji; 3noclegów/rekrutację x 32 rekrutacje
11=Wykonanaie nakelejek na segregatory
12=Zakup materiałów promocyjnych - roll-up'y
13=Wyżywienie specjalistów ds. rekrutacji; 3 dni/rekrutację x 32 rekrutacje
14=Wynagrodzenie kierownika projektu (osoba samozatrudniona)
15=Wynagrodzenie specjalisty ds. formalnych (umowa zlecenie)
16=Wynagrodzenie specjalisty ds. organizacji (os.samozatrudniona)
17=Koszty podróży specjalisty ds. organizacyjnych; 1 wizyta/województwo x 16 województw
18=Noclegi specjalisty ds. organizacyjnych; 1 nocleg/wizytÄ™ x 16 wizyt
19=Wyżywienie specjalisty ds. organizacyjnych; 1 dzień/wizytę x 16 wizyt
20=Koszty 2 rachunków bankowych (dofinansowania i wkłądu prywatnego)
21=Audyt projektu
22=Zadanie nr 2 Realizacja szkoleń - Menedżerowie sieci
23=Zakup usług szkoleniowych - Centrala; 2 dni/zjazd x 3 zjazdy/grupę x 1 grupa
24=Wynagrodzenie opiekunów szkoleń (osoby samozatrudnione); 2 dni/zjazd x 3 zjazdy/grupę x 1 grupa
25=Noclegi opiekunów szkoleń; 2 noclegi/zjazd x 3 zjazdy
26=Wyżywienie opiekunów szkoleń; 2 dni/zjazd x 3 zjazdy
27=Przewóz uczestników i opiekuna szkoleń; 1 przewóz/zjazd x 3 zjazdy
28=Koszt wynajmu sal szkoleniowych; 2 dni/zjazd x 3 zjazdy
29=Wyżywienie uczestników szkoleń; 2 dni/zjazd x 3 zjazdy/grupę x 1 grupa x 10 osób/grupę
30=Noclegi uczestników szkoleń; 1 nocleg/zjazd x 3 zjazdy/grupę x 1 grupa x 10 osób/grupę
31=Zadanie nr 3 Realizacja szkoleń - Trenerzy wewnętrzni
32=Zakup usług szkoleniowych - warsztaty trenerskie; 2 dni/zjazd x 3 zjazdy/grupę x 1 grupa
33=Wynagrodzenie opiekunów szkoleń (osoby samozatrudnione); 2 dni/zjazd x 3 zjazdy/grupę x 1 grupa
34=Noclegi opiekunów szkoleń; 2 noclegi/zjazd x 3 zjazdy
35=Wyżywienie opiekunów szkoleń; 2 dni/zjazd x 3 zjazdy
36=Przewóz uczestników i opiekuna szkoleń; 1 przewóz/zjazd x 3 zjazdy
37=Koszt wynajmu sal szkoleniowych; 2 dni/zjazd x 3 zjazdy
38=Wyżywienie uczestników szkoleń; 2 dni/zjazd x 3 zjazdy/grupę x 1 grupa x 6 osób/grupę
39=Noclegi uczestników szkoleń; 1 nocleg/zjazd x 3 zjazdy/grupę x 1 grupa x 6 osób/grupę
40=Zadanie nr 4 Realizacja szkoleń - Menedżerowie sprzedaży
41=Zakup usług szkoleniowych - menedżerowi sprzedaży; 8 dni/grupę x 32 grupy
42=Wynagrodzenie uczestników szkolenia - pracowników delegowanych do udziału w szkoleniu; 68,79zł/dzień x 8dni/osobę x 220 osób
43=Wynagrodzenie opiekunów szkoleń (osoby samozatrudnione); 8 dni/grupę x 32 grupy
44=Koszty podróży opiekunów szkoleń; 1 wizyta/szkolenie x 8 szkoleń/grupę x 32 grupy
45=Noclegi opiekunów szkoleń; 1 nocleg/szkolenie x 8 szkoleń/grupę x 32 grupy
46=Wyżywienie opiekunów szkoleń; 1 dzień/szkolenie x 8 szkoleń/grupę x 32 grupy
47=Koszt wynajmu sal szkoleniowych; 1 dzień/szkolenie x 8 szkoleń/grupę x 32 grupy
48=Wyżywienie uczestników szkoleń; 8dni/grupę x 32 grupy x 10 osób/grupę
49=Zadanie nr 5  Ewaluacja
50=Zakup usług w zakresie ewaluacji (opracowanie koncepcji ewaluacji i narzędzi badawczych)
51=Zakup usług w zakresie ewaluacji (realizacja badań terenowych - tajemniczy klient)
52=Zakup usług w zakresie ewaluacji (opracowanie i prezentacja wyników ewaluacji)
53=
54=
55=
56=
57=
58=
59=
60=
61=
62=
63=
64=
65=
66=
67=
68=
69=
70=
71=
72=
73=
74=
75=
76=
77=
78=
79=
80=
81=
82=
83=
84=
85=
86=
87=
88=
89=
90=
91=
92=
93=
94=
95=
96=
97=
98=
99=
[section3]
0=
1=CF
2=
3=
4=
5=
6=
7=
8=
9=
10=
11=
12=
13=
14=
15=
16=
17=
18=
19=
20=
21=
22=
23=
24=
25=
26=
27=
28=
29=
30=
31=
32=
33=
34=
35=
36=
37=
38=
39=
40=
41=
42=
43=
44=
45=
46=
47=
48=
49=
50=
51=
52=
53=
54=
55=
56=
57=
58=
59=
60=
61=
62=
63=
64=
65=
66=
67=
68=
69=
70=
71=
72=
73=
74=
75=
76=
77=
78=
79=
80=
81=
82=
83=
84=
85=
86=
87=
88=
89=
90=
91=
92=
93=
94=
95=
96=
97=
98=
99=
[section4]
0=
1=UZ
2=
3=
4=
5=
6=
7=
8=
9=
10=
11=
12=
13=
14=
15=
16=
17=
18=
19=
20=
21=
22=
23=
24=
25=
26=
27=
28=
29=
30=
31=
32=
33=
34=
35=
36=
37=
38=
39=
40=
41=
42=
43=
44=
45=
46=
47=
48=
49=
50=
51=
52=
53=
54=
55=
56=
57=
58=
59=
60=
61=
62=
63=
64=
65=
66=
67=
68=
69=
70=
71=
72=
73=
74=
75=
76=
77=
78=
79=
80=
81=
82=
83=
84=
85=
86=
87=
88=
89=
90=
91=
92=
93=
94=
95=
96=
97=
98=
99=
[section5]
0=
1=PP
2=
3=
4=
5=
6=
7=
8=
9=
10=
11=
12=
13=
14=
15=
16=
17=
18=
19=
20=
21=
22=
23=
24=
25=
26=
27=
28=
29=
30=
31=
32=
33=
34=
35=
36=
37=
38=
39=
40=
41=
42=
43=
44=
45=
46=
47=
48=
49=
50=
51=
52=
53=
54=
55=
56=
57=
58=
59=
60=
61=
62=
63=
64=
65=
66=
67=
68=
69=
70=
71=
72=
73=
74=
75=
76=
77=
78=
79=
80=
81=
82=
83=
84=
85=
86=
87=
88=
89=
90=
91=
92=
93=
94=
95=
96=
97=
98=
99=
[section6]
0=
1=L/P
2=
3=L
4=L
5=L
6=L
7=L
8=L
9=L
10=L
11=L
12=L
13=L
14=L
15=L
16=L
17=L
18=L
19=L
20=L
21=L
22=
23=L
24=L
25=L
26=L
27=L
28=L
29=L
30=L
31=
32=L
33=L
34=L
35=L
36=L
37=L
38=L
39=L
40=
41=L
42=L
43=L
44=L
45=L
46=L
47=L
48=L
49=L
50=L
51=L
52=L
53=L
54=L
55=L
56=L
57=L
58=L
59=L
60=L
61=L
62=L
63=L
64=L
65=L
66=L
67=L
68=L
69=L
70=L
71=L
72=L
73=L
74=L
75=L
76=L
77=L
78=L
79=L
80=L
81=L
82=L
83=L
84=L
85=L
86=L
87=L
88=L
89=L
90=L
91=L
92=L
93=L
94=L
95=L
96=L
97=L
98=L
99=
[section7]
0=
1=Koszty personelu 
2=
3=
4=
5=
6=
7=
8=
9=
10=
11=
12=
13=
14=
15=
16=
17=
18=
19=
20=
21=
22=
23=
24=
25=
26=
27=
28=
29=
30=
31=
32=
33=
34=
35=
36=
37=
38=
39=
40=
41=
42=
43=
44=
45=
46=
47=
48=
49=
50=
51=
52=
53=
54=
55=
56=
57=
58=
59=
60=
61=
62=
63=
64=
65=
66=
67=
68=
69=
70=
71=
72=
73=
74=
75=
76=
77=
78=
79=
80=
81=
82=
83=
84=
85=
86=
87=
88=
89=
90=
91=
92=
93=
94=
95=
96=
97=
98=
99=
[section8]
0=
1=Pozycja skalowana
2=
3=
4=
5=
6=
7=
8=
9=
10=
11=
12=
13=
14=
15=
16=
17=
18=
19=
20=
21=
22=
23=
24=
25=
26=
27=
28=
29=
30=
31=
32=
33=
34=
35=
36=
37=
38=
39=
40=
41=
42=
43=
44=
45=
46=
47=
48=
49=
50=
51=
52=
53=
54=
55=
56=
57=
58=
59=
60=
61=
62=
63=
64=
65=
66=
67=
68=
69=
70=
71=
72=
73=
74=
75=
76=
77=
78=
79=
80=
81=
82=
83=
84=
85=
86=
87=
88=
89=
90=
91=
92=
93=
94=
95=
96=
97=
98=
99=
[section9]
0=
1=j.m
2=
3=sztuka
4=sztuka
5=usługa
6=sztuka
7=miesiÄ…c
8=dzień
9=rekrutacja
10=nocleg
11=komplet
12=sztuka
13=dzień
14=miesiÄ…c
15=miesiÄ…c
16=miesiÄ…c
17=wyjazd
18=nocleg
19=dzień
20=miesiÄ…c
21=usługa
22=
23=dzień
24=dzień
25=nocleg
26=dzień
27=przewóz
28=dzień
29=osobodzień
30=osobonocleg
31=
32=dzień
33=dzień
34=nocleg
35=dzień
36=przewóz
37=dzień
38=osobodzień
39=osobodzień
40=
41=dzień
42=osobodzień
43=dzień
44=wizyta
45=nocleg
46=dzień
47=osobodzień
48=osobodzień
49=usługa
50=usługa
51=usługa
52=usługa
53=
54=
55=
56=
57=
58=
59=
60=
61=
62=
63=
64=
65=
66=
67=
68=
69=
70=
71=
72=
73=
74=
75=
76=
77=
78=
79=
80=
81=
82=
83=
84=
85=
86=
87=
88=
89=
90=
91=
92=
93=
94=
95=
96=
97=
98=
99=
[section10]
0=
1=
2=
3=
4=
5=
6=
7=
8=
9=
10=
11=
12=
13=
14=
15=
16=
17=
18=
19=
20=
21=
22=
23=
24=
25=
26=
27=
28=
29=
30=
31=
32=
33=
34=
35=
36=
37=
38=
39=
40=
41=
42=
43=
44=
45=
46=
47=
48=
49=
50=
51=
52=
53=
54=
55=
56=
57=
58=
59=
60=
61=
62=
63=
64=
65=
66=
67=
68=
69=
70=
71=
72=
73=
74=
75=
76=
77=
78=
79=
80=
81=
82=
83=
84=
85=
86=
87=
88=
89=
90=
91=
92=
93=
94=
95=
96=
97=
98=
99=
[section11]
0=
1=
2=
3=
4=
5=
6=
7=
8=
9=
10=
11=
12=
13=
14=
15=
16=
17=
18=
19=
20=
21=
22=
23=
24=
25=
26=
27=
28=
29=
30=
31=
32=
33=
34=
35=
36=
37=
38=
39=
40=
41=
42=
43=
44=
45=
46=
47=
48=
49=
50=
51=
52=
53=
54=
55=
56=
57=
58=
59=
60=
61=
62=
63=
64=
65=
66=
67=
68=
69=
70=
71=
72=
73=
74=
75=
76=
77=
78=
79=
80=
81=
82=
83=
84=
85=
86=
87=
88=
89=
90=
91=
92=
93=
94=
95=
96=
97=
98=
99=
[section12]
0=
1=
2=
3=
4=
5=
6=
7=
8=
9=
10=
11=
12=
13=
14=
15=
16=
17=
18=
19=
20=
21=
22=
23=
24=
25=
26=
27=
28=
29=
30=
31=
32=
33=
34=
35=
36=
37=
38=
39=
40=
41=
42=
43=
44=
45=
46=
47=
48=
49=
50=
51=
52=
53=
54=
55=
56=
57=
58=
59=
60=
61=
62=
63=
64=
65=
66=
67=
68=
69=
70=
71=
72=
73=
74=
75=
76=
77=
78=
79=
80=
81=
82=
83=
84=
85=
86=
87=
88=
89=
90=
91=
92=
93=
94=
95=
96=
97=
98=
99=
[section13]
0=
1=
2=
3=
4=
5=
6=
7=
8=
9=
10=
11=
12=
13=
14=
15=
16=
17=
18=
19=
20=
21=
22=
23=
24=
25=
26=
27=
28=
29=
30=
31=
32=
33=
34=
35=
36=
37=
38=
39=
40=
41=
42=
43=
44=
45=
46=
47=
48=
49=
50=
51=
52=
53=
54=
55=
56=
57=
58=
59=
60=
61=
62=
63=
64=
65=
66=
67=
68=
69=
70=
71=
72=
73=
74=
75=
76=
77=
78=
79=
80=
81=
82=
83=
84=
85=
86=
87=
88=
89=
90=
91=
92=
93=
94=
95=
96=
97=
98=
99=
[section-1]
0=
1=---I---
2=
3=---II---
4=
5=---III---
6=
7=---IV---
8=
9=---V---
10=
11=---VI---
12=
13=---VII---
14=
15=---VII---
16=
17=---IX---
18=
19=---X---
20=
21=
22=
23=
24=
25=
26=
27=
28=
29=
30=
31=
32=
33=
34=
35=
36=
37=
38=
39=
40=
41=
42=
43=
44=
45=
46=
47=
48=
49=
50=
51=
52=
53=
54=
55=
56=
57=
58=
59=
60=
61=
62=
63=
64=
65=
66=
67=
68=
69=
70=
71=
72=
73=
74=
75=
76=
77=
78=
79=
80=
81=
82=
83=
84=
85=
86=
87=
88=
89=
90=
91=
92=
93=
94=
95=
96=
97=
98=
99=
[section-2]
0=9
1=3
2=22
3=23
4=31
5=32
6=40
7=41
8=49
9=50
10=53
11=
12=
13=
14=
15=
16=
17=
18=
19=
20=
21=
22=
23=
24=
25=
26=
27=
28=
29=
30=
31=
32=
33=
34=
35=
36=
37=
38=
39=
40=
41=
42=
43=
44=
45=
46=
47=
48=
49=
50=
51=
52=
53=
54=
55=
56=
57=
58=
59=
60=
61=
62=
63=
64=
65=
66=
67=
68=
69=
70=
71=
72=
73=
74=
75=
76=
77=
78=
79=
80=
81=
82=
83=
84=
85=
86=
87=
88=
89=
90=
91=
92=
93=
94=
95=
96=
97=
98=
99=

and...? :mellow:

Link to comment
Share on other sites

Zwinny, it gives a lot of errors   :mellow:  :

K:\test\Zwinny\_EIPListView.au3(224,46) : WARNING: $ListView: possibly used before declaration.
    _GUICtrlListView_SetColumnWidth($ListView,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
K:\test\Zwinny\_EIPListView.au3(674,70) : WARNING: $B_DESCENDING: possibly used before declaration.
                __GUICtrlListView_SimpleSort($ListView, $B_DESCENDING,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
K:\test\Zwinny\prog.au3(145,50) : WARNING: $lokacja2: possibly used before declaration.
                $liczebka[$k] = IniRead($lokacja2,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
K:\test\Zwinny\prog.au3(262,23) : WARNING: $PL: possibly used before declaration.
    If GUICtrlRead($PL)
~~~~~~~~~~~~~~~~~~~~~~^
K:\test\Zwinny\prog.au3(264,27) : WARNING: $PP: possibly used before declaration.
        If GUICtrlRead($PP)
~~~~~~~~~~~~~~~~~~~~~~~~~~^
K:\test\Zwinny\prog.au3(442,34) : WARNING: $mojecombo: possibly used before declaration.
    $ile = GUICtrlRead($mojecombo)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
K:\test\Zwinny\prog.au3(443,33) : WARNING: $pozycje: possibly used before declaration.
    $ile2 = GUICtrlRead($pozycje)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
K:\test\Zwinny\prog.au3(515,20) : WARNING: $gui1: possibly used before declaration.
    GUIDelete($gui1)
~~~~~~~~~~~~~~~~~~~^
K:\test\Zwinny\prog.au3(603,129) : WARNING: $czas: possibly used before declaration.
     Global $lokacja = FileSaveDialog( "Zapisz plik...", @ScriptDir, "Pliki tekstowe (*.ini)|Skrypty (*.aut;*.au3)", 2+16, $czas,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
K:\test\Zwinny\prog.au3(45,79) : WARNING: $PL: declared global in function only. Prefer top of file.
    Global $PL = GUICtrlCreateCombo("0", 200, 102, 100, 40, $CBS_DROPDOWNLIST)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
K:\test\Zwinny\_EIPListView.au3(1196,63) : ERROR: _GUICtrlListView_ValidateClassName(): undefined function.
    If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
K:\test\Zwinny\prog.au3(100,59) : ERROR: lvListViewHandler(): undefined function.
    GUICtrlSetOnEvent($__LISTVIEWCTRL, "lvListViewHandler")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
K:\test\Zwinny\prog.au3 - 2 error(s), 10 warning(s)
!>20:42:00 AU3Check ended.rc:2

If it works for you, post a print screen.

EDIT: Or post the Excel workbook, to see what cells have to be merged, what format etc

Edited by taietel
Link to comment
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
 Share

  • Recently Browsing   0 members

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