|
本帖最后由 ditser 于 2010-10-13 09:51 编辑
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>
Opt('MustDeclareVars', 1)
open();声明方法
; 示例 1
Func open()
Local $msg,$Form1,$menu_A,$menu_A_A,$menu_A_B,$menu_A_C,$menu_A_D,$menu_B,$menu_B_A,$menu_B_B,$menu_B_C,$menu_B_D,$menu_c,$menu_c_a,$Button_a
Local $treeview,$filels,$at,$startlabel
Local $infobutton
Local $msg, $item, $hItem, $text
Local $views
;从配置文件中读出值
$views = IniRead("softset.ini","views","views","");读取文件数
Local $filedir[$views],$filedes[$views],$sunfilels[$views],$description[$views]
For $i = 0 to $views-1 Step 1
$filedir[$i]=IniRead("softset.ini",$i,"filedir","")
$filedes[$i]=IniRead("softset.ini",$i,"filedes","")
Next
#cs
$msg = GUIGetMsg()
MsgBox(6,"11",$filedir[0],10)
MsgBox(6,"11",$filedes[0],10)
#ce
$Form1 = GUICreate("GUI例子", 720, 550, -1, -1, $WS_OVERLAPPEDWINDOW);创建一个 GUI 窗口
GUISetIcon("favicon.ico", 0);设置窗口图标
GUISetState(@SW_SHOW) ; 显示窗口
;创建菜单控件
;一级菜单控件
$menu_A = GUICtrlCreateMenu("文件")
$menu_B = GUICtrlCreateMenu("编辑")
$menu_c = GUICtrlCreateMenu("关于")
;二级菜单控件
$menu_A_A = GUICtrlCreateMenuItem("打开", $menu_A)
$menu_A_B = GUICtrlCreateMenuItem("关闭", $menu_A)
$menu_A_B = GUICtrlCreateMenuItem("保存", $menu_A)
$menu_A_D = GUICtrlCreateMenuItem("另存为", $menu_A)
$menu_B_A = GUICtrlCreateMenuItem("全选",$menu_B)
$menu_B_B = GUICtrlCreateMenuItem("剪切",$menu_B)
$menu_B_C = GUICtrlCreateMenuItem("复制",$menu_B)
$menu_B_D = GUICtrlCreateMenuItem("粘贴",$menu_B)
$menu_C_A = GUICtrlCreateMenuItem("版本",$menu_c)
;创建树形目录的容器,指定其样式
$treeview = GUICtrlCreateTreeView(6, 6, 200, 520, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
;在树形目录框中创建菜单
$filels = GUICtrlCreateTreeViewItem("文件列表", $treeview)
$at = GUICtrlCreateTreeViewItem("其他说明", $treeview)
;文件列表 子菜单
For $i = 0 to $views-1 Step 1
$sunfilels[$i] = GUICtrlCreateTreeViewItem($filedir[$i], $filels)
Next
$startlabel = GUICtrlCreateLabel("TreeView Demo", 220, 12, 490, 490, $SS_SUNKEN)
For $i = 0 to $views-1 Step 1
$description[$i] = GUICtrlCreateLabel($filedes[$i], 220, 12, 490, 490, $SS_SUNKEN)
;GUICtrlSetState(-1, $GUI_HIDE) ; 在初始化期间隐藏"关于..."文本
Next
$infobutton = GUICtrlCreateButton("修改", 490, 505, 70, 20)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $menu_c_a
MsgBox(266304, "版本", "版本:初始版(1.0)")
Case $msg = $infobutton
$item = GUICtrlRead($treeview) ; 获取当前挑选的 treeview 项目的控件ID
If $item = 0 Then
MsgBox(64, "TreeView 演示", "现在没有选择项目")
Else
$text = GUICtrlRead($item, 1) ; 获取 treeview 项目的文本
If $text == "" Then
MsgBox(16, "Error", "当取回关于项目信息时发生错误")
Else
;MsgBox(64, "",$text) ; $advmsg[0] 包含文本 and $advmsg[1] 包含 treeview 项目的状态数值
Run("E:\tools\开发工具\EditPlus 3\EditPlus.exe " & $text)
EndIf
EndIf
EndSelect
For $i = 0 to $views-1 Step 1
GUICtrlSetState($description[$i], $GUI_HIDE)
If $msg = $sunfilels[$i] Then
GUICtrlSetState($description[$i], $GUI_show)
Else
GUICtrlSetState($description[$i], $GUI_HIDE)
EndIf
Next
WEnd
GUIDelete()
EndFunc ;==>open
以上是所有代码,想实现效果创建一个GUI 然后从ini文件中读取个树形目录名称,其中每个栏目中对应一个label ,单击每个项目时显示对应label
遇到的问题: label不停的循环显示。
请高人解答,小弟不胜感激! |
|