一个GUI的按钮切换问题
本帖最后由 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 #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 非常感谢
受教 老大上面的代码再修改下呢
测试下发现如先点第一个按钮后打开页面,然后再点第二个按钮后显示出页面,但是第一个按钮显示的页面仍在显示,只是被他给压住了,如何消除呢,如果重复点第二个按钮那么会重复显示很多这个页面!
页:
[1]