向COM公开Form类方法 [英] Exposing Form class methods to COM

查看:71
本文介绍了向COM公开Form类方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C#和C系列语言的新手.我想知道如何展示Show()& Hide()从Form类转换为COM.目前,我有一个接口和一个继承Form和此接口的类.更具体地说,如何实现Show()& Hide()?我知道该如何做Property1,因为它是我的财产,但是Show()& Hide()来自Form类,我不知道在哪里或如何实现它.提前谢谢.

---------------------------

[GuidAttribute("3C1565B0-29B8-448e-B7AD-D36362989640")]

Hi, I'm new to C# and the C family languages.  I would like to know how I can expose the Show() & Hide() from the Form class to COM.  Currently, I have an interface and a class that inherits Form and this interface.  More specifically, how do I implement the Show() & Hide()?  I know how to do Property1 because it's my property, but Show() & Hide() are from the Form class and I don't know where or how to implement it.  Thanks in advance.

---------------------------

[GuidAttribute("3C1565B0-29B8-448e-B7AD-D36362989640")]

[InterfaceType(ComInterfaceType.InterfaceIsDual)]

[InterfaceType(ComInterfaceType.InterfaceIsDual)]

[ComVisible( )]

[ComVisible(true)]

IMyInterface

public interface IMyInterface

{

无效 隐藏( );  //这是正确的吗?

void Hide();  // is this correct?

无效 Show();////这是正确的吗?

void Show(); // is this correct?

bool   Property1 { 获取 ; set ;}

bool Property1 {get; set;}

}

[ClassInterface(ClassInterfaceType.None)]

[ClassInterface(ClassInterfaceType.None)]

[ComVisible( true )]

[ComVisible(true)]

公共 SplashForm:Form,IMyInterface

public class SplashForm : Form, IMyInterface

{

 公共 SplashForm()

  public SplashForm()

  {

  {

    公共 布尔型 Property1

     public bool Property1

   {

    {

    获取 { 返回 tmrShowSplash.Enabled; }

     get { return tmrShowSplash.Enabled; }

    设置 {tmrShowSplash.Enabled = ; }

     set { tmrShowSplash.Enabled = value; }

     }

  }
}

     }

  }
}

推荐答案

您好,
我认为最好在表单实例中运行函数,这将调用相同表单的this.Show()和this.Hide()方法.否则,您可以具有相同的替代功能.但是所有这些都必须具有comvisible(true)属性.
  I think it is better you can have to functions in your form instance, that will call the this.Show() and this.Hide() method of the same form. Else you can have override function of the same. But all these must have the attribute comvisible(true).


这篇关于向COM公开Form类方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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