ActiveX 控件在一个主机容器中变为空白,但在其他容器中则不然
我需要使用 activeX 为遗留应用程序创建插件。我使用 C#,以便可以共享几个相关独立产品的代码库。
当我将控件托管在 SDK 的测试容器 (TstCon32.exe) 中时,一切正常。问题是,当我第一次尝试将其加载到目标应用程序中时,如果我更改了控件的背景颜色,那么除了我单击的项目(文本框或数据网格单元格)之外的所有内容都被涂上了控件灰色控制到其他东西,背景保持与我指定的颜色相同,但所有控件仍然被控制灰色覆盖(来自容器应用程序?)。单击其他控件将导致它们进行绘制,调整控件的大小将导致所有内容重新绘制。初始消隐后,控制功能正常运行,直到下一次创建副本为止。
I need to use activeX to create a plugin for a legacy application. I'm using C# so that i can share the codebase of several related stand alone products.
When I host the control in the SDK's test container (TstCon32.exe) everything works fine. The problem is that when I try to load it in the target application the first time I click on the control everything except the item I clicked on (textbox or datagrid cell) is painted over with control grey, if I change the background color of the control to something else the background stays the same color I specified but all the controls are still covered over with control grey (from the container app?). Clicking on additional controls will cause them to paint, resizing the control will cause everything to repaint. After the initial blanking the control functions normally until the next time a copy is created.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我终于找到了解决办法。第一部分是将我的目标框架从 4.0 更改为之前的版本。这揭示了当控件被清空时发生的异常,该控件之前被消耗并对我隐藏:
从那里我能够找到 帖子,作者:tomasvdb,他遇到了与我使用 Google 边栏相同的问题。
对该帖子的回复之一链接到此 message 为侧边栏应用程序向 .net 控件发送无效数据的错误提供了解决方法。
在控件的 VisibleChanged 事件处理程序中调用该解决方法也解决了我的问题。
I finally found a solution. The first part was to change my targeted framework from 4.0 to a prior version. This revealed an exception thta was occuring when the control was blanked that was previously being consumed and hidden from me:
From there I was able to find a post by tomasvdb who encountered the same problem I had with the Google Sidebar.
One of the replies to that post linked to this message which provided a workaround for a bug where the sidebar application was sending invalid data to the .net control.
Calling that workaround method in the Control's
VisibleChanged
event handler solved my problem as well.