DPIAware 和“启用应用程序框架"在应用程序设置 [英] DPIAware and "Enable application framework" at Application Settings
问题描述
我想在我们的 VB.net WinForms 应用程序中启用 dpi Awareness.所以我把下面的代码放到了 app.config 文件中.但是我们的项目没有选中启用应用程序框架"复选框.我们的应用程序从一个共享的子主程序和 .show() 开始.未选中该复选框时,我无法启用 dpiAwareness!(自 19 年 4 月起,您可以在任务管理器中看到 dpi 模式)app.config 设置被忽略了?!我不知道.
I want to enable dpi Awareness in our VB.net WinForms Application. So I put the code below into the app.config file. But our project has the checkbox "enable application framework" not checked. Our App starts with a shared sub main and .show(). When the checkbox is not checked I can not enable dpiAwareness! (Since April '19 you can see the dpi mode in the taskmanager) The app.config settings gets ignored?! I dont know.
在测试项目中,没有问题.在那里我可以选中该框并且 app.config 可以工作,或者我不选中它并且可以在运行时通过 api 调用更改 dpi 模式.
In Test Projects, there is no problem. There I can check the box and the app.config works or I leave it unchecked and can change the dpi mode at runtime via api call.
</system.diagnostics>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<System.Windows.Forms.ApplicationConfigurationSection>
<add key="DpiAwareness" value="PerMonitorV2" />
如果没有启用应用程序框架"复选框,app.config 中的 dpi 设置将无法工作.
dpi setting in app.config wont work without "enable application framework" checkbox.
推荐答案
启用 Win 版本就像 TnTinMn 说的:
Enable the Win Version like TnTinMn said:
如果您想使用 app.config 文件为 .Net 声明 DPI 感知4.7及以上版本,还需要修改app.manifest
文件(项目属性->应用程序->查看窗口设置按钮)并声明程序与 Win 10 兼容.请参阅:配置您的 Windows 窗体应用程序高 DPI 支持.如果使用 app.config
方法,不要设置app.manifest
文件中的 dpi 级别,因为这将覆盖app.config
设置.
If you want use the app.config file to declare DPI awareness for .Net 4.7 and above, you also have to modify the
app.manifest
file (Project Properties->Application->View Window Settings button) and declare the program to be Win 10 compatible. See: Configuring your Windows Forms app for high DPI support. If using theapp.config
method, do not set the dpi level in theapp.manifest
file as that will override theapp.config
settings.
在我们使用新生成的 mainfest 文件并添加多年来我们需要的设置之前.我们将应用程序作为应用程序框架启用"启动.在项目设置中.然后我们必须将共享的主代码移动到主窗体中.我认为这应该可以完成工作.谢谢.
Before we take a newly generated mainfest file and add the settings we need since years. We start the app as "application framework enable" in the Project Settings. Then we have to move the shared main code to the main form. I think this should do the job. thx at all.
这篇关于DPIAware 和“启用应用程序框架"在应用程序设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!