Windows 应用程序分辨率
我有一个 Windows 应用程序,可以在 96DPI 的 PC 上正确运行,但当我在 120DPI 的 PC 上使用它时,表单会发生转换,并且所有组件都会打乱。
我该如何解决这个问题?
谢谢。
I have a windows app that runs correctly in my PC that is 96DPI but when I use it on a PC that has 120DPI the forms transform and all their components scramble.
How can I fix this?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您需要在表单中使用动态布局。您可以使用 AutoSize、Docking/Anchoring、Padding、Margin、TableLayoutPanel、FlowLayoutPanel 等来构建表单,以便控件的实际定位在运行时而不是编译时完成。这样,即使 DPI 不同,您的表单也将保留其布局。 Charles Petzold 的《Programming Microsoft Windows Forms》是一本关于 Windows 窗体的好书。该书的第 3 章充满了有关如何使用动态布局的信息。
It sounds like you need to use dynamic layout in your forms. You can use AutoSize, Docking/Anchoring, Padding, Margin, TableLayoutPanel, FlowLayoutPanel, etc, to structure your form so the actual positioning of your controls is done at run-time instead of compile-time. That way, your form will retain its layout even when the DPI is different. "Programming Microsoft Windows Forms" by Charles Petzold is a good book on Windows Forms. Chapter 3 of that book is full of information about how to use dynamic layout.
如果您的意思是您有应用程序的源代码(开发问题),您可以检查应用程序运行的显示器的 DPI 设置,并根据需要根据分辨率重新格式化您的界面。
如果您的意思是您有从其他地方编译的应用程序并且没有其源代码,您可以将分辨率设置为 96 DPI。
希望有帮助。
if you mean you have the source for the application (development question) you can check the DPI setting of the display the application is running on and re-format your interface as needed depending on the resolution.
If you mean that you have a compiled application from somewhere else and you don't have the source code for it you can set your resolution to 96 DPI.
Hope that helps.