C# Winform 使用SunnyUI包 不同分辨率、百分比缩放解决方案

发布时间:2026/7/24 20:36:12
C# Winform 使用SunnyUI包 不同分辨率、百分比缩放解决方案 1、窗体属性更改2、设置app.manifest文件的dpiAware右键项目-》新建文件更改清单文件如下application xmlnsurn:schemas-microsoft-com:asm.v3 windowsSettings dpiAware xmlnshttp://schemas.microsoft.com/SMI/2005/WindowsSettingstrue/dpiAware longPathAware xmlnshttp://schemas.microsoft.com/SMI/2016/WindowsSettingstrue/longPathAware /windowsSettings /application3、窗体增加UIStyleManager控件如下4、完成后在100%缩放下编译编译完成后在其他缩放电脑看效果解决SunnyUI包下载地址SunnyUI: SunnyUI.NET 是基于.NET Framework 4.0、.NET6、.NET8、.NET9 框架的 C# WinForm UI、开源控件库、工具类库、扩展类库、多页面开发框架。https://gitee.com/yhuse/SunnyUI解决问题的话点个赞app.manifest文件如下?xml version1.0 encodingutf-8? assembly manifestVersion1.0 xmlnsurn:schemas-microsoft-com:asm.v1 assemblyIdentity version1.0.0.0 nameMyApplication.app/ trustInfo xmlnsurn:schemas-microsoft-com:asm.v2 security requestedPrivileges xmlnsurn:schemas-microsoft-com:asm.v3 !-- UAC 清单选项 如果想要更改 Windows 用户帐户控制级别请使用 以下节点之一替换 requestedExecutionLevel 节点。 requestedExecutionLevel levelasInvoker uiAccessfalse / requestedExecutionLevel levelrequireAdministrator uiAccessfalse / requestedExecutionLevel levelhighestAvailable uiAccessfalse / 指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。 如果你的应用程序需要此虚拟化来实现向后兼容性则移除此 元素。 -- requestedExecutionLevel levelasInvoker uiAccessfalse / /requestedPrivileges /security /trustInfo compatibility xmlnsurn:schemas-microsoft-com:compatibility.v1 application !-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的 Windows 版本的列表。取消评论适当的元素 Windows 将自动选择最兼容的环境。 -- !-- Windows Vista -- !--supportedOS Id{e2011457-1546-43c5-a5fe-008deee3d3f0} /-- !-- Windows 7 -- !--supportedOS Id{35138b9a-5d96-4fbd-8e2d-a2440225f93a} /-- !-- Windows 8 -- !--supportedOS Id{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38} /-- !-- Windows 8.1 -- !--supportedOS Id{1f676c76-80e1-4239-95bb-83d0f6d0da78} /-- !-- Windows 10 -- !--supportedOS Id{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a} /-- /application /compatibility !-- 指示该应用程序可感知 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 xmlnsurn:schemas-microsoft-com:asm.v3 windowsSettings dpiAware xmlnshttp://schemas.microsoft.com/SMI/2005/WindowsSettingstrue/dpiAware longPathAware xmlnshttp://schemas.microsoft.com/SMI/2016/WindowsSettingstrue/longPathAware /windowsSettings /application -- !-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -- !-- dependency dependentAssembly assemblyIdentity typewin32 nameMicrosoft.Windows.Common-Controls version6.0.0.0 processorArchitecture* publicKeyToken6595b64144ccf1df language* / /dependentAssembly /dependency -- /assembly