Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class EnumerateMetafileProc
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
public class Form1
Inherits System.Windows.Forms.Form
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim g As Graphics = Me.CreateGraphics()
g.Clear(Me.BackColor)
Dim curMetafile As New Metafile("mtfile.wmf")
Dim enumMetaCB1 As New Graphics.EnumerateMetafileProc(AddressOf EnumMetaCB)
g.EnumerateMetafile(curMetafile, New Point(0, 0), EnumMetaCB1)
curMetafile.Dispose()
g.Dispose()
End Sub
Private Function EnumMetaCB(ByVal recordType As EmfPlusRecordType, ByVal flags As Integer, ByVal dataSize As Integer, ByVal data As IntPtr, ByVal callbackData As PlayRecordCallback) As Boolean '
Dim str As String = ""
' Play only EmfPlusRecordType.FillEllipse records.
If recordType = EmfPlusRecordType.FillEllipse Or recordType = EmfPlusRecordType.FillRects Or recordType = EmfPlusRecordType.DrawEllipse Or recordType = EmfPlusRecordType.DrawRects Then
str = "Record type:" + recordType.ToString() + ", Flags:" + flags.ToString() + ", DataSize:" + dataSize.ToString() + ", Data:" + data.ToString()
MessageBox.Show(str)
End If
Return True
End Function 'EnumMetaCB
Public Sub New()
MyBase.New()
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
End Sub
End Class
|