2016-09-02 18 views

答えて

1

は、このやって単純な形式である:表示するSVGについて

Public Class Form1 
    Inherits Form 

    Private mZoomFactor As Short = 100 

    Private Sub InitializeComponent() 
     Me.WebBrowser1 = New System.Windows.Forms.WebBrowser() 
     Me.WebBrowser1.Dock = System.Windows.Forms.DockStyle.Fill 
     Me.Controls.Add(Me.WebBrowser1) 
    End Sub 

    Friend WithEvents WebBrowser1 As System.Windows.Forms.WebBrowser 

    Public Sub New() 
     ' This call is required by the designer. 
     InitializeComponent() 
     WebBrowser1.DocumentText = "<!DOCTYPE html><html><head><meta http-equiv=""X-UA-Compatible"" content=""IE=9""/></head><body><h1>My first SVG</h1><svg width=""100"" height=""100""> <circle cx=""50"" cy=""50"" r=""40"" stroke=""green"" stroke-width=""4"" fill=""yellow"" /> Sorry, your browser does not support inline SVG.</svg></body></html>" 
    End Sub 

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load 
     'These two statements are needed, to get the MouseWheel event when the Control key is pressed. 
     WindowState = FormWindowState.Normal 
     WebBrowser1.Focus() 
    End Sub 

    Private Sub Form1_MouseWheel(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel 
     If ModifierKeys = Keys.Control AndAlso e.Delta <> 0 Then 
      mZoomFactor += e.Delta/120 
      mZoomFactor = Math.Max(1, mZoomFactor) 
      mZoomFactor = Math.Min(1000, mZoomFactor) 
      WebBrowser1.Document.Body.Style = "zoom:" & mZoomFactor & "%" 
     End If 
    End Sub 
End Class 

を、IE9をインストールする必要がありますし、次のフラグメントは、HTMLの頭の中に含まれている必要があります

<meta http-equiv="X-UA-Compatible" content="IE=9"/> 

WebBrowserコントロールでMouseWheelイベントを取得するには、Controlキーを押したときにForm_Loadハンドラに次の2つのステートメントを含める必要があります。

WindowState = FormWindowState.Normal 
WebBrowser1.Focus() 
関連する問題