GUICtrlCreateInput有数量限制吗?
#include <Array.au3>#include <GUIConstantsEx.au3>
Dim $FieldArray
$MyGUI = GUICreate("", 800, 600, 0, 0)
$YY = 100
For $Y = 1 to 221
$FieldArray[$Y] = GUICtrlCreateInput("", 100, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 200, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 300, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 400, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 500, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 600, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 700, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 800, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 900, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1000, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1100, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1200, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1300, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1400, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1500, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1600, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1700, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1800, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1900, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2000, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2100, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2200, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2300, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2400, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2500, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2600, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2700, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2800, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2900, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3000, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3100, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3200, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3300, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3400, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3500, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3600, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3700, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3800, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3900, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 4000, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 4100, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 4200, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 4300, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 4400, $YY, 80, 20)
$FieldArray[$Y] = 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创建的单行输入栏控件有数量限制吗? 你的代码我测试正常啊,但你做什么程序需要用到这么多的input 本帖最后由 半芯竹 于 2012-9-21 09:16 编辑
回复 1# drifter
#include <Array.au3>
#include <GUIConstantsEx.au3>
Local $FieldArray,$YY = 100
$MyGUI = GUICreate("", 800, 600, 0, 0)
For $Y = 1 to 333
$FieldArray[$Y] = GUICtrlCreateInput("", 100, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 200, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 300, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 400, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 500, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 600, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 700, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 800, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 900, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1000, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1100, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1200, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1300, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1400, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1500, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1600, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1700, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1800, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 1900, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2000, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2100, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2200, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2300, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2400, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2500, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2600, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2700, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2800, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 2900, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3000, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3100, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3200, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3300, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3400, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3500, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3600, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3700, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3800, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 3900, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 4000, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 4100, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 4200, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 4300, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 4400, $YY, 80, 20)
$FieldArray[$Y] = GUICtrlCreateInput("", 4500, $YY, 80, 20)
$YY += 30
Next
$btn = GUICtrlCreateButton("退出", 800, $YY +50, 80, 20)
GUISetState()
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE 回复drifter
半芯竹 发表于 2012-9-21 09:11 http://www.autoitx.com/images/common/back.gif
用了你的代码可以了,谢谢你。
可是为什么呢,如果不麻烦能说说吗?我本以为是GUICtrlCreateInput有数量限制。 经测试,确实有问题。
我重新贴段窗口加了滚动条、GUICtrlCreateInput加了序号的代码,这样看得比较清楚了#include <Array.au3>
#include <Excel.au3>
#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>
Local $FieldArray,$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] = $hWnd Then
$index = $x
$xClientMax = $aSB_WindowInfo[$index]
$xChar = $aSB_WindowInfo[$index]
$yChar = $aSB_WindowInfo[$index]
$ivMax = $aSB_WindowInfo[$index]
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] = $xClient
$aSB_WindowInfo[$index] = $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] = $hWnd Then
$index = $x
$xChar = $aSB_WindowInfo[$index]
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] = $hWnd Then
$index = $x
$yChar = $aSB_WindowInfo[$index]
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就退出了,根据三楼的修改后防止自已退出了,但没能解决问题的根源。 回复 5# drifter
我运行了你本楼的代码,只有9961个生成~~{:face (319):}
楼主 这是什么用呢?
多一个循环少一些代码 看看是否合用:
#include <Array.au3>
#include <GUIConstantsEx.au3>
Local $FieldArray,$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 14:53 http://www.autoitx.com/images/common/back.gif
谢谢,在五楼已经换子循环了,与这个无关。
具体代码的作用是用来导入每天的Excel报表(列数固定/行数不固定),然后视需要在窗体内编缉,然后将编缉所得内容insert到数据库。 回复 8# drifter
不好意思,只看了一楼........... 回复 8# drifter
我承认我电脑垃圾了
E5200 +4G内存,运行你这个东东,卡了十几分钟。。动也动不了。。不解。 回复drifter
我运行了你本楼的代码,只有9961个生成~~
annybaby 发表于 2012-9-21 14:37
我换了台电脑,结果变成了9987,这到底是怎么回事呢 回复 11# drifter
我换了个3.3.7.15版的也是9987~~
原来的3.3.9.4的是9961 目测 内存溢出 双击回复了,编辑之 我顶一下,求高人解答
页:
[1]
2