本帖最后由 xlcwxl 于 2010-2-2 16:51 编辑 #include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#Include <GuiListView.au3>
#include <WindowsConstants.au3>
#include '_FileSRER2Line.au3'
#Region ### START Koda GUI section ###
$Form1 = GUICreate("Form1", 554, 425, 192, 124)
$ListView1 = GUICtrlCreateListView("", 24, 16, 506, 390)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_AddColumn($ListView1, "条数",60)
_GUICtrlListView_AddColumn($ListView1, "名称",230)
$RightMenu = GUICtrlCreateContextMenu($ListView1)
$RightDel = GUICtrlCreateMenuItem("删除",$RightMenu)
GUISetState(@SW_SHOW)
read()
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $RightDel
$select = GUICtrlRead(GUICtrlRead($ListView1))
$line = StringTrimLeft(StringTrimRight($select,1), StringInStr(StringTrimRight($select,1), '|',0,1,1))
MsgBox(64,'',$line)
_FileSRER2Line(@ScriptDir&'\text',$line)
EndSwitch
WEnd
Func read()
$fileread = FileOpen(@ScriptDir&'\text',0)
If $fileread = -1 Then
MsgBox(64, "提示", "不能读取",5)
EndIf
$i = 1
While 1
$temp = FileReadLine($fileread)
If @error Then ExitLoop
If Not $temp = "" Then
GUICtrlCreateListViewItem($i & "|" & $temp,$ListView1)
$i += 1
EndIf
WEnd
FileClose($fileread)
EndFunc
listview种的右键删除不了,应该是文件被占用,但是我用了fileclose还是不行,不知问题出在哪?
糊涂啊;解决了,以上代码正确 |