Salve a tutti sciaxini!
Molti chiedevano come fare lo zoom nei browser e allora scrivo questa guida... però e solo per WebBrowser (Gecko e WebKit non lo so)
INIZIAMO!!
1.Aggiungere 1 Trackbar e 11 Label
2. Sotto Public Class Form1 inserite:
3. Inserite questo codice nella Trackbar:
4.Rinominate i link label così:
12% 25% 50% 75% 100% 125% 150% 175% 200% 225% e 250%
Link label 12% codice:
Link label 25% codice:
Per le altre link label cambiate il codice:
con la percentuale del label...
Esempio:
E così via ;) Grazie!
Fonte: Altro Forum
Molti chiedevano come fare lo zoom nei browser e allora scrivo questa guida... però e solo per WebBrowser (Gecko e WebKit non lo so)
INIZIAMO!!
1.Aggiungere 1 Trackbar e 11 Label
2. Sotto Public Class Form1 inserite:
Private Enum Exec
OLECMDID_OPTICAL_ZOOM = 63
End Enum
Private Enum ExecOpt
OLECMDEXECOPT_DODEFAULT = 0
OLECMDEXECOPT_PROMPTUSER = 1
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_SHOWHELP = 3
End Enum
OLECMDID_OPTICAL_ZOOM = 63
End Enum
Private Enum ExecOpt
OLECMDEXECOPT_DODEFAULT = 0
OLECMDEXECOPT_PROMPTUSER = 1
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_SHOWHELP = 3
End Enum
3. Inserite questo codice nella Trackbar:
If TrackBar1.Value = 0 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 12, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 1 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 25, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 2 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 50, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 3 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 75, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 4 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 100, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 5 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 125, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 6 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 150, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 7 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 175, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 8 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 200, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 9 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 225, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 10 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 250, IntPtr.Zero)
Catch ex As Exception
End Try
End If
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 12, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 1 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 25, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 2 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 50, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 3 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 75, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 4 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 100, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 5 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 125, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 6 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 150, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 7 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 175, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 8 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 200, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 9 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 225, IntPtr.Zero)
Catch ex As Exception
End Try
ElseIf TrackBar1.Value = 10 Then
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 250, IntPtr.Zero)
Catch ex As Exception
End Try
End If
4.Rinominate i link label così:
12% 25% 50% 75% 100% 125% 150% 175% 200% 225% e 250%
Link label 12% codice:
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 12, IntPtr.Zero)
Catch ex As Exception
End Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 12, IntPtr.Zero)
Catch ex As Exception
End Try
Link label 25% codice:
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 25, IntPtr.Zero)
Catch ex As Exception
End Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 25, IntPtr.Zero)
Catch ex As Exception
End Try
Per le altre link label cambiate il codice:
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 25, IntPtr.Zero)
Esempio:
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 50, IntPtr.Zero)
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 75, IntPtr.Zero)
ExecOpt.OLECMDEXECOPT_PROMPTUSER, 100, IntPtr.Zero)
Fonte: Altro Forum
Ultima modifica: