根据INI文件决定选择框的内容后遇到的问题
本人制作了一个选择框,选择框的内容是根据INI文件决定的,如图:我现在想对选择框内的某一项进行选择,然后点击“打开目录”按键的时候,程序又根据INI里所提供的路径打开相应的文件夹。
如何解决?请高手指点!!
还有就是选择框内容是按字母顺序排列的,有什么办法让它按CONFIG.INI文件里的顺序排列在选择框内?
config.ini
---------------------------
目录路径=D:\Program Files\AUTOCAD2004
官方网站=www.autocad.com
目录路径=D:\Program Files\AdobePhotoshopCS3
官方网站=www.photoshop.com
目录路径=D:\Program Files\Foxmail
官方网站=www.foxmail.com.cn
[快速批处理文件编译器]
D:\Program Files\Quick Batch File (De)Compiler
官方网站=www.quick.com.cn
-------------------------------------------
代码:
--------------------------------------------
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListBoxConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 566, 404, 193, 125)
$List1 = GUICtrlCreateList("", 40, 48, 345, 266)
GUICtrlSetFont(-1, 11, 400, 0, "幼圆")
$Group1 = GUICtrlCreateGroup("列表(请选择)", 8, 24, 545, 345)
GUICtrlSetFont(-1, 10, 400, 0, "幼圆")
$Button1 = GUICtrlCreateButton("进入目录", 400, 64, 129, 33, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$var = IniReadSectionNames(@ScriptDir & "\config.ini")
For $i = 1 To $var
FileWrite("dir.txt", $var[$i] & @CRLF)
Next
For $i = 1 To 65535
$string = FileReadLine("dir.txt", $i)
If @error Then ExitLoop
If @error = 0 Then GUICtrlSetData($List1, $string)
Next
FileDelete("dir.txt")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$Path = IniRead(@ScriptDir & "\setting.ini", $var[$i], "目录路径", "")
ShellExecute ($Path)
EndSwitch
WEnd
-------------------------------------------------------------
源码打包:
[ 本帖最后由 charson 于 2008-11-1 11:44 编辑 ] 没有人一帮帮我啊~ ~~~~
:face (18): :face (18): While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$Path = IniRead(@ScriptDir & "\setting.ini", GUICtrlRead($List1), "目录路径", "")
ShellExecute($Path)
EndSwitch
WEnd 谢谢提示,已经解决!
代码如下:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListBoxConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 566, 404, 193, 125)
$List1 = GUICtrlCreateList("", 40, 48, 345, 266)
GUICtrlSetFont(-1, 11, 400, 0, "幼圆")
$Group1 = GUICtrlCreateGroup("列表(请选择)", 8, 24, 545, 345)
GUICtrlSetFont(-1, 10, 400, 0, "幼圆")
$Button1 = GUICtrlCreateButton("进入目录", 400, 64, 129, 33, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$var = IniReadSectionNames(@ScriptDir & "\config.ini")
For $i = 1 To $var
FileWrite("dir.txt", $var[$i] & @CRLF)
Next
For $i = 1 To 65535
$string = FileReadLine("dir.txt", $i)
If @error Then ExitLoop
If @error = 0 Then GUICtrlSetData($List1, $string)
Next
FileDelete("dir.txt")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$a=GUICtrlRead($List1)
$b=IniRead(@ScriptDir & "\config.ini",$a,"目录路径","")
ShellExecute ($b)
EndSwitch
WEnd
页:
[1]