处理 C# ActiveX 控件中的父控件事件
我用 C# 编写了一个 ActiveX 用户控件。该 ActiveX 控件托管在用 Delphi 编写的 IE 中运行的旧应用程序内。 一切正常,我唯一的问题是我需要订阅托管我的控件的事件(例如 - 调整大小事件)。
目前我无法做到这一点,当我调整 IE 窗口大小时,我的控件没有收到 SizeChanged
事件。我尝试订阅父控件的事件,但父控件被列为空。 (我猜这是 Delphi 的问题。)
我想知道是否有办法让它工作(也许我必须实现一些接口?)。
这是我的控件的代码示例:
[
ClassInterface(ClassInterfaceType.AutoDispatch),
ComVisible(true),
Guid("<some guid>"),
]
public partial class MyActiveXControl : UserControl, IMyInterface
{
public MyActiveXControl()
{
InitializeComponent();
}
#region IScriptViewer Members
//implement interface
#endregion
}
I have written an ActiveX user control in C#. That ActiveX control is hosted inside a legacy application running in IE that is written in Delphi.
Everything works, my only problem is that I need to subscribe on events of the control that is hosting me (for example - resize event).
Currently I am unable to do that, and when I resize the IE window, my control does not get a SizeChanged
event. I tried to subscribe on the parent control's events, but the parent control is listed as null. (I guess it's the Delphi issue.)
I want to know if there is a way to get this working (some interface I have to implement maybe?).
Here is an example of the code of my control:
[
ClassInterface(ClassInterfaceType.AutoDispatch),
ComVisible(true),
Guid("<some guid>"),
]
public partial class MyActiveXControl : UserControl, IMyInterface
{
public MyActiveXControl()
{
InitializeComponent();
}
#region IScriptViewer Members
//implement interface
#endregion
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您如何处理网页中的控件大小?例如,获取浏览器窗口大小/changes,然后设置边界的手动控制。如果您希望控件内的控件重新排列它们,那么可能会调用控件的 OnSize 事件。
How about you handle the control size in your WebPage. For instance, get the browser window size/changes, and then set the bounds of control manually. And if you want the controls within the control the re-arrange them, then probably call the OnSize event of the control.