Sonntag, 3. Februar 2008

Zooming in the old COM Webbrowser Control

You may use the traditional COM Webbrowser Control for cetain reasons. How is the zoom changed in this Control?

It is NOT like in the managed Version of the HTMLDocument.

Dim Zoomlevel As Integer = 100



Private Sub WebBrowser_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles WebBrowser.PreviewKeyDown
If e.Control = True AndAlso e.KeyCode = Keys.Subtract Then
Zoomlevel *= 0.95
Me.Browserinfoobj.HTMLDocument.body.style.setAttribute("zoom", Zoomlevel & "%")
ElseIf e.Control = True AndAlso e.KeyCode = Keys.Add Then
Zoomlevel /= 0.95
Me.Browserinfoobj.HTMLDocument.body.style.setAttribute("zoom", Zoomlevel & "%")
ElseIf e.Control = True AndAlso e.KeyCode = Keys.NumPad0 Then
Zoomlevel = 100
Me.Browserinfoobj.HTMLDocument.body.style.setAttribute("zoom", Zoomlevel & "%")
End If
End Sub


 



 



 

Keine Kommentare: