简体   繁体   English

我正在使用ActiveX控件并通过msi安装它。 使用ActiveX用户控件类编写的方法正在触发,但UI不可见

[英]I am using ActiveX control and installing it by msi. The method written in ActiveX user control class are firing but UI is not visible

<object name="Form" id='Form' classid='2F76566A-964F-4547-BD48-EE498AE1A7A2' 
       codebase='ActiveXControl.cab#version=1,0,0,0'
       width="500px" height="500px" style="background-color:Blue">
</object>

<script type="text/javascript" language="javascript">
    var x = new ActiveXObject("ActiveXControl.ControlClass");
    x.UserTxt = "Aashish";
    x.password = "Rockstar";
    x.getmethod();
    alert(x.Data());
</script>

I have used object tag in Htm file and have provided the classid and codebase to my code. 我在Htm文件中使用了对象标记,并为我的代码提供了classid和代码库。 My method Data() is calling successfully but the view of my ActiveX control is not visible. 我的方法Data()成功调用,但是ActiveX控件的视图不可见。 I don't want to use Caspol.exe to fix my query 我不想使用Caspol.exe修复我的查询

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace ActiveXControl
{
    [ComVisible(true)]
    [ClassInterface(ClassInterfaceType.None)]
    [Guid("2F76566A-964F-4547-BD48-EE498AE1A7A2")]
    [ProgId("ActiveXControl.ControlClass")]
    [ComDefaultInterface(typeof(Intermediate))]
    public partial class ControlClass : UserControl, Intermediate, IObjectSafety
    {
        public ControlClass()
        {
            InitializeComponent();
        }
        public string UserTxt { get; set; }
        public string password { get; set; }

        public void getmethod()
        {
            textBox1.Text = UserTxt;
            textBox2.Text = password;
        }
        public string Data()
        {
            return textBox1.Text +" " + textBox2.Text;
        }
        public enum ObjectSafetyOptions
        {
            INTERFACESAFE_FOR_UNTRUSTED_CALLER = 0x00000001,
            INTERFACESAFE_FOR_UNTRUSTED_DATA = 0x00000002,
            INTERFACE_USES_DISPEX = 0x00000004,
            INTERFACE_USES_SECURITY_MANAGER = 0x00000008
        };

        public int GetInterfaceSafetyOptions(ref Guid riid, out int pdwSupportedOptions, out int pdwEnabledOptions)
        {
            ObjectSafetyOptions m_options = ObjectSafetyOptions.INTERFACESAFE_FOR_UNTRUSTED_CALLER | ObjectSafetyOptions.INTERFACESAFE_FOR_UNTRUSTED_DATA;
            pdwSupportedOptions = (int)m_options;
            pdwEnabledOptions = (int)m_options;
            return 0;
        }

        public int SetInterfaceSafetyOptions(ref Guid riid, int dwOptionSetMask, int dwEnabledOptions)
        {
            return 0;
        }
    }
}

This code is written in my ActiveX class where it can be clearly seen that constructor is calling the method to Initialize form object. 这段代码是用我的ActiveX类编写的,可以清楚地看到构造函数正在调用方法来初始化表单对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM