文本框显示数据默认大小比较保守,可用GUICtrlSetLimit()控制!
<P>列举某文件夹下所有文件,写入C:\1.txt,(论坛某朋友贡献的源码)</P><P>我在此之上加了使之显示在edit文本框.</P>
<P>但是会卡在某个地方,C:\1.txt里面是列举完成了的,难道是数量限制吗?</P>
<P> </P>
<P>附上截图及源码</P>#include <GUIConstants.au3>
#Region ### START Koda GUI section ### Form=
$AForm1 = GUICreate("AForm1", 633, 451, 193, 125)
$Edit1 = GUICtrlCreateEdit("", 8, 8, 617, 400, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL))
$Button1 = GUICtrlCreateButton("Button1", 8, 408, 617, 33, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
If FileExists("c:\1.txt") Then FileDelete("c:\1.txt")
Local $fh = FileOpen("c:\1.txt", 2)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
FindAll("F:")
FileClose($fh)
EndSwitch
WEnd
Func FindAll($path)
Local $fpath, $fs, $fa
$fpath = $path & "\*.*"
Local $f = FileFindFirstFile($fpath)
While 1
$fs = FileFindNextFile($f)
If @error Then
FileClose($f)
Return
EndIf
If $fs = "." Or $fs = ".." Then
ContinueLoop
EndIf
$fa = FileGetAttrib($path & "\" & $fs)
If StringInStr($fa, "D") Then
FindAll($path & "\" & $fs)
Else
FileWriteLine($fh, $path & "\" & $fs)
GUICtrlSetData($Edit1,$path & "\" & $fs&@CRLF,1)
EndIf
WEnd
EndFunc
[ 本帖最后由 e5907 于 2008-7-29 08:34 编辑 ] 貌似就是字数限制...我用覆盖显示就可以例举完了! 原帖由 e5907 于 2008-7-28 17:26 发表 http://www.autoitx.com/images/common/back.gif
貌似就是字数限制...我用覆盖显示就可以例举完了!
默认是有字数限制,修改为下面的程序应该是满足文件列表
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $_1MB = 1024*1024
Global $limit = 8 * $_1MB
#Region ### START Koda GUI section ### Form=
$AForm1 = GUICreate("AForm1", 633, 451, 193, 125)
$Edit1 = GUICtrlCreateEdit("", 8, 8, 617, 400)
GUICtrlSetLimit(-1, $limit)
$Button1 = GUICtrlCreateButton("Button1", 8, 408, 617, 33, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
If FileExists("c:\1.txt") Then FileDelete("c:\1.txt")
Local $fh = FileOpen("c:\1.txt", 2)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
FindAll("F:")
FileClose($fh)
EndSwitch
WEnd
Func FindAll($path)
Local $fpath, $fs, $fa
$fpath = $path & "\*.*"
Local $f = FileFindFirstFile($fpath)
While 1
$fs = FileFindNextFile($f)
If @error Then
FileClose($f)
Return
EndIf
If $fs = "." Or $fs = ".." Then
ContinueLoop
EndIf
$fa = FileGetAttrib($path & "\" & $fs)
If StringInStr($fa, "D") Then
FindAll($path & "\" & $fs)
Else
FileWriteLine($fh, $path & "\" & $fs)
GUICtrlSetData($Edit1,$path & "\" & $fs&@CRLF,1)
EndIf
WEnd
EndFunc GUICtrlSetLimit() 谢谢 auto 朋友的解答...
谢谢 漠北雪~狼的解答..
我查看了GUICtrlSetLimit()函数的..不过快下班的时候看的就没有测试,而且我怕是有最大限制,所以先发贴问问.呵呵!
原来默认的大小是比较保守的咯!
页:
[1]