C# 屏幕保护程序:配置对话框模式以提供 HWND
我正在开发 C# XNA 屏幕保护程序套件,到目前为止,除了配置对话框之外,一切都已就位,该对话框必须是 Windows 提供的屏幕保护程序设置对话框的模式(“/c:
我的基准是 Vista 内置的3D 文本屏幕保护程序 - 我的代码应提供相同的功能,并且关于配置对话框,3D 文本显示完全模态的屏幕保护程序设置< /em> 对话框,当单击屏幕保护程序设置 对话框时,对话框会闪烁而不接受单击。
我已经尝试过按照 Ryan 建议的用 IWin32Window 包装 HWND 的方法Farley,但即使我的对话框显示在“屏幕保护程序设置”对话框的顶部,仍然可以单击“屏幕保护程序设置”对话框中的控件。
那么我是否需要一些奇特的 Win32API 调用来通知父对话框它已被模态化或者是否存在更干净的解决方案?
I am working on a C# XNA screensaver kit and so far, everything is in place except for the configuration dialog which must be modal to the Screen Saver Settings dialog provided by windows ("/c:<hwnd>" argument).
My benchmark is Vistas builtin 3D Text screensaver - my code shall provide the same features and regarding the configuration dialog, 3D Text displays fully modal to the Screen Saver Settings dialog and when clicking Screen Saver Settings dialog, the dialogs blink without accepting the click.
I have tried the method of wrapping the HWND with a IWin32Window as suggested by Ryan Farley, but even though my dialog displays on top of the Screen Saver Settings dialog, the controls in Screen Saver Settings dialog still can be clicked.
So do I need some exotic Win32API calls to inform the parent dialog that it has been modalized or does a more clean solution exist?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试调用
SetParent
< /a> API 函数。Try calling the
SetParent
API function.实际上,原来Windows向屏幕保护程序提供的
HWND
是设置对话框的子项,因此通过在HWND
上调用GetParent
,我得到一个代表对话框的HWND
。今天是我在 stackoverflow.com 上写下第一个问题并回答第一个问题的日子。
Actually, it turned out that the
HWND
provided by windows to the screensaver is a child of the settings dialog, so by callingGetParent
on theHWND
, I get anHWND
that represents the dialog.Today is the day that I wrote my first question on stackoverflow.com and answered the first question.
我也有同样的问题。此外,我无法使用 .NET 将对话框直接挂接到外部窗口。因此,我提供了一种解决方法,将对话框挂钩到给定窗口句柄的父级:
从命令行提取句柄后
创建对话框
,您可以通过Reimer
I had the same problem. Additionally I was not able to directly hook a dialog to a foreign window with .NET. Therefore I supply a work around to hook a dialog to the parent of a given window handle:
After extracting your handle from the command line
you create your Dialog by
Reimer