找回密码
 加入
搜索
查看: 9465|回复: 17

[GUI管理] GUICtrlCreateInput有数量限制吗?

 火.. [复制链接]
发表于 2012-9-21 01:03:51 | 显示全部楼层 |阅读模式
#include <Array.au3>
#include <GUIConstantsEx.au3>

Dim $FieldArray[1000][1000]
$MyGUI = GUICreate("", 800, 600, 0, 0)
$YY = 100
For $Y = 1 to 221
                $FieldArray[$Y][1] = GUICtrlCreateInput("", 100, $YY, 80, 20)
                $FieldArray[$Y][2] = GUICtrlCreateInput("", 200, $YY, 80, 20)
                $FieldArray[$Y][3] = GUICtrlCreateInput("", 300, $YY, 80, 20)
                $FieldArray[$Y][4] = GUICtrlCreateInput("", 400, $YY, 80, 20)
                $FieldArray[$Y][5] = GUICtrlCreateInput("", 500, $YY, 80, 20)
                $FieldArray[$Y][6] = GUICtrlCreateInput("", 600, $YY, 80, 20)
                $FieldArray[$Y][7] = GUICtrlCreateInput("", 700, $YY, 80, 20)
                $FieldArray[$Y][8] = GUICtrlCreateInput("", 800, $YY, 80, 20)
                $FieldArray[$Y][9] = GUICtrlCreateInput("", 900, $YY, 80, 20)
                $FieldArray[$Y][10] = GUICtrlCreateInput("", 1000, $YY, 80, 20)
                $FieldArray[$Y][11] = GUICtrlCreateInput("", 1100, $YY, 80, 20)
                $FieldArray[$Y][12] = GUICtrlCreateInput("", 1200, $YY, 80, 20)
                $FieldArray[$Y][13] = GUICtrlCreateInput("", 1300, $YY, 80, 20)
                $FieldArray[$Y][14] = GUICtrlCreateInput("", 1400, $YY, 80, 20)
                $FieldArray[$Y][15] = GUICtrlCreateInput("", 1500, $YY, 80, 20)
                $FieldArray[$Y][16] = GUICtrlCreateInput("", 1600, $YY, 80, 20)
                $FieldArray[$Y][17] = GUICtrlCreateInput("", 1700, $YY, 80, 20)
                $FieldArray[$Y][18] = GUICtrlCreateInput("", 1800, $YY, 80, 20)
                $FieldArray[$Y][19] = GUICtrlCreateInput("", 1900, $YY, 80, 20)
                $FieldArray[$Y][20] = GUICtrlCreateInput("", 2000, $YY, 80, 20)
                $FieldArray[$Y][21] = GUICtrlCreateInput("", 2100, $YY, 80, 20)
                $FieldArray[$Y][22] = GUICtrlCreateInput("", 2200, $YY, 80, 20)
                $FieldArray[$Y][23] = GUICtrlCreateInput("", 2300, $YY, 80, 20)
                $FieldArray[$Y][24] = GUICtrlCreateInput("", 2400, $YY, 80, 20)
                $FieldArray[$Y][25] = GUICtrlCreateInput("", 2500, $YY, 80, 20)
                $FieldArray[$Y][26] = GUICtrlCreateInput("", 2600, $YY, 80, 20)
                $FieldArray[$Y][27] = GUICtrlCreateInput("", 2700, $YY, 80, 20)
                $FieldArray[$Y][28] = GUICtrlCreateInput("", 2800, $YY, 80, 20)
                $FieldArray[$Y][29] = GUICtrlCreateInput("", 2900, $YY, 80, 20)
                $FieldArray[$Y][30] = GUICtrlCreateInput("", 3000, $YY, 80, 20)
                $FieldArray[$Y][31] = GUICtrlCreateInput("", 3100, $YY, 80, 20)
                $FieldArray[$Y][32] = GUICtrlCreateInput("", 3200, $YY, 80, 20)
                $FieldArray[$Y][33] = GUICtrlCreateInput("", 3300, $YY, 80, 20)
                $FieldArray[$Y][34] = GUICtrlCreateInput("", 3400, $YY, 80, 20)
                $FieldArray[$Y][35] = GUICtrlCreateInput("", 3500, $YY, 80, 20)
                $FieldArray[$Y][36] = GUICtrlCreateInput("", 3600, $YY, 80, 20)
                $FieldArray[$Y][37] = GUICtrlCreateInput("", 3700, $YY, 80, 20)
                $FieldArray[$Y][38] = GUICtrlCreateInput("", 3800, $YY, 80, 20)
                $FieldArray[$Y][39] = GUICtrlCreateInput("", 3900, $YY, 80, 20)
                $FieldArray[$Y][40] = GUICtrlCreateInput("", 4000, $YY, 80, 20)
                $FieldArray[$Y][41] = GUICtrlCreateInput("", 4100, $YY, 80, 20)
                $FieldArray[$Y][42] = GUICtrlCreateInput("", 4200, $YY, 80, 20)
                $FieldArray[$Y][43] = GUICtrlCreateInput("", 4300, $YY, 80, 20)
                $FieldArray[$Y][44] = GUICtrlCreateInput("", 4400, $YY, 80, 20)
                $FieldArray[$Y][45] = GUICtrlCreateInput("", 4500, $YY, 80, 20)
                $YY += 30
        Next
        $btn = GUICtrlCreateButton("退出", 800, $YY +50, 80, 20)
