gpt4 book ai didi

c# - VB6中的COM控件 : Make a container out of the control

转载 作者:太空狗 更新时间:2023-10-29 20:39:48 24 4
gpt4 key购买 nike

我有一个在 VB6 中使用的 C# 控件,它基本上是一个带有圆角的面板。我想知道是否有办法使该控件成为一个容器,有点像 Frame 是一个容器。基本上,我希望能够将东西放在里面,以便它们一起移动,最重要的是将东西放在它的前面

现在,如果我在它上面放置一个标签或命令,它就会进入我的 COM 控件并使用 Bring to FrontSend to Back什么都不做。

我是否需要在 vb6 中将其声明为容器?代码是否必须来自 c#?

编辑:

我已经签署了 NDA,所以我不能在这里发布整个代码,但我会发布一些并解释一些。

public class AzPanel : Panel
{
protected const int BORDER_WIDTH = 3;
protected int BORDER_RADIUS = 4;
private object _lock = new object();
private bool regionNeedsRefresh = false;

public AzPanel() : base()
{
this.SetStyle(
ControlStyles.DoubleBuffer |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.Selectable, false);
base.BackColor = Color.Transparent;
this.BorderColor = Color.DarkRed;
this.ContentColor = Color.DarkGoldenrod;
this.DoubleBuffered = true;

base.Padding = new Padding(3, 3, 4, 4);
}
}

还有一些其他的东西可以用圆角定义一个区域,但它基本上只是一个面板。我有一个扩展 AzPanel 的类,AzPanelCOM 具有以下属性:

[Guid("...")]
[ProgId...]
[ComVisible(true)]
[ComdefaultInterface...]
[ClassInterface(ClassInterfaceType.AutoDispatch)]

还有一个接口(interface) IAzPanelCOM,用于将其公开给 VB6。

[Guid("...")]
[ComVisible(true)]
public interface IAzPanelCOM
{
void DesignTimeReload();
//some other things
}

在构建时,我使用“regasm.exe”创建一个类型库 (tlb),我在运行 Windows xp 和 vs2010 (.net Framework 4.0) 的虚拟机上导入 VB6。

然后我可以实例化 AzPanel,甚至在设计时调整它们的大小和移动它们,并且我可以毫无问题地向它们添加命令(按钮)。然而,当涉及到形状或标签时,它们似乎出现在面板后面,我无法将它们放在前面。

最佳答案

根据@MarkBertenshaw 的评论

You can't use windowless controls (shape, label, et.c) with a .NET container component. However, you could use a VB windowed control, e.g. Frame (no border) or Picture Box inside the .NET component, into which you place those windowless controls

关于c# - VB6中的COM控件 : Make a container out of the control,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15885629/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com