Jump to content

Edit In Place Listview (multi-column)


eltorro
 Share

Recommended Posts

I looked around the forum and the web, and this is the closest thing I could come up with for editing a listview. It does not use $LVS_EDITLABELS style. Instead it relies on other Windows api's to place the editing control over the listview item. It uses a concept from pdm that uses an array that specifies what control to use on each column.

Is sounds really complicated but it isn't.

Here's the handler:

#include-once
#include <GuiConstants.au3>
#include <GuiListview.au3>
#Include <GuiCombo.au3>
#Include <GuiList.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 [url="http://netmdc.com/"]netmdc.com/[/url]> Gary Frost <gafrost at charter dot net/>
; pdm for control array concept
; see [url="http://www.autoitscript.com/forum/index.php?showtopic=42694&st=0&gopid=322551&#entry322551"]http://www.autoitscript.com/forum/index.ph...mp;#entry322551[/url]
;==============================================================================
; ######>>> 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 $HDN_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 $DTN_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 $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 = 0 ;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 [url="http://netmdc.com/"]netmdc.com/[/url]>
; 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])
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 [url="http://netmdc.com/"]netmdc.com/[/url]>
; 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
;----------------------------------------------------------------------------------------------
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])
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
_GUICtrlListViewSetItemText($__LISTVIEWCTRL, $iRow, $iCol, $newText)
EndIf
Else
_GUICtrlListViewSetItemText($__LISTVIEWCTRL, $iRow, $iCol, $newText)
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 = _GUICtrlListViewGetItemText($__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 = _GUICtrlComboFindString($editCtrl,$oldText)
If $DebugIt Then ConsoleWrite("index="&@LF)
If ($index = -1) Then $index = _GUICtrlComboAddString($editCtrl,$oldText)
_GUICtrlComboSetCurSel($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 = (_GUICtrlListCount($lvList)*14.5)*(_GUICtrlListCount($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] = _GUICtrlListViewGetColumnWidth($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
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 = $NM_CLICK
If $bLVEDITondblclick = False Then
_LVGetInfo($lParam)
;scroll column into view.
Switch $LVINFO[1]
Case 0
_GUICtrlListViewScroll ( $__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
_GUICtrlListViewScroll ( $__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

$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 > _GUICtrlListViewGetSubItemsCount($__LISTVIEWCTRL) then $clicked_col = -1
if $clicked_row > _GUICtrlListViewGetItemCount($__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 [url="http://netmdc.com/"]netmdc.com/[/url]>
; 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 [url="http://netmdc.com/"]netmdc.com/[/url]>
; 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 [url="http://netmdc.com/"]netmdc.com/[/url]>
; 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 [url="http://netmdc.com/"]netmdc.com/[/url]>
; 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 [url="http://netmdc.com/"]netmdc.com/[/url]>
; Note(s) :
;===============================================================================
Func _LvHasCheckStyle($hCtrl)
Local $style = _GUICtrlListViewGetExtendedListViewStyle($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 [url="http://netmdc.com/"]netmdc.com/[/url]>
; Note(s) :
;===============================================================================
Func _LvGetCheckedCount($nCtrl)
if _LvHasCheckStyle($nCtrl) Then
Local $count =0
For $x =0 to _GUICtrlListViewGetItemCount($nCtrl)-1
If _GUICtrlListViewGetCheckedState($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 [url="http://netmdc.com/"]netmdc.com/[/url]>
; 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

Here a test script.

#include <GuiConstants.au3>
#include <GuiTab.au3>
#include <user\_EIPListView.au3>
#AutoIt3Wrapper_AU3Check_Parameters= -q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7
Global $count = 0
;===============================================================================
; Name : ListViewEIP
; Description : An example of editing a ListView by overlaying editing controls.
; :
; Requirement(s) : _EIPListView.au3
; :
; :
; Author(s) : Stephen Podhajecki <gehossafats at [url="http://netmdc.com/"]netmdc.com/[/url]>
; Note(s) :
;===============================================================================
Global $Checkbox1, $Checkbox2, $HelpContext, $bProgressShowing, $Tab1;,$Status1,$Status2
Opt("GUICloseOnESC", 0);turn off exit on esc.
Opt("GUIOnEventMode", 1)
_Main()
Func _Main()
; ======>>> set the type of control for each column <<<======
;0= ignore, 1= edit, 2= combo, 4= calendar, 256= use callback.
Global $LVcolControl[5] = [1, 8, 256, 2, 4] ;left click actions
;0 = ignore, 1= use context callback
Global $LVcolRControl[5] = [256, 256, 0, 0, 0] ; right click actions
_SetLvCallBack ("MyCallBack") ;set callback function
_SetLvContext ("MyContext") ;set context fuction
Local $guiw = 800
Local $guih = 400
Local $deskh = @DesktopHeight - _GetTaskBarHeight()
Local $aWinPos[4] = [(@DesktopWidth - $guiw) / 2, ($deskh - $guih) / 2, 800, 400]
$Gui = GUICreate("Edit In Place Demo", $aWinPos[2], $aWinPos[3], $aWinPos[1], $aWinPos[0], BitOR($GUI_SS_DEFAULT_GUI, $WS_CLIPSIBLINGS));, 424, 280, 200, 110)
GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")
;---------------------------------------------
;create the editing controls before the ListView.
Local $Tab1 = GUICtrlCreateTab(3, 3, $guiw - 5, $guih - 5, BitOR($TCS_FOCUSNEVER, $WS_CLIPCHILDREN))
GUICtrlSetOnEvent(-1, "TabHandler")
Local $TabItem = GUICtrlCreateTabItem("Tab1")
#forceref $Tab1, $TabItem
;---------------------------------------------
Local $ListView = GUICtrlCreateListView("Items|Items2|Third|Fourth|Startdate", 10, 35, $guiw - 220, $guih - 100)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
$__LISTVIEWCTRL = $ListView

$Checkbox1 = GUICtrlCreateCheckbox("Update On Focus Change", 30, $guih - 60, 147, 17)
GUICtrlSetTip($Checkbox1, "Checking this box means that if a cell is being actively edited" & @LF & _
"and another cell is clicked, the edited cell is updated with the new data." & @LF & _
"If unchecked, the original data is preserved.")

GUICtrlSetOnEvent($Checkbox1, "SetUpdateOptions")
$Checkbox2 = GUICtrlCreateCheckbox("DblClick to Init Edit ", 30, $guih - 40, 147, 17)
GUICtrlSetTip($Checkbox2, "Checking this box means that one must double click the cell to get the edit control.")
GUICtrlSetOnEvent($Checkbox2, "SetUpdateOptions")
GUICtrlCreateTabItem("Tab2")
GUICtrlCreateTabItem("")
Local $Status1 = GUICtrlCreateLabel("", 1, $guih - 17, $guiw / 2, 17, $SS_SUNKEN)
Local $Status2 = GUICtrlCreateLabel("", ($guiw / 2) + 2, $guih - 17, ($guiw / 2) - 2, 17, $SS_SUNKEN)
; Populate list and make it wide enough to see
;======>>> Populate controls with test data<<<======
GUICtrlSetOnEvent($__LISTVIEWCTRL, "lvListViewHandler")
Local $c
For $i = 1 To 18
$c = $c & Chr($i + 66) & "|"
GUICtrlCreateListViewItem("DoubleClick or press F2, then press Enter|Something|MsgBox|" & $i & "|01/07/1969", $ListView)
Next
$c = StringTrimRight($c, 1)
GUICtrlSendMsg($ListView, 0x101E, 0, 300);$listview, LVM_SETCOLUMNWIDTH, 0, resize to widest value
GUICtrlSendMsg($ListView, 0x101E, 1, 100);$listview, LVM_SETCOLUMNWIDTH, 0, resize to widest value
GUICtrlSendMsg($ListView, 0x101E, 2, 100);$listview, LVM_SETCOLUMNWIDTH, 0, resize to widest value
;======>>> End Populate <<<======
$__LISTVIEWCTRL = $ListView ;<<<====== Set $__LISTVIEWCTRL to the ctrlID of the ListView control
WinMove($Gui, "", 1, @DesktopHeight)
GUISetState(@SW_SHOW, $Gui)
_InitEditLib ("", "", "", "Whatever", $Gui);
GUICtrlSetOnEvent($lvList, "lvListHandler")
GUICtrlSetData($lvList, "Something|Nothing|Other|Nada|Zip|Ziltch|A Lot|Mucho|Smidge|Pinch"); <<<====== populate list.
GUICtrlSetData($lvCombo, $c)
_AnimateWindow($Gui, $aWinPos)
$bInitiated = True
ConsoleWrite("Initiate Done." & @LF)
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
Local $statMsg1 = StringFormat("Row: %s Col: %s Ckd: %s", $LVINFO[8] & @TAB, $LVINFO[9] & @TAB, $LVCHECKEDCNT)
Local $statMsg2 = StringFormat("Update: %s DblClick: %s", $bLVUPDATEonfocusCHANGE, $bLVEDITondblclick)
If GUICtrlRead($Status1) <> $statMsg1 Then GUICtrlSetData($Status1, $statMsg1)
If GUICtrlRead($Status2) <> $statMsg2 Then GUICtrlSetData($Status2, $statMsg2)
Sleep(25)
WEnd

_TermEditLib ();<<<====== add this after your message loop<<<======
EndFunc ;==>_Main
Func OnExit()
_TermEditLib ()
_AnimateWindow($Gui, WinGetPos($Gui), 1)
Exit
EndFunc ;==>OnExit
Func SetUpdateOptions()
$bLVUPDATEonfocusCHANGE = (BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) = $GUI_CHECKED)
$bLVEDITondblclick = (BitAND(GUICtrlRead($Checkbox2), $GUI_CHECKED) = $GUI_CHECKED)
EndFunc ;==>SetUpdateOptions
Func MyCallBack($aLVInfo)
$bProgressShowing = True
_ArrayDisplay($aLVInfo, "LV Info")
Local $xx1, $yy1, $LVPOS
ClientToScreen (WinGetHandle($Gui), $xx1, $yy1)
Local $lvProgressWin = GUICreate("LVPROGRESSWIN", $aLVInfo[4] + 1, $aLVInfo[5] - 8, ($xx1 + $aLVInfo[2]), ($yy1 + $aLVInfo[3] + 3), $WS_POPUP, -1, $Gui)
Local $lvProgress = GUICtrlCreateProgress(0, 0, $aLVInfo[4], $aLVInfo[5] - 9)
GUICtrlSetState($lvProgress, $GUI_ONTOP)
GUISetState(@SW_SHOW, $lvProgressWin)
WinSetOnTop($lvProgressWin, "", 1)
WinActivate($lvProgressWin, "")
Local $r1 = $LVINFO[0]
Local $c1 = $LVINFO[1]
ConsoleWrite($r1 & " , " & $c1 & " " & $aLVInfo[0] & " , " & $aLVInfo[1] & @LF)
Local $xx, $yy
For $x = 0 To 100
If $r1 <> $aLVInfo[0] Or $c1 <> $aLVInfo[1] Then
_FillLV_Info ($__LISTVIEWCTRL, $r1, $c1, $aLVInfo, 0)
Else
For $xx = 0 To UBound($aLVInfo) - 1
$aLVInfo[$xx] = $LVINFO[$xx]

Next
EndIf
ConsoleWrite($r1 & " , " & $c1 & " " & $aLVInfo[0] & " , " & $aLVInfo[1] & @LF)
$xx = $aLVInfo[2]
$yy = $aLVInfo[3]
ClientToScreen ($Gui, $xx, $yy)
$LVPOS = ControlGetPos($Gui, "", $__LISTVIEWCTRL)
ClientToScreen ($Gui, $LVPOS[0], $LVPOS[1])
If $xx <> $aLVInfo[2] Or $yy <> $aLVInfo[3] Then
If $r1 = $aLVInfo[0] And $c1 = $aLVInfo[1] Then WinMove($lvProgressWin, "", ($xx), ($yy + 3))
If $xx < $LVPOS[0] Or $xx > ($LVPOS[0] + $LVPOS[2]) Or $yy + 3 < $LVPOS[1] + 20 Or $yy + 3 > ($LVPOS[1] + $LVPOS[3] - 21) Then
GUISetState(@SW_HIDE, $lvProgressWin)
Else
GUISetState(@SW_SHOW, $lvProgressWin)
EndIf
EndIf
GUICtrlSetData($lvProgress, $x)
Sleep(50)
Next
GUICtrlDelete($lvProgress)
GUIDelete($lvProgressWin)
$bProgressShowing = False
Return 1
EndFunc ;==>MyCallBack
Func MyContext($aLVInfo)
Local $ret = 0, $oldText

;create context menu on demand.
;----------------------------------------------------------------------------------------------
If $DebugIt Then ConsoleWrite(_DebugHeader (StringFormat("MyContext Row:%d Col:%d", $aLVInfo[0], $aLVInfo[1])))
;----------------------------------------------------------------------------------------------
If ($aLVInfo[0] < 0 Or $aLVInfo[1] < 0) Then Return
Local $HelpCtx[7]
$HelpCtx[0] = GUICtrlCreateDummy()
$HelpCtx[1] = GUICtrlCreateContextMenu($HelpCtx[0])
$HelpCtx[2] = GUICtrlCreateMenuItem("String Upper", $HelpCtx[1])
$HelpCtx[3] = GUICtrlCreateMenuItem("", $HelpCtx[1])
$HelpCtx[4] = GUICtrlCreateMenuItem("String Lower", $HelpCtx[1])
$HelpCtx[5] = GUICtrlCreateMenuItem("", $HelpCtx[1])
$HelpCtx[6] = GUICtrlCreateMenuItem("About...", $HelpCtx[1])
GUISetState(@SW_SHOW)
Local $hMenu = GUICtrlGetHandle($HelpCtx[1])
Local $xx, $yy
$xx = 0
$yy = 0
ClientToScreen (WinGetHandle($Gui), $xx, $yy)
Local $ctx = TrackPopupMenu(WinGetHandle($Gui), $hMenu, $xx + $aLVInfo[2], $yy + $aLVInfo[3])
;----------------------------------------------------------------------------------------------
If $DebugIt Then ConsoleWrite(_DebugHeader ("MenuItem=" & $ctx))
;----------------------------------------------------------------------------------------------
;; do something with the result.
Switch $ctx
Case $HelpCtx[2]
$oldText = _GUICtrlListViewGetItemText($__LISTVIEWCTRL, $aLVInfo[0], $aLVInfo[1])
$ret = _GUICtrlListViewSetItemText($__LISTVIEWCTRL, $aLVInfo[0], $aLVInfo[1], StringUpper($oldText))
Case $HelpCtx[4]
$oldText = _GUICtrlListViewGetItemText($__LISTVIEWCTRL, $aLVInfo[0], $aLVInfo[1])
$ret = _GUICtrlListViewSetItemText($__LISTVIEWCTRL, $aLVInfo[0], $aLVInfo[1], StringLower($oldText))
Case $HelpCtx[6]
MsgBox(266288, "EIP ListView", "Called from context menu.")
EndSwitch
;; clean up the context menu.
For $x = 0 To UBound($HelpCtx) - 1
GUICtrlDelete($HelpCtx[$x])
Next
Return $ret
EndFunc ;==>MyContext
; added TPM_RETURNCMD to uflags to get menu item return value.
; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd)
Func TrackPopupMenu($hWnd, $hMenu, $x, $y)
Local $v_ret = DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0X100, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
Return $v_ret[0]
EndFunc ;==>TrackPopupMenu
Func TabHandler()
;cancel edit if tab changes.
If _GUICtrlTabGetCurFocus($Tab1) <> 1 Then
If $editFlag Then _CancelEdit ()
EndIf
EndFunc ;==>TabHandler
Func lvListHandler()
ConsoleWrite("List control handler" & @LF)
If $bLVDBLCLICK Then
ConsoleWrite("DblClick" & @LF)
$bLVDBLCLICK = False
Else
ConsoleWrite("Click" & @LF)
EndIf
EndFunc ;==>lvListHandler
Func lvListViewHandler()
ConsoleWrite("lvListViewHandler>>" & @LF)
EndFunc ;==>lvListViewHandler
Func _AnimateWindow($hWnd, $aPos, $iFlag = 0)
If $hWnd = 0 Then Return 0
If IsArray($aPos) Then
If UBound($aPos) <> 4 Then Return 0
EndIf
Local $tstep, $lstep
If $iFlag Then
$tstep = (@DesktopHeight - $aPos[1]) / 50
$lstep = $aPos[0] / 50
For $x = 50 To 0 Step - .5
WinMove($Gui, "", $lstep * $x, @DesktopHeight - ($tstep * $x), $aPos[2] / 4, $aPos[3] / 4)
Next
Else
WinMove($Gui, "", 1, 1, 1, 1)
$tstep = (@DesktopHeight - $aPos[1]) / 50
$lstep = $aPos[0] / 50
For $x = 0 To 50 Step .5
WinMove($Gui, "", $lstep * $x, @DesktopHeight - ($tstep * $x), $aPos[2] / 4, $aPos[3] / 4)
Next
WinMove($Gui, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3])
EndIf
Return
EndFunc ;==>_AnimateWindow
Func _GetTaskBarHeight()
Local $oldOpt = Opt("WinTitleMatchMode", 4)
Local $TrayPos = WinGetPos("classname=Shell_TrayWnd")
Opt("WinTitleMatchMode", $oldOpt)
Return $TrayPos[3]
EndFunc ;==>_GetTaskBarHeight

Updated example to reflect changes.

Edit: Change the default behavior for the edit control.

Previous method, any value for the column != 1 or 2 defaulted to 0 (input box)

Now, it just returns assuming the cell is readonly.

Edit: Added code to update edit if another control outside the listview is clicked.

Removed some unused code.

Edit: Small fix for row, col indication.

Edit: Added dialog and context menu functionality.

Edit: Fixed problem with new Gui version of _ArrayDisplay crashing script.

Fixed issue Date picker not selecting date with mouse.

Made a slight change to _CancelEdit() for compatibility with beta 3.2.5.[0,1]

Edit: The editing controls are now created on a popup window to workaround

issues related to listviews on tabs.

Edit: Fixed context menu popup location.

Edit: Fixed control not moving with GUI

Edit: Fixed control staying when tab changes

Control now cancels when edit is active and column is resized.

eiplv.zip 101 downloads

EIPListView.zip 96 downloads

EIPListView.zip 47 downloads

EIPListView.zip Number of Downloads:

Edited by Jon
Link to comment
Share on other sites

  • Replies 82
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

It's working great! thanks!

few issues:

*It would be more great if the "applying process" will happend also after i clicked in some diferend place (not inside the edit), that the changes will be seen not just after pressing Enter.

*When it's monitoring, the usage of CPU is growing :shocked: (10 - 20)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

MsCreatoR,

You can change the ListView_Click func to below if you want it to update by clicking on another lv item:

;===============================================================================
; Function Name:    ListView_Click
; Description:    Called from WN_NOTIFY event handler.
; Parameter(s):
; Requirement(s):        
; Return Value(s):    
; User CallTip:    
; Author(s):        
;===============================================================================
Func ListView_Click()
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then ConsoleWrite(_DebugHeader("$NM_CLICK"))
    ;----------------------------------------------------------------------------------------------
    sleep(50)
    If $editFlag = 1 Then
        If UBound($LVcolControl)-1 < $LVINFO[1] Then            
        _CancelEdit()
        Else
            Update($editCtrl, $LISTVIEWCTRL, $LVINFO[6],$LVINFO[7])
        EndIf
    EndIf
oÝ÷ Ø]¶¢YhÂ)à)Þ¶,>·¬±çL¡Øî²ÖÞ~Þ¶·öw±·lµ«^éí¶Þvçr®±¨jëh×6If Mod($i,10) =0 Then sleep(5)

Regards

eltorro

Link to comment
Share on other sites

awesome job..

two questions/requests.. how could i edit whenever i click an item and start typin.. and another one how do you keep the contents after you typed text in the item and then click another item with the mouse..

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

eltorro

Thanks, now its realy perfect! :shocked:

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

@mrRevoked

awesome job..

two questions/requests.. how could i edit whenever i click an item and start typin.. and another one how do you keep the contents after you typed text in the item and then click another item with the mouse..

Not sure, I understand the question. Just click or double click a cell (depends on option), the edit control (input/edit box, combobox, date control) pops up in the cell. Type or pick the the new data, hit enter. Or if options are set, click on another cell.

Pressing F2 will also initiate the edit.

Press ESC to cancel the edit

I hope this answers your question.

Regards

eltorro

Edited by eltorro
Link to comment
Share on other sites

rooo man, i've made a lot of trys to make subitems editable in autoit

your work is amazing and open up more possibilities in autoit

thx for your great work !

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

Thanks for the compliments. :shocked:

A couple of small changes.

Changed the default action if a columns edit control value is incorrect. Now defaults to read only.

Changed the keypress handler to only look for the keys we want ( Enter, ESC , F2) instead of a blanket of keys. This greatly improves responsiveness.

Please see code in first post.

Link to comment
Share on other sites

  • 2 weeks later...

@mrRevoked

Not sure, I understand the question. Just click or double click a cell (depends on option), the edit control (input/edit box, combobox, date control) pops up in the cell. Type or pick the the new data, hit enter. Or if options are set, click on another cell.

Pressing F2 will also initiate the edit.

Press ESC to cancel the edit

I hope this answers your question.

Regards

eltorro

well basically i was wondering if you can get it to act like an editbox, so when you start typing it will add the text, and when you move while it was still in edit mode, it will save the contents..

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

well basically i was wondering if you can get it to act like an editbox, so when you start typing it will add the text, and when you move while it was still in edit mode, it will save the contents..

I added some code that save the edit if another control is clicked.

There is also a line that can be uncommented in WM_Notify_Events() that will trigger the update if the mouse moves off the listview.

eltorro

Link to comment
Share on other sites

I made a small fix for the rol , col values. Sometimes when a click happens outside the listview, the row and colum would be astronomical numbers.

eltorro

Link to comment
Share on other sites

now you can work on customdraw to make subitems colors ...

have fun ! XD

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

if he succeeds with custom draw, so it can implement more than dropdownlist : progressbar, colors, images and so on

i'm dreaming of that (i was working on it but's it's really complicated for someone like me)

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

I'm going to pass on the customdraw stuff. However, a couple of callback functions, that's a different story.

I made some changes to allow for right click functions and and callback functions.

They haven't been extensively tested but they work with the example script.

In your main script you assign the callback/context functions

Each one takes the $LVINFO array as a param.

;assign the callback functions.
    _SetLvCallBack("MyCallBack") ;set callback function
    _SetLvContext ("MyContext") ;set context fuction
oÝ÷ Ù8^Ç­¶ºw-ìjëh×6
Func MyCallBack($aLVInfo)
    _ArrayDisplay($aLVInfo,"LVINFO CALLBACK")
    Return 1
EndFunc
Func MyContext($aLVInfo)
    Local $ret =0
    ;create context menu on demand.
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then ConsoleWrite(_DebugHeader(StringFormat("MyContext Row:%d Col:%d",$aLVInfo[0],$aLVInfo[1])))
    ;----------------------------------------------------------------------------------------------
    If ($aLVInfo[0] <0 or $aLVInfo[1] <0) Then Return
    Dim $HelpCtx[7]
         $HelpCtx[0]= GUICtrlCreateDummy()
         $HelpCtx[1]= GUICtrlCreateContextMenu($HelpCtx[0])
         $HelpCtx[2]= GUICtrlCreateMenuItem("String Upper", $HelpCtx[1])
         $HelpCtx[3]= GUICtrlCreateMenuItem("", $HelpCtx[1])
         $HelpCtx[4]= GUICtrlCreateMenuItem("String Lower", $HelpCtx[1])
         $HelpCtx[5]= GUICtrlCreateMenuItem("", $HelpCtx[1])
         $HelpCtx[6]= GUICtrlCreateMenuItem("About...", $HelpCtx[1])
    GUISetState(@SW_SHOW)
   Local $hMenu = GUICtrlGetHandle($HelpCtx[1])
    ClientToScreen(WinGetHandle($Gui), $aLVInfo[2], $aLVInfo[3])
    Local $ctx = TrackPopupMenu(WinGetHandle($Gui), $hMenu,$aLVInfo[2], $aLVInfo[3])

    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then ConsoleWrite(_DebugHeader("MenuItem="&$ctx ))
    ;----------------------------------------------------------------------------------------------
    ;; do something with the result.
    Switch $ctx
        Case $HelpCtx[2]
            Local $oldText = _GUICtrlListViewGetItemText($LISTVIEWCTRL, $aLVInfo[0],$aLVInfo[1])
            $ret =     _GUICtrlListViewSetItemText($LISTVIEWCTRL, $aLVInfo[0],$aLVInfo[1],StringUpper($oldText))
        Case $HelpCtx[4]
            Local $oldText = _GUICtrlListViewGetItemText($LISTVIEWCTRL, $aLVInfo[0],$aLVInfo[1])
            $ret =     _GUICtrlListViewSetItemText($LISTVIEWCTRL, $aLVInfo[0],$aLVInfo[1],StringLower($oldText))
        Case $HelpCtx[6]
            MsgBox(266288,"EIP ListView","Called from context menu.")
    EndSwitch
    ;; clean up the context menu.
    For $x =0 to UBound($HelpCtx)-1
        GUICtrlDelete($HelpCtx[$x])
    Next
    Return $ret
EndFunc

The context menu has options to UPPER case or lower case the item. It opens at the top left of the ListViewItems box. It is possible that if the context menu is initiated on a far right colum that it could go beyond the boundary of the gui.

It shouldn't be too difficult to overlay a progress bar. The $LVINFO array contains to co-ordinates of the items box.

The other significant change is with the arrays that specifies what control each column uses for editing.

This will break earlier scripts and, other than any additions, will likely stay this way from here out.

This is the breakdown:

Left Click:

0= ignore, 1= edit, 2= combo, 4= calendar, 256 use callback.

Right Click:

0= ignore, 256 = use callback.

One note, if the listview is going to have the $LVS_EX_CHECKBOXES style, be sure to enable double clicking to init the edit ($bEDITondblclick = True) as a single click will both set the check box state and init the edit.

I have zipped the files and put the UDF in scrolling box for space reasons. please see the first post.

edit: changed sentence to reflect scrolling box instead of removal.

eltorro.

Edited by eltorro
Link to comment
Share on other sites

oh maaaannn ! that's REALLY impressive !

i'm really impressed by subitem editing (lower/upper) and more than that, by embedded dropdown and calendar controls

hope to see your customdraw soon

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

  • 2 months later...

I get error when the "something" item is clicked in col 2...LVINFO CALLBACK window opens as blank gui, but errors out "Not Responding" and 5 icons are displayed in the tray.

I'm using XP, autoit v3.2.4.9

Link to comment
Share on other sites

  • 2 weeks later...

@Will66: Really sorry I didn't see your post sooner.

There have been some edits made to work with current production 3.4.2.9 and beta 3.2.5.1.

The _ArrayDisplay issue with the new _ArrayDisplay version is fixed.

Updated code and zip in first post.

Edited by eltorro
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...