GUISetState()

        $msg = 0
        While $msg <> $GUI_EVENT_CLOSE
                $msg = GUIGetMsg()
                Select
                        Case $msg = $btn
                                ExitLoop
                EndSelect
        WEnd
以上代码运行正常,但若是For $Y = 1 to 222,代码运行后窗体一闪而逝,请问是什么原因?
是GUICtrlCreateInput创建的单行输入栏控件有数量限制吗?
发表于 2012-9-21 08:33:14 | 显示全部楼层
你的代码我测试正常啊,但你做什么程序需要用到这么多的input
发表于 2012-9-21 09:11:48 | 显示全部楼层
本帖最后由 半芯竹 于 2012-9-21 09:16 编辑

回复 1# drifter

#include <Array.au3>
#include <GUIConstantsEx.au3>
Local $FieldArray[1000][1000],$YY = 100
$MyGUI = GUICreate("", 800, 600, 0, 0)
For $Y = 1 to 333
                $FieldArray[$Y][1] = GUICtrlCreateInput("", 100, $YY, 80, 20)
                $FieldArray[$Y][2] = GUICtrlCreateInput("", 200, $YY, 80, 20)
                $FieldArray[$Y][3] = GUICtrlCreateInput("", 300, $YY, 80, 20)
                $FieldArray[$Y][4] = GUICtrlCreateInput("", 400, $YY, 80, 20)
                $FieldArray[$Y][5] = GUICtrlCreateInput("", 500, $YY, 80, 20)
                $FieldArray[$Y][6] = GUICtrlCreateInput("", 600, $YY, 80, 20)
                $FieldArray[$Y][7] = GUICtrlCreateInput("", 700, $YY, 80, 20)
                $FieldArray[$Y][8] = GUICtrlCreateInput("", 800, $YY, 80, 20)
                $FieldArray[$Y][9] = GUICtrlCreateInput("", 900, $YY, 80, 20)
                $FieldArray[$Y][10] = GUICtrlCreateInput("", 1000, $YY, 80, 20)
                $FieldArray[$Y][11] = GUICtrlCreateInput("", 1100, $YY, 80, 20)
                $FieldArray[$Y][12] = GUICtrlCreateInput("", 1200, $YY, 80, 20)
                $FieldArray[$Y][13] = GUICtrlCreateInput("", 1300, $YY, 80, 20)
                $FieldArray[$Y][14] = GUICtrlCreateInput("", 1400, $YY, 80, 20)
                $FieldArray[$Y][15] = GUICtrlCreateInput("", 1500, $YY, 80, 20)
                $FieldArray[$Y][16] = GUICtrlCreateInput("", 1600, $YY, 80, 20)
                $FieldArray[$Y][17] = GUICtrlCreateInput("", 1700, $YY, 80, 20)
                $FieldArray[$Y][18] = GUICtrlCreateInput("", 1800, $YY, 80, 20)
                $FieldArray[$Y][19] = GUICtrlCreateInput("", 1900, $YY, 80, 20)
                $FieldArray[$Y][20] = GUICtrlCreateInput("", 2000, $YY, 80, 20)
                $FieldArray[$Y][21] = GUICtrlCreateInput("", 2100, $YY, 80, 20)
                $FieldArray[$Y][22] = GUICtrlCreateInput("", 2200, $YY, 80, 20)
                $FieldArray[$Y][23] = GUICtrlCreateInput("", 2300, $YY, 80, 20)
                $FieldArray[$Y][24] = GUICtrlCreateInput("", 2400, $YY, 80, 20)
                $FieldArray[$Y][25] = GUICtrlCreateInput("", 2500, $YY, 80, 20)
                $FieldArray[$Y][26] = GUICtrlCreateInput("", 2600, $YY, 80, 20)
                $FieldArray[$Y][27] = GUICtrlCreateInput("", 2700, $YY, 80, 20)
                $FieldArray[$Y][28] = GUICtrlCreateInput("", 2800, $YY, 80, 20)
                $FieldArray[$Y][29] = GUICtrlCreateInput("", 2900, $YY, 80, 20)
                $FieldArray[$Y][30] = GUICtrlCreateInput("", 3000, $YY, 80, 20)
                $FieldArray[$Y][31] = GUICtrlCreateInput("", 3100, $YY, 80, 20)
                $FieldArray[$Y][32] = GUICtrlCreateInput("", 3200, $YY, 80, 20)
                $FieldArray[$Y][33] = GUICtrlCreateInput("", 3300, $YY, 80, 20)
                $FieldArray[$Y][34] = GUICtrlCreateInput("", 3400, $YY, 80, 20)
                $FieldArray[$Y][35] = GUICtrlCreateInput("", 3500, $YY, 80, 20)
                $FieldArray[$Y][36] = GUICtrlCreateInput("", 3600, $YY, 80, 20)
                $FieldArray[$Y][37] = GUICtrlCreateInput("", 3700, $YY, 80, 20)
                $FieldArray[$Y][38] = GUICtrlCreateInput("", 3800, $YY, 80, 20)
                $FieldArray[$Y][39] = GUICtrlCreateInput("", 3900, $YY, 80, 20)
                $FieldArray[$Y][40] = GUICtrlCreateInput("", 4000, $YY, 80, 20)
                $FieldArray[$Y][41] = GUICtrlCreateInput("", 4100, $YY, 80, 20)
                $FieldArray[$Y][42] = GUICtrlCreateInput("", 4200, $YY, 80, 20)
                $FieldArray[$Y][43] = GUICtrlCreateInput("", 4300, $YY, 80, 20)
                $FieldArray[$Y][44] = GUICtrlCreateInput("", 4400, $YY, 80, 20)
                $FieldArray[$Y][45] = GUICtrlCreateInput("", 4500, $YY, 80, 20)
                $YY += 30
        Next
        $btn = GUICtrlCreateButton("退出", 800, $YY +50, 80, 20)
