枚举增强型图元文件从不调用回调 [英] enumerate enhanced metafile never calls callback

查看:85
本文介绍了枚举增强型图元文件从不调用回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用框架4.

           mf =新的图元文件(IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyPictures,"bagStream.emf"))
           Debug.WriteLine("Got mf ="& mf.ToString)
           Me.CreateGraphics().EnumerateMetafile(mf,New Point(20,10),New Graphics.EnumerateMetafileProc(AddressOf MetafileCallback))

            mf = New Metafile(IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyPictures, "bagStream.emf"))
            Debug.WriteLine("Got mf = " & mf.ToString)
            Me.CreateGraphics().EnumerateMetafile(mf, New Point(20, 10), New Graphics.EnumerateMetafileProc(AddressOf MetafileCallback))

  私有函数MetafileCallback(ByVal记录类型为EmfPlusRecordType,ByVal标志为整数,ByVal数据大小为整数,ByVal数据为IntPtr,ByVal回调数据为PlayRecordCallback)为布尔值
       Debug.WriteLine("在回调中,键入="& recordType.ToString)
      如果recordType = EmfPlusRecordType.Comment然后
           Debug.WriteLine(评论")
      如果结束
   结束功能

    Private Function MetafileCallback(ByVal recordType As EmfPlusRecordType, ByVal flags As Integer, ByVal dataSize As Integer, ByVal data As IntPtr, ByVal callbackData As PlayRecordCallback) As Boolean
        Debug.WriteLine("In callback, type = " & recordType.ToString)
        If recordType = EmfPlusRecordType.Comment Then
            Debug.WriteLine("Got comment")
        End If
    End Function

我知道.emf文件是有效的……它也达到调试说"Got mf = System.Drawing.Imaging.Metafile"的地步.但它永远不会触发MetafileCallback函数,不会一次.我想遍历图元文件本身,而不是创建

I know that the .emf file is valid... also it gets to the point where the debug says "Got mf = System.Drawing.Imaging.Metafile" but it never trips the MetafileCallback function, not once.  I want to walk through the metafile itself, not create an image from it, because I want to get at the comment data.

推荐答案

 我没有尝试您的代码,但是,如果您通读了

 I did not try your code but, if you read through the msdn documents on the Graphics.EnumerateMetafileProc Delegate you will see the Return Value is suppose to be True if you want to keep enumerating through the records and False if you want to stop. So, you need to return True at the end of the MetafileCallback function in order for it to keep enumerating the records.

 如果您查看msdn底部的示例 Metafile.PlayRecord 方法来调用记录的信息,或在MetafileCallback函数末尾的内容,因此,您可能需要调查一下这是什么以及什么.它是 也用了.

 If you look at the example at the bottom of the msdn Graphics.EnumerateMetafile Method you will see what i mean by returning True. Also if you read the Remarks section on that page is says something about using the Metafile.PlayRecord method for calling the records or something at the end of the MetafileCallback function so, you may want to look into seeing what that is and what it is used for too.


这篇关于枚举增强型图元文件从不调用回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