Wrong auto-scaling controls with anchors on PageControl in VCL form

爱⌒轻易说出口 提交于 2019-12-08 10:59:38

问题


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 The bug was fixed in Rad Studio 10.3


回答1:


C++ Builder Help for TFont says:

The PixelsPerInch property affects printer fonts only and should not be modified.

To modify the size of a font, use the Size or Height properties.




回答2:


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.

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.

The second approach seems to work: On each TTabSheet, I am placing a TPanel with the following properties:

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

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!



来源:https://stackoverflow.com/questions/48370423/wrong-auto-scaling-controls-with-anchors-on-pagecontrol-in-vcl-form

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!