当前位置:网站首页>DPI exception of window form dynamically created by WPF
DPI exception of window form dynamically created by WPF
2022-04-22 01:46:00 【SarznLiu】
There is a requirement in the project , Need to be in WPF Click the button in the main form to create a sub form , The position of the child form needs to move with the parent form , On multiple screens and individual screens dpi In different situations , The initial value of a dynamically created form at the time of creation dpi Is the screen where the program runs ( Simply speaking , For example, there is a screen 1、2, On screen 1 Double click on the icon to run the program , Then drag the program to the screen 2 Up , The screen 1 Is the initial screen for the program to run , Dynamically created subform dpi The initial value is the same as the screen 1 Of dpi identical ), At this time, when you move the subform according to the coordinates, the coordinate calculation error will appear , And the problem only occurs at the beginning .
terms of settlement : After dynamically creating a subform , The subform needs to call show Method , Then get the zoom ratio of the sub form at this time
var source = PresentationSource.FromVisual(myWindow);
if (source != null)
dpiRatio = source.CompositionTarget.TransformToDevice.M11;
Also use the same method to get the parent form at this time dpi, Then according to two dpi Calculate the corresponding coordinates
版权声明
本文为[SarznLiu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220056465698.html
边栏推荐
- 【lua编程 控制手机进行聊天】--用于养号、可以放下手进行自动化聊天养号了
- How to set the TS slice file size for the new kernel version of easycvr?
- Appium mobile terminal automated testing -- building a simulator and real machine environment
- 程序员的黑科技 | 每日趣闻
- 代码源每日一题 div1 (201-207)
- MSF series - Eternal Blue vulnerability
- [untitled]
- Thales
- 二十四节气之谷雨
- 真羡慕哪些不用发朋友圈的人
猜你喜欢

pycharm实现设置自动的参数注释标识

C# UserControl造成内存泄漏

net easy

The playback volume exceeds 2000W. Why can these high-energy qiafan videos be "watched repeatedly" by users of station B?

In depth understanding Construction mode of thread synchronization in. Net (1) user mode construction

2022年ADB 命令知多少?一文2000字详细 ADB 命令大全来啦

MySQL realizes master-slave replication / master-slave synchronization

The Sandbox 与 Design Egg 达成合作,将共同建立虚拟空间 Como 小小世界

VMware虚拟机安装详细教程网络NAT、网桥配置

什么智能合约?dapp合约系统定制技术原理分析
随机推荐
vscode使用ssh远程连接失败
代码源每日一题 div1 (501-507)
【服务器数据恢复】服务器进水后的数据恢复成功案例
面试链表题
Oracle installation server
真羡慕哪些不用发朋友圈的人
Penetration test of Mr robot target
Codeforces Round #783 (Div. 2)
educoder -- ip分片重组
Emotional control of investment
代码源每日一题 div1 (301-307)
Node靶机渗透测试
Bsides-vancouver-2018-workshop target penetration test
DVWA series - SQL injection
Webrtc video cannot be played. How to add UDP hole drilling program in easycvr?
BSides-Vancouver-2018-Workshop靶机渗透测试
互联网使用代理IP有哪些作用?
MATLAB实现多元正态Copula分布
Alibaba Android development specification, senior programmer interview questions
Code source daily question div1 (201-207)