找回密码
 加入
搜索
查看: 1840|回复: 4

文本框显示数据默认大小比较保守,可用GUICtrlSetLimit()控制!

[复制链接]
发表于 2008-7-28 17:14:00 | 显示全部楼层 |阅读模式
<P>列举某文件夹下所有文件,写入C:\1.txt,(论坛某朋友贡献的源码)</P>
<P>我在此之上加了使之显示在edit文本框.</P>
<P>但是会卡在某个地方,C:\1.txt里面是列举完成了的,难道是数量限制吗?</P>
<P>&nbsp;</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 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2008-7-28 17:26:17 | 显示全部楼层
貌似就是字数限制...我用覆盖显示就可以例举完了!
发表于 2008-7-28 19:32:51 | 显示全部楼层
原帖由 e5907 于 2008-7-28 17:26 发表
貌似就是字数限制...我用覆盖显示就可以例举完了!

默认是有字数限制,修改为下面的程序应该是满足文件列表
#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
发表于 2008-7-29 05:55:10 | 显示全部楼层
GUICtrlSetLimit()
 楼主| 发表于 2008-7-29 08:32:51 | 显示全部楼层
谢谢 auto 朋友的解答...
谢谢 漠北雪~狼的解答..

我查看了GUICtrlSetLimit()函数的..不过快下班的时候看的就没有测试,而且我怕是有最大限制,所以先发贴问问.呵呵!
原来默认的大小是比较保守的咯!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-19 18:55 , Processed in 0.089775 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表