Crear Navegador Web
Codigo fuente:
Option Explicit On
Imports System.Windows.Forms
Imports System.ComponentModel
Imports System.IO
Public Class Form1
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler wb.ProgressChanged, AddressOf Loading
wb.ScriptErrorsSuppressed = True
wb.WebBrowserShortcutsEnabled = False
wb.IsWebBrowserContextMenuEnabled = True
wb.GoHome()
End Sub
Private Sub google_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles google.Click
If Not (cbserch.Text = "") Then
Navegar("http://www.google.cl/#hl=es&source=hp&q=" + (cbserch.Text) + "&meta=&aq=f&aqi=&aql=&oq=&gs_rfai=&fp=e6787d9c4fb35799")
End If
End Sub
Private Sub go_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles go.Click
If Not (cbUrl.Text = "") Then
Navegar(cbUrl.Text)
End If
End Sub
Private Sub back_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles back.Click
wb.GoBack()
End Sub
Private Sub forw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles forw.Click
wb.GoForward()
End Sub
Private Sub stp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles stp.Click
wb.Stop()
End Sub
Private Sub home_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles home.Click
wb.GoHome()
End Sub
Private Sub refr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles refr.Click
If Not (cbUrl.Text = "") Or Not wb.Url.Equals("about:blank") Then
wb.Refresh()
End If
End Sub
Private Sub Loading(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserProgressChangedEventArgs)
ProgressBar1.Maximum = e.MaximumProgress
ProgressBar1.Value = e.CurrentProgress
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
StatusLabel1.Text = wb.StatusText
End Sub
Private Sub wb_DocumentTitleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles wb.DocumentTitleChanged
If Not String.IsNullOrEmpty(wb.DocumentTitle.ToString) Then
Me.Text = wb.DocumentTitle.ToString
Else
Me.Text = "Webar"
End If
End Sub
Private Sub Navegar(ByVal cadenaUrl As String)
If String.IsNullOrEmpty(cadenaUrl) Then Return
If cadenaUrl.Equals("about:blank") Then Return
If Not cadenaUrl.StartsWith("http://") And Not cadenaUrl.StartsWith("https://") Then
cadenaUrl = "http://" & cadenaUrl
End If
Try
wb.Navigate(New Uri(cadenaUrl))
Catch Web As System.UriFormatException
Return
End Try
End Sub
Private Sub wb_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles wb.DocumentCompleted
cbUrl.Text = wb.Url.ToString
Try
Dim n As Integer
n = cbUrl.FindString(cbUrl.Text)
If (n = -1) And Not wb.Document.Url.ToString.Equals("about:blank") Then
cbUrl.Items.Add(cbUrl.Text)
End If
Catch Web As Exception
Return
End Try
End Sub
Private Sub cbUrl_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cbUrl.KeyDown
If Not (cbUrl.Text = "") Then
If (e.KeyCode = Keys.Enter) Then
Navegar(cbUrl.Text)
End If
End If
End Sub
End Class
Cd Tray :utilidad para abrir y cerrar la unidad de cd rom desde el escritorio
Codigo fuente:
Public Class Form1
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
(ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal _
uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
If Button1.Text = "Open" Then
Button1.Text = "Closed"
mciSendString("Set CDAudio Door Open Wait", vbNullString, 0, 0)
ElseIf Button1.Text = "Closed" Then
Button1.Text = "Open"
mciSendString("Set CDAudio Door Closed Wait", vbNullString, 0, 0)
End If
End Sub
End Class
Descargar proyecto:
https://rapidshare.com/files/1855074738/CD tray.rar
No hay comentarios.:
Publicar un comentario