GUISetState()
Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE
 楼主| 发表于 2012-9-21 12:56:33 | 显示全部楼层
回复  drifter
半芯竹 发表于 2012-9-21 09:11


用了你的代码可以了,谢谢你。
可是为什么呢,如果不麻烦能说说吗?我本以为是GUICtrlCreateInput有数量限制。
 楼主| 发表于 2012-9-21 13:27:09 | 显示全部楼层
经测试,确实有问题。
我重新贴段窗口加了滚动条、GUICtrlCreateInput加了序号的代码,这样看得比较清楚了
#include <Array.au3>
#include <Excel.au3>
#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Local $FieldArray[1000][1000],$YY = 100,$Z = 1
$MyGUI = GUICreate("", 800, 800, 0, 0, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
        _GUIScrollBars_Init($MyGUI)
        _GUIScrollBars_SetScrollRange($MyGUI, $SB_HORZ, 0, 1410)
        _GUIScrollBars_SetScrollRange($MyGUI, $SB_VERT, 0, 180)
        
For $Y = 1 to 100
        For $X = 1 To 100
                $FieldArray[$Y][$X] = GUICtrlCreateInput($Z, $X * 100, $YY, 80, 20)
                $Z += 1
        Next
        $YY += 30
Next

GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")
GUISetState()

Do
        $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

;================================================================================

Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)
        #forceref $Msg, $wParam
        Local $index = -1, $yChar, $xChar, $xClientMax, $xClient, $yClient, $ivMax
        For $x = 0 To UBound($aSB_WindowInfo) - 1
                If $aSB_WindowInfo[$x][0] = $hWnd Then
                        $index = $x
                        $xClientMax = $aSB_WindowInfo[$index][1]
                        $xChar = $aSB_WindowInfo[$index][2]
                        $yChar = $aSB_WindowInfo[$index][3]
                        $ivMax = $aSB_WindowInfo[$index][7]
                        ExitLoop
                EndIf
        Next
        If $index = -1 Then Return 0

        Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)

        ; Retrieve the dimensions of the client area.
        $xClient = BitAND($lParam, 0x0000FFFF)
        $yClient = BitShift($lParam, 16)
        $aSB_WindowInfo[$index][4] = $xClient
        $aSB_WindowInfo[$index][5] = $yClient

        ; Set the vertical scrolling range and page size
        DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
        DllStructSetData($tSCROLLINFO, "nMin", 0)
        DllStructSetData($tSCROLLINFO, "nMax", $ivMax)
        DllStructSetData($tSCROLLINFO, "nPage", $yClient / $yChar)
        _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)

        ; Set the horizontal scrolling range and page size
        DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
        DllStructSetData($tSCROLLINFO, "nMin", 0)
        DllStructSetData($tSCROLLINFO, "nMax", 2 + $xClientMax / $xChar)
        DllStructSetData($tSCROLLINFO, "nPage", $xClient / $xChar)
        _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)

        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

