找回密码
 加入
搜索
查看: 1677|回复: 6

关于第二个FORM问题

[复制链接]
发表于 2008-10-25 12:34:09 | 显示全部楼层 |阅读模式
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("test", 303, 339, 321, 178)
$ListView1 = GUICtrlCreateListView("键值 |值", 0, 8, 289, 273)
$button = GUICtrlCreateButton("Yes", 25, 290, 80, 40)
$delete = GUICtrlCreateButton("删除", 115, 290, 80, 40)
$add = GUICtrlCreateButton("添加", 205, 290, 80, 40)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                                Case $button
                                                ;Exit
                Case $delete
                        ;del()
                                Case $add
                                                add()
        EndSwitch
WEnd
       
Func add()
$Form1 = GUICreate("添加注册表启动项目", 215, 110, 309, 283)
$Label1 = GUICtrlCreateLabel("注册表项", 8, 20, 52, 17)
GUICtrlCreateInput("", 64, 16, 137, 21)
$Label2 = GUICtrlCreateLabel("项    值", 8, 45, 52, 17)
GUICtrlCreateInput("", 64, 40, 137, 21)
$Button1 = GUICtrlCreateButton("确定", 48, 80, 75, 25, 0)
$Button2 = GUICtrlCreateButton("取消", 136, 80, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                                Exit
                Case $Button2
                                Exit
        EndSwitch
WEnd
EndFunc
请问点击$add出来的窗体,点关闭就把整个程序都退出了?我是想关闭点击出来的窗体,而不关闭主窗体。
如何设置$ListView1 = GUICtrlCreateListView("键值|值", 0, 8, 289, 273)"值"的宽度?_GUICtrlListView_SetColumnWidth($ListView1, 0, 75)这个可以设置"键值"的宽度。

[ 本帖最后由 xg911335 于 2008-10-26 16:33 编辑 ]
发表于 2008-10-25 13:59:46 | 显示全部楼层
GUIDelete()
 楼主| 发表于 2008-10-26 11:08:48 | 显示全部楼层
$Form1 = GUICreate("test", 303, 339, 321, 178)
$ListView1 = GUICtrlCreateListView("键值 |值", 0, 8, 289, 273)
$button = GUICtrlCreateButton("Yes", 25, 290, 80, 40)
$delete = GUICtrlCreateButton("删除", 115, 290, 80, 40)
$add = GUICtrlCreateButton("添加", 205, 290, 80, 40)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        GUIDelete($Form1);;;;;;;;;;;;;;;;怎么这个关闭不了??
                                Case $button
                                                ;Exit
                Case $delete
                        ;del()
                                Case $add
                                                add()
        EndSwitch
WEnd
        
Func add()
$Form2 = GUICreate("添加注册表启动项目", 215, 110, 309, 283)
$Label1 = GUICtrlCreateLabel("注册表项", 8, 20, 52, 17)
GUICtrlCreateInput("", 64, 16, 137, 21)
$Label2 = GUICtrlCreateLabel("项    值", 8, 45, 52, 17)
GUICtrlCreateInput("", 64, 40, 137, 21)
$Button1 = GUICtrlCreateButton("确定", 48, 80, 75, 25, 0)
$Button2 = GUICtrlCreateButton("取消", 136, 80, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                                GUIDelete($Form2);;;;;;;;;;;;;;;;;;;这里也有一个
                Case $Button2
                                Exit
        EndSwitch
WEnd
EndFunc
GUIDelete($Form1);;;;;;;;;;;;;;;;怎么这个关闭不了??

[ 本帖最后由 xg911335 于 2008-10-26 11:55 编辑 ]
发表于 2008-10-26 12:31:09 | 显示全部楼层
交换一下句柄,要关闭子窗体时,必须先激活主窗体,先把焦点转到主窗体上
 楼主| 发表于 2008-10-26 14:01:28 | 显示全部楼层
不好意思。我不是太理解。能给出代码吧。看代码比较容易理解。谢谢。
发表于 2008-10-26 14:23:10 | 显示全部楼层
guiswitch($form1)
guidelete($form2)
guisetstate(-1,@gui_show)
记得不是很清楚,大概如此吧
还有,如果你要用case $nmsg的话,这么用不行,一定要带参数,$nMsg(1),否则程序自己判断不出来,你的这个nmsg是哪个界面上的

[ 本帖最后由 netegg 于 2008-10-26 14:32 编辑 ]
 楼主| 发表于 2008-10-26 16:33:02 | 显示全部楼层
GUISetState(@SW_HIDE, $Form2)
GUISetState(@SW_ENABLE, $Form1)
WinActivate("test")
谢谢。问题已解决。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-10 17:01 , Processed in 0.105602 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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