我每20秒呼叫我的页面一次,但是当我呼叫我的页面时,我看到了闪光。页面加载时是否可以避免闪烁?
Private Sub WebBrowser1_load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate(New Uri("http://metalrockpopradio.caramania.com/tuneefy4.php"))
Dim timer As New Timer()
timer.Interval = 20000
AddHandler timer.Tick, AddressOf WebBrowser1.Refresh
timer.Start()
答案 0 :(得分:0)
有两个。新的重新加载完成后,显示新的控件并隐藏旧的控件。
或者,在页面上使用AJAX或类似内容重新加载内容。
答案 1 :(得分:0)
您可以执行以下操作:
Form1
)PictureBox1
)SizeMode = Zoom
Imports System.Net
Imports System.Windows.Forms
Public Class Form1
Dim timer As System.Windows.Forms.Timer
Private client As WebClient = New WebClient()
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
RefreshImage(Nothing, Nothing)
timer = New System.Windows.Forms.Timer()
AddHandler timer.Tick, AddressOf Me.RefreshImage
timer.Interval = 5000
timer.Start()
End Sub
Protected Sub RefreshImage(sender As Object, e As EventArgs)
Dim HttpResource As String = client.DownloadString("http://metalrockpopradio.caramania.com/tuneefy4.php")
Dim ParseStart As Integer = HttpResource.IndexOf("=") + 2
HttpResource = HttpResource.Substring(ParseStart, HttpResource.LastIndexOf(ChrW(34)) - ParseStart)
If PictureBox1.Image IsNot Nothing Then PictureBox1.Image.Dispose()
PictureBox1.Load(HttpResource)
End Sub
Private Sub Form1_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
client.Dispose()
timer.Dispose()
End Sub
End Class