找回密码
 加入
搜索
查看: 2301|回复: 7

[AU3基础] [已解决]FileOpenDialog点击取消之后如何返回原窗口

  [复制链接]
发表于 2010-5-12 10:32:30 | 显示全部楼层 |阅读模式
本帖最后由 lancaogen1999 于 2010-5-12 10:37 编辑

如下代码中,怎样在打开选择文件的窗口后点取消返回form1重新选择,而不是退出,请高手指教。
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 259, 217, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 72, 72, 113, 57)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $var = FileOpenDialog("打开", @DesktopDir & "", "文本文件(*.txt)", 2)
                        If @error Then
                                ExitLoop
                        EndIf
        EndSwitch
WEnd

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-5-12 10:34:20 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 259, 217, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 72, 72, 113, 57)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $var = FileOpenDialog("打开", @DesktopDir & "", "文本文件(*.txt)", 2)
                        If @error Then ContinueLoop
        EndSwitch
WEnd
 楼主| 发表于 2010-5-12 10:36:56 | 显示全部楼层
哦,这么简单啊 ,谢谢啦,不过我好像发错版了,不过现在对了,呵呵
发表于 2010-5-12 12:57:43 | 显示全部楼层
谢谢afan,学习了.另外问一下如何控制FileOpenDialog弹出的窗口居中.
发表于 2010-5-12 13:09:15 | 显示全部楼层
回复 4# dulein


    上面的第16行改为
$var = FileOpenDialog("打开", @DesktopDir & "", "文本文件(*.txt)", 2, '', $Form1)

即加入父窗口句柄,更实用~
发表于 2010-5-16 09:38:57 | 显示全部楼层
感激不尽.Thank You afan !!!
 楼主| 发表于 2010-5-20 09:11:37 | 显示全部楼层
谢谢各位支持!
发表于 2010-12-30 17:45:16 | 显示全部楼层
太感谢了,又学习一招
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-2 18:30 , Processed in 0.080341 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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