找回密码
 加入
搜索
查看: 1703|回复: 3

根据INI文件决定选择框的内容后遇到的问题

[复制链接]
发表于 2008-10-24 10:27:13 | 显示全部楼层 |阅读模式
本人制作了一个选择框,选择框的内容是根据INI文件决定的,如图:


我现在想对选择框内的某一项进行选择,然后点击“打开目录”按键的时候,程序又根据INI里所提供的路径打开相应的文件夹。
如何解决?请高手指点!!

还有就是选择框内容是按字母顺序排列的,有什么办法让它按CONFIG.INI文件里的顺序排列在选择框内?

config.ini
---------------------------
[AUTOCAD]
目录路径=D:\Program Files\AUTOCAD2004
官方网站=www.autocad.com

[PHOTOSHOP]
目录路径=D:\Program Files\AdobePhotoshopCS3
官方网站=www.photoshop.com

[Foxmail]
目录路径=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[0]
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 编辑 ]

本帖子中包含更多资源

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

×
 楼主| 发表于 2008-10-25 08:49:41 | 显示全部楼层
没有人一帮帮我啊~ ~~~~
发表于 2008-10-25 09:50:46 | 显示全部楼层
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $Path = IniRead(@ScriptDir & "\setting.ini", GUICtrlRead($List1), "目录路径", "")
                        ShellExecute($Path)
        EndSwitch
WEnd
 楼主| 发表于 2008-10-25 12:19:31 | 显示全部楼层
谢谢提示,已经解决!
代码如下:
#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[0]
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
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-11 02:15 , Processed in 0.077476 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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