VCL 形式的 PageControl 上带有锚点的错误自动缩放控件 [英] Wrong auto-scaling controls with anchors on PageControl in VCL form

查看:24
本文介绍了VCL 形式的 PageControl 上带有锚点的错误自动缩放控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在为不同的显示器 DPI 设置自动缩放表单上的控件时遇到问题.Rad Studio 10.2 东京.启用高 dpi"已开启.我在设计时将表单的 PixelsPerInch 设置为 96.我将 TPageControl 放在一个窗体上,在其中创建一个 TTabSheet 页面,在页面上放置一些控件并将它们的 Anchor 属性设置为 akRight(除了 akLeft 和 akTop).当程序在分辨率为 120 DPI 的显示器上运行时,这些控件的右边缘会出现超出 PageControl 的右边界之外,因此控件的右侧部分不可见.如果我关闭 akRight,则控件将正确缩放.但是我需要这些锚点在运行时正确调整表单的大小.如何解决问题?

I have problems with auto-scaling of controls on my form for different monitor DPI settings. Rad Studio 10.2 Tokio. "Enable high-dpi" is on. I set the form's PixelsPerInch to 96 at design time. I put TPageControl on a form, create a TTabSheet page in it, put some controls on a page and set their Anchor property to akRight (in addition to akLeft and akTop). When the program is run on a monitor with a resolution of 120 DPI right edge of those controls appear extended beyond the right boundary of PageControl, so that the right parts of controls are not visible. If I switch off the akRight, then the controls are scaled correctly. But I need those anchors to resize form correctly at run time. How to solve the problem?

PS 该错误已在 Rad Studio 10.3 中修复

PS The bug was fixed in Rad Studio 10.3

推荐答案

我遇到了同样的问题,一个应用程序拥有无数 TPageControl 和 TEdit、TMemo 和其他高 dpi 模式下未对齐的控件.

I was facing the same problem with an application owning myriads of TPageControl's with TEdit's, TMemo's and other misaligned controls in high-dpi mode.

我解决这个问题的第一个方法是尝试将 TForm 传递给一个名为 FixFormScaling() 的过程,我打算在那里修复所有有问题的缩放问题.但是我失败了,因为包含的控件有许多不同的对齐方式,我无法在一个简短的过程中合理地处理这些问题.

My first approach to solve this was an attempt to pass the TForm to a procedure called FixFormScaling(), where I intended to fix all buggy scaling stuff. But I failed greatly, due to having many different alignments of the contained controls, which I could not handle reasonably in one short procedure.

第二种方法似乎有效:在每个 TTabSheet 上,我放置了一个具有以下属性的 TPanel:

Align=alClient
BevelOuter=bvNone
Name=pnlDpiHelper<NameOfTabsheet>
ShowCaption=False

我正在将所有其他控件(TEdit、TMemo 等)移到该 TPanel 上.在高 dpi 模式下的结果是现在一切似乎都正确缩放了!

I am moving all other controls (TEdit, TMemo, etc.) onto that TPanel. The result in high-dpi mode is that everything seems to be scaled correctly now!

这篇关于VCL 形式的 PageControl 上带有锚点的错误自动缩放控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