Func WM_HSCROLL($hWnd, $Msg, $wParam, $lParam)
        #forceref $Msg, $lParam
        Local $nScrollCode = BitAND($wParam, 0x0000FFFF)

        Local $index = -1, $xChar, $xPos
        Local $Min, $Max, $Page, $Pos, $TrackPos

        For $x = 0 To UBound($aSB_WindowInfo) - 1
                If $aSB_WindowInfo[$x][0] = $hWnd Then
                        $index = $x
                        $xChar = $aSB_WindowInfo[$index][2]
                        ExitLoop
                EndIf
        Next
        If $index = -1 Then Return 0

;~         ; Get all the horizontal scroll bar information
        Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ)
        $Min = DllStructGetData($tSCROLLINFO, "nMin")
        $Max = DllStructGetData($tSCROLLINFO, "nMax")
        $Page = DllStructGetData($tSCROLLINFO, "nPage")
        ; Save the position for comparison later on
        $xPos = DllStructGetData($tSCROLLINFO, "nPos")
        $Pos = $xPos
        $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
        #forceref $Min, $Max
        Switch $nScrollCode

                Case $SB_LINELEFT ; user clicked left arrow
                        DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)

                Case $SB_LINERIGHT ; user clicked right arrow
                        DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)

                Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box
                        DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)

                Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box
                        DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)

                Case $SB_THUMBTRACK ; user dragged the scroll box
                        DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)
        EndSwitch

;~    // Set the position and then retrieve it.  Due to adjustments
;~    //   by Windows it may not be the same as the value set.

        DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
        _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
        _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
        ;// If the position has changed, scroll the window and update it
        $Pos = DllStructGetData($tSCROLLINFO, "nPos")
        If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0)
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_HSCROLL

Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)
        #forceref $Msg, $wParam, $lParam
        Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
        Local $index = -1, $yChar, $yPos
        Local $Min, $Max, $Page, $Pos, $TrackPos

        For $x = 0 To UBound($aSB_WindowInfo) - 1
                If $aSB_WindowInfo[$x][0] = $hWnd Then
                        $index = $x
                        $yChar = $aSB_WindowInfo[$index][3]
                        ExitLoop
                EndIf
        Next
        If $index = -1 Then Return 0


        ; Get all the vertial scroll bar information
        Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
        $Min = DllStructGetData($tSCROLLINFO, "nMin")
        $Max = DllStructGetData($tSCROLLINFO, "nMax")
        $Page = DllStructGetData($tSCROLLINFO, "nPage")
        ; Save the position for comparison later on
        $yPos = DllStructGetData($tSCROLLINFO, "nPos")
        $Pos = $yPos
        $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

        Switch $nScrollCode
                Case $SB_TOP ; user clicked the HOME keyboard key
                        DllStructSetData($tSCROLLINFO, "nPos", $Min)

                Case $SB_BOTTOM ; user clicked the END keyboard key
                        DllStructSetData($tSCROLLINFO, "nPos", $Max)

                Case $SB_LINEUP ; user clicked the top arrow
                        DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)

                Case $SB_LINEDOWN ; user clicked the bottom arrow
                        DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)

                Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box
                        DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)

                Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box
                        DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)

                Case $SB_THUMBTRACK ; user dragged the scroll box
                        DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)
        EndSwitch

