惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
博客园 - 【当耐特】
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
大猫的无限游戏
大猫的无限游戏
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
博客园 - 三生石上(FineUI控件)
Martin Fowler
Martin Fowler
云风的 BLOG
云风的 BLOG
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Fortinet All Blogs
Y
Y Combinator Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
J
Java Code Geeks
Engineering at Meta
Engineering at Meta
MyScale Blog
MyScale Blog
B
Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
人人都是产品经理
人人都是产品经理

博客园 - Dragon-China

JS实现显示倒影的图片展示特效之改变图片显示大小 转:如何用C#获得文件信息以及扩展信息 C#制作WinForm控件 InfoPath: Passing Command Line parameters to a new form Office 2003 主 Interop 程序集的安装和使用 .NET 反编译工具及其插件 Extensible OLE Property Pages in .NET COM组件设计与应用之GUID和接口 用C#创建COM对象 ActiveX and Com 一位软件工程师的6年总结本人读了深受启发,献给所有从事IT开发的人[转贴] InfoPath 的自动化和扩展 创建可绑定到 InfoPath 表单数据的 ActiveX 控件 Extending the InfoPath control set with custom controls InfoPath2007 开发人员的新增功能 在Infopath中使用自定义控件不能激发 OnPropertyChange 事件 ActiveX控件和它的容器 值得推荐的Infopath开发例子和资料 Custom Control support in InfoPath
Infopath中,自己编写的ActiveX控件,为何不能绑定数据到XML...
Dragon-China · 2007-11-07 · via 博客园 - Dragon-China

转自: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