惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
P
Proofpoint News Feed
D
DataBreaches.Net
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
宝玉的分享
宝玉的分享
Recorded Future
Recorded Future
GbyAI
GbyAI
阮一峰的网络日志
阮一峰的网络日志
S
SegmentFault 最新的问题
C
Cisco Blogs
L
LangChain Blog
博客园 - 聂微东
Microsoft Security Blog
Microsoft Security Blog
Recent Announcements
Recent Announcements
量子位
AWS News Blog
AWS News Blog
爱范儿
爱范儿
Know Your Adversary
Know Your Adversary
F
Full Disclosure
MyScale Blog
MyScale Blog
Stack Overflow Blog
Stack Overflow Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Microsoft Azure Blog
Microsoft Azure Blog
S
Schneier on Security
Spread Privacy
Spread Privacy
P
Privacy International News Feed
人人都是产品经理
人人都是产品经理
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
美团技术团队
Latest news
Latest news
D
Docker
Scott Helme
Scott Helme
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
MongoDB | Blog
MongoDB | Blog
The Register - Security
The Register - Security
T
Tailwind CSS Blog
SecWiki News
SecWiki News
C
CERT Recently Published Vulnerability Notes
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Security Affairs
G
GRAHAM CLULEY
Simon Willison's Weblog
Simon Willison's Weblog
Martin Fowler
Martin Fowler
I
InfoQ
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Tenable Blog

博客园 - 赖仪灵

分享几个简单的WPF控件(代码) 捕捉WPF应用程序中XAML代码解析异常 设置WPF窗口相对于非WPF窗口的位置 上海.NET俱乐部--微软社区巡展VSTS上海专题活动 WPF全景体验 最优化WPF 3D性能(基于“Tier-2”硬件) Windows Vista桌面窗口管理器(3) 闲话WPF之二六(WPF性能优化点) 闲话WPF之二五(WPF中的ControlTemplate [3]) 闲话WPF之二四(WPF中的ControlTemplate [2]) Windows Vista桌面窗口管理器(2) 闲话WPF之二三(WPF中的ControlTemplate [1]) 闲话WPF之二二(WPF中的Style) Windows Vista桌面窗口管理器(1) 闲话WPF之二一(WPF中的数据处理 [3]) 闲话WPF之二十(WPF中的传递事件 [2] ) 闲话WPF之十九(WPF中的传递事件 [1] ) 闲话WPF之十八(WPF中的资源 [4] ) 闲话WPF之十七(WPF中的资源 [3])
WPF关于WindowInteropHelper的一个BUG
赖仪灵 · 2007-04-03 · via 博客园 - 赖仪灵

在Windows SDK中关于WindowInteropHelper类的介绍中,关于其Owner属性的说明和实现有些问题。

原文是:An example scenario is if you need to host a WPF dialog box in a Win32 application. Initialize the WindowInteropHelper with a WPF window object for the dialog. You can then get the WPF window's handle (HWND) from the Handle property and specify the owner for the WPF window with the Owner property. The following code example shows how to use WindowInteropHelper when hosting a WPF dialog box in a Win32 application.

大意是通过WindowInteropHelper的Owner属性可以把WPF窗口的Owner属性设置为一个Win32的窗口句柄HWND。但是这个功能的实现是有问题的。有兴趣的朋友可以通过下面的代码进行测试:

Window myDialog = new Window();
myDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
WindowInteropHelper wih = new WindowInteropHelper(myDialog);
wih.Owner = ownerHwnd;
myDialog.ShowDialog();

这段代码最后显示的窗口不会位于Owner窗口的中心。事实上,WindowInteropHelper.Owner属性设置的是Window类的_ownerHandle成员。这个成员和Window.Owner设置的成员不是同一个。因此,文档中的说明和WPF的实际实现不相符的。这个问题基本已经确认是WPF的一个BUG。