向COM公开Form类方法 [英] Exposing Form class methods to COM
问题描述
我是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(
---------------------------
---------------------------
公共 界面 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; }
}
}
}
}
}
}
推荐答案
您好,
这篇关于向COM公开Form类方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!