• Infopath中,自己编写的ActiveX控件,为何不能绑定数据到XML属性节点


    转自:http://www.mcse.ms/message1299834.html&highlight=InfopathControl.savestate

    I've been recently dealing with this same issue and here's the resolution
    I've come to:

    1. You can ONLY use Integers, Longs and Strings to represent your data in
    InfoPath.  I tried stdOLE.Picture, Variant, Byte() and they all won't bind by
    default (or at all after many hours of recompiling to test). Why you ask?,
    InfoPath is storing the data in an XML document file as node data
    (<node>datadatadatadata</node>). Most types of data are using illegal
    characters in this context and utf-8 or iso-8859-1 encoding won't solve the
    problem, and I'm not quite sure why.

    The simple resolution to storing ANY form of binary data is to Base64 encode
    the data and return it as a String. Just to be fair here, after talking with
    Microsoft about this using Visual Studio .NET and creating a
    custom InfoPath form with the SDK should allow for binary data, however the
    reason some of us are using ActiveX controls for data representation is
    because not everyone working with InfoPath is a programmer, which is what is
    expected when using .NET. This process is futher complicated by having to
    create custom data schemas for InfoPath in VS .NET. Again, the simple
    resolution to storing ANY form of binary data is to Base64 encode the data
    and return it as a String.

    2. Even though some of the examples lead you to believe that you can have
    your own Public Property names, InfoPath's default schema only recognizes
    ENABLED and VALUE (just as the examples show, but don't clearly state this as
    a condition), so you may have to adjust your code to expose those names, or
    use the InfoPath SDK and extend the default schema to accomodate your public
    properties, for which I haven't seen any faq's or examples.








    One more thing I forgot to mention, you must use the StrConv() function to
    convert to and from Unicode data for your string value. Again the reason for
    this is you're dealing with XML node data. See example below.


    Public Property Get Value() As String 'Needs to be called Value, data needs to be String  'Ignore all Errors or InfoPath will die an Automation Exception death
        On Error Resume Next
        Set m_oSig = New cSigControl

        If m_Signature.Handle Then 'Convert our STDOLE Picture to Base64 encoded string.'Then convert the Base64 string to UniCode and return the value.
            Value = StrConv(m_oSig.SetStreamPicture(m_Signature), vbUnicode)
        End If
        Set m_oSig = Nothing
    End Property

    Public Property Let Value(vData As String) 'Needs to be called Value, data needs to be string   'Ignore all Errors or InfoPath will die an Automation Exception death
        On Error Resume Next
        Set m_oSig = New cSigControl
    'Convert the incoming string from Unicode, then decode the Base64 encoding
    'Stream the Base64 encoding back to STDOLE Picture.
    'GetStreamPricture will return true if succussfully converted Base64
        stream to IPicture.
        If m_oSig.GetStreamPicture(StrConv(vData, vbFromUnicode)) Then
            Set m_Signature = m_oSig.UserSignature  'Double checking for validity
            If Not m_Signature Is Nothing Then
                Set UserControl.Picture = m_Signature
                Me.SignDocument = False
                PropertyChanged "Value"
            End If
        End If
        UserControl_Paint
        UserControl.Refresh
        Set m_oSig = Nothing
    End Property


  • 相关阅读:
    Windows 2003安全配置最佳方法(转)
    令人十分怨念的tomcat注册成windows服务(转)
    AMR开源编码jrtplib中与int系统重定义问题解决
    由系统熵转移的思考
    此男因为什么被送进医院?
    [转]风水师的郁闷
    飞盘奇门局例我能顺利办好护照拿到签证出国参加会议吗?
    最近工作方面发生了一些大事情,所以特地为此摇了一挂,请高手进来断一断。
    概率面前的错误
    杜新会一个精彩占例之反推
  • 原文地址:https://www.cnblogs.com/timy/p/1735265.html
Copyright © 2020-2023  润新知