You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

双屏切换时DpiChanged事件多次触发问题求助

问题:跨DPI显示器移动窗体时DpiChanged事件异常触发

环境配置

  • 两台显示器:一台缩放比例100%(对应96 DPI),另一台175%(对应168 DPI)
  • .NET Framework 4.8,应用程序dpiAwareness设置为PerMonitorV2

正常触发场景

将在100%缩放显示器上启动的窗口缓慢移至175%缩放显示器时,DpiChanged事件触发符合预期,日志输出:

DPI changed: was: 96, now: 168
MessageBox2_Resize: System.EventArgs
MessageBox2_Resize: System.EventArgs

异常触发场景

将窗体从175%缩放显示器移回100%时,DpiChanged事件反复触发,导致程序运行异常,日志输出:

DPI changed: was: 168, now: 96
DPI changed: was: 96, now: 168
MessageBox2_Resize: System.EventArgs
MessageBox2_Resize: System.EventArgs
DPI changed: was: 168, now: 96
DPI changed: was: 96, now: 168
MessageBox2_Resize: System.EventArgs
DPI changed: was: 168, now: 96
MessageBox2_Resize: System.EventArgs

关键关联现象

  • 窗体开启根据内容自动调整大小设置时,出现上述异常;
  • 禁用该自动调整功能后,DpiChanged事件触发恢复正常。

内容的提问来源于stack exchange,提问作者Daniel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 14:25:20