请教各位老大:tab不同分页控件的创建问题【已解决】
本帖最后由 禁忌石 于 2010-7-3 14:03 编辑在tab0的输入框中输入数字,以在tab1中建相应数量的Label,但结果建在整个gui中,不是tab1中,请教
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <GuiEdit.au3>
#include <GuiListView.au3>
#Include <GuiTab.au3>
#Include <GuiEdit.au3>
#Include <GuiComboBox.au3>
GUICreate("GUI", 600, 400)
$tab = GUICtrlCreateTab(2, 2, 596, 396)
$tab0 = GUICtrlCreateTabItem("TAB0")
GUICtrlCreateLabel("请输入数量:", 40, 40,100,20,$SS_RIGHT)
$minhand=GUICtrlCreateInput("", 150, 35, 200, 20)
$tab1OK = GUICtrlCreateButton("确定", 220, 100,80, 50)
$tab1 = GUICtrlCreateTabItem("TAB1")
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
EXIT
Case $msg=$tab1OK
For $i=1 to _GUICtrlEdit_GetText($minhand)
GUICtrlCreateLabel("Label "&$i, 40, 40+20*$i)
Next
EndSelect
WEnd #include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <GuiEdit.au3>
#include <GuiListView.au3>
#Include <GuiTab.au3>
#Include <GuiEdit.au3>
#Include <GuiComboBox.au3>
GUICreate("GUI", 600, 400)
$tab = GUICtrlCreateTab(2, 2, 596, 396)
$tab0 = GUICtrlCreateTabItem("TAB0")
GUICtrlCreateLabel("请输入数量:", 40, 40,100,20,$SS_RIGHT)
$minhand=GUICtrlCreateInput("", 150, 35, 200, 20)
$tab1OK = GUICtrlCreateButton("确定", 220, 100,80, 50)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
EXIT
Case $msg=$tab1OK
$tab1 = GUICtrlCreateTabItem("TAB1")
For $i=1 to _GUICtrlEdit_GetText($minhand)
GUICtrlCreateLabel("Label "&$i, 40, 40+20*$i)
Next
EndSelect
WEnd
不是很完美 本帖最后由 afan 于 2010-6-27 01:24 编辑
换个角度看问题GUICreate("GUI", 600, 400)
$tab = GUICtrlCreateTab(2, 2, 596, 396)
$tab0 = GUICtrlCreateTabItem("TAB0")
GUICtrlCreateLabel("请输入数量:", 40, 40, 100, 20);, $SS_RIGHT)
$minhand = GUICtrlCreateInput("", 150, 35, 200, 20)
$tab1OK = GUICtrlCreateButton("确定", 220, 100, 80, 50)
$tab1 = GUICtrlCreateTabItem("TAB1")
Dim $Label
For $i = 1 To 20 ;你准备如何自动生成Label可在此先创建出来
$Label[$i] = GUICtrlCreateLabel("Label " & $i, 40, 20 + 17 * $i)
GUICtrlSetState(-1, 32)
Next
GUICtrlCreateTabItem("")
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = -3
Exit
Case $msg = $tab1OK
$zs = GUICtrlRead($minhand)
If $zs > 20 Then MsgBox(0, 0, '限制最多设置20,多出部分将无效')
For $i = 1 To 20
If $i <= $zs Then GUICtrlSetState($Label[$i], 16)
If $i > $zs Then GUICtrlSetState($Label[$i], 32)
Next
EndSelect
WEnd 谢谢上面两位,
这两种方法都不错,但的确不完美
不过还是相当的感谢
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <GuiTab.au3>
#include <GuiEdit.au3>
Dim $laber, $labernumber
$hWin = GUICreate("tab不同分页控件的创建问题", 600, 400)
$tab = GUICtrlCreateTab(2, 2, 596, 396)
$tab0 = GUICtrlCreateTabItem("TAB0")
GUICtrlCreateLabel("请输入数量:", 40, 40, 100, 20, $SS_RIGHT)
$minhand = GUICtrlCreateInput("", 150, 35, 200, 20)
$tab1OK = GUICtrlCreateButton("确定", 220, 100, 80, 50)
$tab1 = GUICtrlCreateTabItem("TAB1")
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $tab1OK
For $n = 1 To $labernumber
GUICtrlDelete($laber[$n])
Next
For $i = 1 To _GUICtrlEdit_GetText($minhand)
GUISwitch($hWin, $tab1)
$laber[$i] = GUICtrlCreateLabel("Label " & $i, 40, 40 + 20 * $i)
GUICtrlCreateTabItem("")
$labernumber = $i
Next
EndSelect
WEnd
函数参考
GUICtrlCreateTabItem
注意/说明
...
要创建一个新的控件到一个存在的标签项目上,使用 GUISwitch($hWin,$tabitem) 选择标签并创建您的新控件. 别忘了使用 GUICtrlCreateTabItem("") 关闭标签项目. 函数参考
GUICtrlCreateTabItem
注意/说明
...
要创建一个新的控件到一个存在的标签项目上,使 ...
lynfr8 发表于 2010-6-28 01:10 http://www.autoitx.com/images/common/back.gif
学习了,不知道GUISwitch还有这个用法~~
28行的 GUICtrlCreateTabItem("") 移到 30行的 next 后会更完美,不会频繁刷新~ 看来又学会一招了!!!{:face (303):} 谢谢lynfr8,这正是我想要的,谢谢 thank you very much
页:
[1]