|
本帖最后由 eaglelin 于 2011-12-19 13:46 编辑
Func LnkDiy($mainwin)
Local $msg,$var
Global $DIY[40]
Global $Button1 = ""
Global $Button2 = ""
Global $mains = ""
Global $AppDir = @AppDataDir & "\NtvTools"
$mains = GUICreate("用户应用管理", 642, 430, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU), -1)
........
$exitbutton = GUICtrlCreateButton("退出面板", 540, 380, 70, 30)
$helpbutton = GUICtrlCreateButton("查看帮助", 540, 340, 70, 30)
For $i = 0 To 39 Step 1
$button_name = IniRead("NTVtools.ini", "UserDIY", "Button" & $i, "")
If $button_name = "" Then
ContinueLoop
EndIf
$tip_line = IniRead("NTVtools.ini", "UserDIY", "Tip" & $i, "")
$Button_x = 20 + Mod($i - 1, 4) * 155
$Button_y = 20 + Int(($i - 1) / 4) * 30
GUICTRLDelete($DIY[$i])
$DIY[$i] = CreateCursorLabel($button_name, $Button_x, $Button_y, 140, 20, 10, 400, 4, "ALL", "")
Next
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $addbutton
For $i = 0 To 39 Step 1
If (IniRead(@ScriptDir & "\NTVtools.ini", "UserDIY", "Button" & $i, "")) = "" Then
ExitLoop
EndIf
Next
If (GUICtrlRead($button_n) <> "") Then
$i = GUICtrlRead($button_n)
EndIf
IniWrite(@ScriptDir & "\NTVtools.ini", "UserDIY", "Button" & $i, GUICtrlRead($button_name))
IniWrite(@ScriptDir & "\NTVtools.ini", "UserDIY", "Commander" & $i, GUICtrlRead($command_file))
IniWrite(@ScriptDir & "\NTVtools.ini", "UserDIY", "Tip" & $i, GUICtrlRead($tip_line))
MsgBox(64, "提示", "按钮 '" & GUICtrlRead($button_name) & "' 已经添加!重启本工具生效")
list()
Case $msg = $DIY[0]
$command_line = IniRead("NTVtools.ini", "UserDIY", "Commander0", "")
If $command_line <> "" Then
ShellExecute($command_line, "", _getdir($command_line))
EndIf
Case $msg = $DIY[1]
$command_line = IniRead("NTVtools.ini", "UserDIY", "Commander1", "")
If $command_line <> "" Then
ShellExecute($command_line, "", _getdir($command_line))
EndIf
..........................................................
Case $msg = $GUI_EVENT_CLOSE
GUIDelete($mains)
Return
Case $msg = $exitbutton
GUIDelete($mains)
Return
EndSelect
WEnd
EndFunc ;==>LnkDiy
Func list()
For $i = 0 To 39 Step 1
$button_name = IniRead("NTVtools.ini", "UserDIY", "Button" & $i, "")
If $button_name = "" Then
ContinueLoop
EndIf
$tip_line = IniRead("NTVtools.ini", "UserDIY", "Tip" & $i, "")
$Button_x = 20 + Mod($i - 1, 4) * 155
$Button_y = 20 + Int(($i - 1) / 4) * 30
GUICTRLDelete($DIY[$i])
$DIY[$i] = CreateCursorLabel($button_name, $Button_x, $Button_y, 140, 20, 10, 400, 4, "ALL", "")
Next
GUISetState()
EndFunc ;==>list
我在这个子程序里面建立的一系列 $DIY 控件 我用GUICTRLDelete($DIY[$i])删掉 再重建 因为控件增加了或者删除了 。但是画面上看不见我新建的控件,而且空白的画面好像也失效了。
我也搞不清楚怎么回事!
另:我发现要是在GUI上临时增加一个控件 点击这个控件无效 需要重启软件才可以 |
|