在本机窗口中托管 Windows 窗体控件,窗口类=“静态”
我需要向本机应用程序 (Visual Studio) 提供 Windows 窗体控件。
所以我创建一个控件并提供它的句柄。
然后,当我使用 Spy++ 检查本机窗口时,我发现我的控件被包装在附加的“控件”中,窗口类 =“静态”且标题为“这是静态的!”。我有几个问题:
- 通过托管窗口发送到我的控件的调整大小事件必须重新发送到“静态”,因此它也会调整大小(否则我的控件会部分隐藏在静态大小内)。
- 该静态没有
WS_EX_CONTROLPARENT
,这会导致出现 KB149501 (简而言之,整个应用程序因失去焦点而挂起)。 - 如果我应用 WS_EX_CONTROLPARENT ,静态中的列表框将停止重绘。
我想我做错了什么,但我不确定是什么。 Google 没有提供帮助,因为 static 也是 C# 关键字,因此它经常出现在 WinForms 结果中。
I need to provide a Windows Forms control to a native application (Visual Studio).
So I create a control and provide its handle.
Then, when I check the native window using Spy++, I see that my control is wrapped in additional 'control' with window class = "Static" and title "This is a static!". I have several problems with it:
- Resize events sent to my control by a hosting window have to be re-sent to the "Static" so it also gets resized (otherwise my control get partially hidden within the static's size).
- The static does not have
WS_EX_CONTROLPARENT
, which causes KB149501 to appear (in short, whole application hangs on lost focus). - If I apply
WS_EX_CONTROLPARENT
, listbox within the static stops redrawing.
I think I have been doing something wrong, but I am not sure what. Google does not help, since static is a C# keyword as well so it occurs quite often in WinForms results.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我主要使用 DoubleBuffered=True 解决了重绘问题,所以可能就是这样。
我仍然认为我做错了什么,但至少现在它有效了。
I mostly solved the redrawing problem using DoubleBuffered=True, so probably this is it.
I still think I am doing something wrong, but at least it works now.