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

一个GUI的按钮切换问题

[复制链接]
发表于 2009-8-29 10:29:35 | 显示全部楼层 |阅读模式
本帖最后由 lvsea2008 于 2009-8-30 11:20 编辑

自己学编写一个GUI,但是现在有个问题,点了第一个按钮后,想换个,比如点第2个按钮就没有用,那个网页不能出来代码如下,因播放地址还没找到暂时用hao123来替代!
请指正下谢谢!
#include <GUIConstants.au3>
GUICreate("轻松一刻",500,380,194,116,-1,-1,WinGetHandle(AutoItWinGetTitle()))
GUISetState ()
$b1 = GUICtrlCreateButton ("视听享受", 0,0,61,30)
$b2 = GUICtrlCreateButton ("网络电视1",61,0,61,30)
$b3 = GUICtrlCreateButton ("网络电视2",122,0,61,30)
$b4 = GUICtrlCreateButton ("网址大全",183,0,61,30)

While 1
$msg = GUIGetMsg()
If $msg = $b1 Then
GUISetState(@SW_SHOW)
$os = ObjCreate("Shell.Explorer.2")
$GUIActiveX= GUICtrlCreateObj($os, 0,0 ,300,500)
$os.navigate("http://www.hao123.com/")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
EndIf
If $msg = $b2 Then
GUISetState(@SW_SHOW)
$oIE = ObjCreate("Shell.Explorer.2")
$GUIActiveX= GUICtrlCreateObj( $oIE,-2,-3,500,375 )
$oIE.navigate("http://www.baidu.com/")
While 1
    $msg = GUIGetMsg()
   
        Select
                Case $msg = $GUI_EVENT_CLOSE
                        ExitLoop
        EndSelect
Wend
EndIf
If $msg = $b3 Then
$oIE = ObjCreate("Shell.Explorer.2")
$GUIActiveX= GUICtrlCreateObj( $oIE,-2,-3,500,375 )
GUISetState ()       ;Show GUI
$oIE.navigate("http://www.163.com/")
While 1
    $msg = GUIGetMsg()
   
        Select
                Case $msg = $GUI_EVENT_CLOSE
                        ExitLoop
        EndSelect
Wend
EndIf
If $msg = $b4 Then
$url = "http://www.hao123.com/"
Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe -new " & $url)
EndIf
wend
发表于 2009-8-29 10:40:03 | 显示全部楼层
[au3]#include <GUIConstants.au3>
GUICreate("轻松一刻", 500, 380, 194, 116, -1, -1, WinGetHandle(AutoItWinGetTitle()))
GUISetState()
$b1 = GUICtrlCreateButton("视听享受", 0, 0, 61, 30)
$b2 = GUICtrlCreateButton("网络电视1", 61, 0, 61, 30)
$b3 = GUICtrlCreateButton("网络电视2", 122, 0, 61, 30)
$b4 = GUICtrlCreateButton("网址大全", 183, 0, 61, 30)

While 1
        $msg = GUIGetMsg()
        Switch $msg
                Case $b1
                        $os = ObjCreate("Shell.Explorer.2")
                        $GUIActiveX = GUICtrlCreateObj($os, 0, 30, 500, 375)
                        $os.navigate("about:blank")

                Case $b2
                        $oIE = ObjCreate("Shell.Explorer.2")
                        $GUIActiveX = GUICtrlCreateObj($oIE, 0, 30, 500, 375)
                        $oIE.navigate("http://www.baidu.com/")

                Case $b3
                        $oIE = ObjCreate("Shell.Explorer.2")
                        $GUIActiveX = GUICtrlCreateObj($oIE, 0, 30, 500, 375)
                        GUISetState() ;Show GUI
                        $oIE.navigate("http://www.163.com/")
                Case $b4
                        $url = "http://www.hao123.com/"
                        Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe -new " & $url)
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd[/au3]
 楼主| 发表于 2009-8-29 10:49:55 | 显示全部楼层
非常感谢
受教
 楼主| 发表于 2009-8-29 10:55:45 | 显示全部楼层
老大上面的代码再修改下呢
测试下发现如先点第一个按钮后打开页面,然后再点第二个按钮后显示出页面,但是第一个按钮显示的页面仍在显示,只是被他给压住了,如何消除呢,如果重复点第二个按钮那么会重复显示很多这个页面!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-7 12:54 , Processed in 0.071863 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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