bbip 发表于 2009-6-21 17:33:40

想做一个不确定有多少个按钮的小选单,有没有高手给个提示

像图中那样,按钮的信息通过INI文件读取,我可以通过iniReadSection函数获取INI文件的所有信息并通过UBound函数来得到到底有几个按钮但是在gui输出上面却不知道如何下手 请高手指教一下 谢谢

bbip 发表于 2009-6-21 17:43:24

附上INI文件


name1=正常启动劲舞团
run1=d:\窗口化.exe

name2=NT兼容模式启动
run2=d:\paly1.bat

name3=2000兼容模式启动
run3=d:\play2.bat

name4=98兼容模式启动
run4=d:\play3.bat

大绯狼 发表于 2009-6-21 18:42:05

本帖最后由 大绯狼 于 2009-6-21 18:59 编辑

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
Dim $Button
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 198, 447, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "main")

$i = 0
While 1
      $i += 1
      ReDim $Button[$i]
      $temp = IniRead("txt.txt", "list", "name" & $i, "")
      If $temp = "" Then ExitLoop
      $Button[$i - 1] = GUICtrlCreateButton($temp, 48, 18 + $i * 30, 120, 25, 0)

      GUICtrlSetOnEvent($Button[$i - 1], "main")
WEnd
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
      Sleep(100)
WEnd

Func main()
      For $i = 1 To UBound($Button)
                Switch @GUI_CtrlId
                        Case $GUI_EVENT_CLOSE
                              Exit
                        Case $Button[$i-1]
                              MsgBox(0, "", IniRead("txt.txt", "list", "run" & $i, ""))
                EndSwitch
      Next
EndFunc   ;==>main

78391493 发表于 2009-6-22 11:11:02

读按钮数量 每增加一个自增高度

bbip 发表于 2009-6-24 09:59:00

感谢二楼提供的思路 我先试试看吧 谢谢了
页: [1]
查看完整版本: 想做一个不确定有多少个按钮的小选单,有没有高手给个提示