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

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
博客园_首页
WordPress大学
WordPress大学
博客园 - 聂微东
P
Privacy International News Feed
Forbes - Security
Forbes - Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Last Week in AI
Last Week in AI
C
CERT Recently Published Vulnerability Notes
月光博客
月光博客
NISL@THU
NISL@THU
美团技术团队
T
Tailwind CSS Blog
Jina AI
Jina AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
C
Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Hacker News
The Hacker News
B
Blog
P
Palo Alto Networks Blog
L
Lohrmann on Cybersecurity
有赞技术团队
有赞技术团队
The Register - Security
The Register - Security
S
Securelist
A
Arctic Wolf
MyScale Blog
MyScale Blog
H
Help Net Security
N
Netflix TechBlog - Medium
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
Threatpost
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Security Latest
Security Latest
T
Tor Project blog
V
Vulnerabilities – Threatpost
V
V2EX
AI
AI
Hugging Face - Blog
Hugging Face - Blog
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
Simon Willison's Weblog
Simon Willison's Weblog
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Troy Hunt's Blog
Schneier on Security
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Heimdal Security Blog
Google Online Security Blog
Google Online Security Blog
Know Your Adversary
Know Your Adversary

博客园 - yhuse

MiniMax 权益码 Token Plan 套餐 9 折优惠,Token Plan 共建邀请计划 至2026.7.31 MiniMax 权益码 Token Plan 套餐 9 折优惠,Token Plan 共建邀请计划 至2026.7.31 MiniMax 权益码 Token Plan 套餐 9 折优惠,Token Plan 共建邀请计划 至2026.7.31 MiniMax 权益码 Token Plan 套餐 9 折优惠,至2026.6.30 MiniMax 权益码 Token Plan 套餐 9 折优惠,至2026.6.30 MiniMax 权益码 Token Plan 套餐 9 折优惠 MiniMax 权益码 Token Plan 套餐 9 折优惠 MiniMax 权益码 Token Plan 套餐 9 折优惠 WinForms 内置的公共系统级别编辑器 科技衰退,CodeProject.com 关闭了 DataView RowFilter Syntax [C#] .NET Standard 对 .NET 的每个实现的支持 NuGet 包版本引用 | Microsoft Docs C# Winform窗体继承过程中,TableLayoutPanel是不支持继承的 VS2022安装.NetFramework4.0目标包的方法 VS2022禁用全局using,禁用GlobalUsings.g.cs Ubuntu下libpcap安装步骤 Ubuntu 18.04 安装.net 5 .Net Framework各版本微软技术支持及到期日期 TargetFrameworks输出多版本类库,SDK 样式项目中的目标框架 [原创][开源] SunnyUI.Net 常见问题答疑 [原创][开源] SunnyUI.Net 开发日志:UIBarChart 坐标轴刻度取值算法 [原创][开源] SunnyUI.Net 主题 [原创][开源] SunnyUI.Net 字体图标 [原创][开源] SunnyUI.Net 国际化 [原创][开源] SunnyUI.Net 安装 [原创][开源] SunnyUI.Net 开发日志:UIListBox 增加跟随鼠标滑过高亮
[原创][开源]C# Winform DPI自适应方案,SunnyUI三步搞定
yhuse · 2022-04-22 · via 博客园 - yhuse

Winform窗体随着屏幕的DPI缩放,会引起窗体变形及字体变形。
SunnyUI的DPI缩放自适应方案目标为随着DPI缩放,窗体和字体均不变形,从而实现界面的美观。
主要有以下三步操作:

1、设置窗体和自定义用户控件的AutoScaleMode为None
实现目标:禁止窗体因为字体大小缩放变形
因为显示的高分屏,然后操作系统的设置了字体缩放引起的。窗体默认的AutoScaleMode = Font,控件会因为高分屏自动缩放。
解决方法:设置窗体、用户控件的AutoScaleMode = None
输入图片说明

2、设置app.manifest的dpiAware为true
实现目标:禁止窗体因为DPI缩放变形
选择项目属性,安全性
输入图片说明
选中 启用 ClickOnce 安全设置,再取消选中。
这时候项目的文件里就多了app.manifest
输入图片说明
按下面代码修改,启用dpiAware

  <!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
       自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
       选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
       在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
       
       将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->

  <application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
      <longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
    </windowsSettings>
  </application>

  
  

3、设置DPIScale为true
实现目标:DPI缩放后字体大小不变
确认编译时DPI缩放为100%
在主窗体上放置UIStyleManager控件
输入图片说明
设置DPIScale为true
输入图片说明
编译程序,在不同的DPI缩放下测试编译好的SunnyUI.Demo.exe

SunnyUI.Net:C# .Net WinForm开源控件库、工具类库、扩展类库、多页面开发框架;Sunny's blog:https://www.cnblogs.com/yhuse