;~    // Set the position and then retrieve it.  Due to adjustments
;~    //   by Windows it may not be the same as the value set.

        DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
        _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
        _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
        ;// If the position has changed, scroll the window and update it
        $Pos = DllStructGetData($tSCROLLINFO, "nPos")

        If ($Pos <> $yPos) Then
                _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos))
                $yPos = $Pos
        EndIf

        Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_VSCROLL
代码很短,之所以这么长是因为为了滚屏拼凑了段帮助里抄来的函数。
从运行结果来看,本欲生成的100*100也就是一万个GUICtrlCreateInput里,还是只生成了9989个。
我顶楼的代码运行到9990就退出了,根据三楼的修改后防止自已退出了,但没能解决问题的根源。
发表于 2012-9-21 14:37:00 | 显示全部楼层
回复 5# drifter

我运行了你本楼的代码,只有9961个生成~~

本帖子中包含更多资源

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

×
发表于 2012-9-21 14:53:33 | 显示全部楼层
楼主   这是什么用呢?
多一个循环少一些代码   看看是否合用:
#include <Array.au3>
#include <GUIConstantsEx.au3>
Local $FieldArray[1000][1000],$YY = 100
$MyGUI = GUICreate("", 800, 600, 0, 0)
For $Y = 1 to 333
                For $x = 1 To 45
                        $FieldArray[$Y][$x] = GUICtrlCreateInput("", $x*100, $YY, 80, 20)
                Next 
        $YY += 30
Next
        $btn = GUICtrlCreateButton("退出", 800, $YY +50, 80, 20)
GUISetState()
Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE
 楼主| 发表于 2012-9-21 15:27:42 | 显示全部楼层
楼主   这是什么用呢?
多一个循环少一些代码   看看是否合用:
魔导 发表于 2012-9-21 14:53


谢谢,在五楼已经换子循环了,与这个无关。
具体代码的作用是用来导入每天的Excel报表(列数固定/行数不固定),然后视需要在窗体内编缉,然后将编缉所得内容insert到数据库。
发表于 2012-9-21 15:34:02 | 显示全部楼层
回复 8# drifter


    不好意思  ,只看了  一楼...........
发表于 2012-9-21 16:44:24 | 显示全部楼层
回复 8# drifter


    我承认我电脑垃圾了
E5200 +4G内存,运行你这个东东,卡了十几分钟。。动也动不了。。不解。
 楼主| 发表于 2012-9-21 19:02:28 | 显示全部楼层
回复  drifter

我运行了你本楼的代码,只有9961个生成~~
annybaby 发表于 2012-9-21 14:37 [url=http://www.autoitx.com/forum.php?mod=redirect&goto=findpost&pid=473838&ptid=35088][/url]


我换了台电脑,结果变成了9987,这到底是怎么回事呢
发表于 2012-9-21 20:10:49 | 显示全部楼层
回复 11# drifter

我换了个3.3.7.15版的也是9987~~
  原来的3.3.9.4的是9961
发表于 2012-9-21 23:14:53 | 显示全部楼层
目测 内存溢出
发表于 2012-9-21 23:14:58 | 显示全部楼层
双击回复了,编辑之
 楼主| 发表于 2012-9-26 22:53:12 | 显示全部楼层
我顶一下,求高人解答
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-26 22:20 , Processed in 0.079153 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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