在 Windows 7 中将显示更改为 125% 时,MFC 中的控件被剪切
我有一个 MFC 应用程序。在 Windows 7 上运行它时,我意识到当将显示百分比更改为中 - 125% 时,我有一个 TextControl 被切断(不出现句尾)。
我该如何解决这个问题?
我可以放大对话框上控件的大小,但我宁愿通过代码来做到这一点。 我的应用程序已本地化,我不想更改每种语言的所有对话框。
I have an MFC application. When running it on Windows 7 I realized that when changing the display percentage to meduium - 125%, I have a TextControl which is cut off (end of sentence doesn't appear.)
How can I fix this?
I could enlarge the size of the control on the dialog, but I'd rather do that via the code.
My application is localized and I woudn't want to change all the dialogs on every language.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般来说,问题在于绝对坐标用于某些尺寸调整,而不是相对坐标。该框架最初会以大 DPI 正确布局,然后由您通过调整大小来保持事物的直线性。
您可以使用如下布局框架:Ultimate Toolbox 布局管理器,或者你可以自己动手。
以下是我使用的常见模式:
OnSize
中,根据每个控件的布局行为重新定位并调整其大小。In general, the issue is that absolute coordinates are being used for some sizing rather than relative. The framework will initially lay things out correctly in large DPI, it's then up to you to keep things straight through resizes.
You can use a layout framework like this one: Ultimate Toolbox Layout Manager, or you can roll your own.
Here's a common pattern I use:
OnInitDialog
, capture the initial control positions, e.g. for controls set to anchor top left you need to grab the initial distance from the top and left of the parent.OnSize
, reposition and resize each control according to its layout behavior.我不确定它是否对您的情况有帮助,但 RessizedLib 有效对我来说很好。您还可以跳过创建库并仅使用项目中的文件。
有一篇关于 CRessizedDialog 的单独文章,其中通过几个简单的步骤解释了如何为现有对话框实现此功能。
I'm not exactly sure if it helps in your case but the ResizableLib works pretty well for me. You can also skip creating a library and just use the files in your project.
There is a separate article for CResizableDialog which explains in a few easy steps how to implement this for existing dialogs.