的ActiveX初始化:AxHost.State对象 [英] ActiveX initialization: AxHost.State object
问题描述
我想用WinFormsHost控制嵌入Unity3D,ActiveX控件到WPF表格。
I'm trying to embed a Unity3D-ActiveX control into a WPF-Form by using a WinFormsHost-Control.
其实它运作良好,设置路径VS的属性窗口时,但设置它,当我在code文件时,它不会加载任何东西。这是控制的一个已知的问题,但我想我可以简单地复制的形式,设计师的创作code和手动初始化。
Actually it works well when setting the path in the property window of VS, but when setting it in my code file it does not load anything. This is a known issue of the control but i thought i can simply copy the creation code of the forms-designer and initialize it manually.
当在初始化我注意到的code看有没有的src
属性在code,但物业用于物业窗口。设置该属性手动不起作用(抛出一个错误)。
When looking at the code of the initialization i noticed that there is no src
property in the code, but the property is used in the property window. Setting the property manually does not work ( throws a error ).
在一些测试的,我决定检查钻具组合为的src
属性,但的src
属性是永远设置和我甚至找不到路径的字符串。
After some test's i decided to check the hole assembly for the src
property, but the src
property is never set and i can't even find the string of the path.
我注意到,只能有一个地方的SRC路径位于:由窗口窗体设计器生成的资源,这是的 AxHost.State 型。
I noticed that there can be only one place where the src-path is located: The resource generated by the window forms designer, which is a object of the AxHost.State-type.
我如何建立一个有效的 AxHost.State
对象初始化Unity3D,ActiveX控件应该加载指定的Unity3D文件由我?
How do i create a valid AxHost.State
object to initialize the Unity3D-ActiveX control which should load a Unity3D-file specified by me?
推荐答案
这是它的工作原理,但有一点慢(注意解决方案:你需要在窗体设计器,一旦初始化控制和OcxState对象复制到集资源):
This is the solution which works but is a little bit slow( Note: You need to initialize the Control once in the Forms Designer and copy the OcxState object into the assembly resources ):
// Create a ocx state object with the correct path
_Unity = new AxUnityWebPlayerAXLib.AxUnityWebPlayer();
((System.ComponentModel.ISupportInitialize)(_Unity)).BeginInit();
_Unity.OcxState = (AxHost.State)(Resources.Unity3DOcx);
_Unity.TabIndex = 0;
Controls.Add(_Unity);
((System.ComponentModel.ISupportInitialize)(_Unity)).EndInit();
_Unity.src = _File;
AxHost.State state = _Unity.OcxState;
_Unity.Dispose();
// Create the unity web player object
_Unity = new AxUnityWebPlayerAXLib.AxUnityWebPlayer();
((System.ComponentModel.ISupportInitialize)(_Unity)).BeginInit();
this.SuspendLayout();
_Unity.Dock = DockStyle.Fill;
_Unity.Name = "Unity";
_Unity.OcxState = state;
_Unity.TabIndex = 0;
Controls.Add(_Unity);
((System.ComponentModel.ISupportInitialize)(_Unity)).EndInit();
this.ResumeLayout(false);
这篇关于的ActiveX初始化:AxHost.State对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!