下在这个例中,我想点这样操作,点一下“读取列表”,将重新读入ini的 IniReadSectionNames内容,
可是点了一下后,倒是取出来了,但以前的还在,成了重复的了;再点一下,成三个重复的内容了,
能不能,点下后,清空,然后重新读取,请求帮助
#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <Process.au3>
#include <GUIConstants.au3>
#include <guiconstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
$Form1 = GUICreate("Form1", 604, 546, 508, 164)
$ListView1 = GUICtrlCreateListView(" 列表:", 12, 46, 557, 453, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES, $LVS_EX_TRACKSELECT, $LVS_EX_HEADERDRAGDROP, $WS_HSCROLL, $WS_VSCROLL))
$Button1 = GUICtrlCreateButton("读取列表", 160, 8, 265, 33, -1, $WS_EX_CLIENTEDGE)
GUISetState(@SW_SHOW)
Global $inipath = @ScriptDir & "\列表.ini"
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_Quit()
Case $Button1
CheckIni()
EndSwitch
WEnd
Func CheckIni()
Local $ReadIni
$ReadIni = IniReadSectionNames($inipath)
If @error Then
MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
For $i = 1 To $ReadIni[0]
$item = GUICtrlCreateListViewItem($ReadIni[$i], $ListView1)
$item = GUICtrlSetData($ReadIni[$i], $ListView1)
Next
EndIf
$num = String(GUICtrlRead(GUICtrlRead($ListView1)))
EndFunc ;==>CheckIni
Func _Quit()
Exit
EndFunc ;==>_Quit
[ 本帖最后由 木纳 于 2008-5-23 11:18 编辑 ] |