Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Wrong scaling of controls with anchors on a PageControl


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Apr 18, 2018 3:06 PM Last Post By: Gwyn Skone
Vladimir Shvetsov

Posts: 12
Registered: 2/18/05
Wrong scaling of controls with anchors on a PageControl  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 20, 2018 1:51 AM
Hi,
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 Anchors 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.
The problem can be reproduced in a new project with a single PageControl and some anchored controls on it.
How to solve the problem?

Edited by: Vladimir Shvetsov on Jan 21, 2018 12:53 PM
Mark Griffiths

Posts: 1
Registered: 2/3/12
Re: Wrong scaling of controls with anchors on a PageControl  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 13, 2018 12:46 AM   in response to: Vladimir Shvetsov in response to: Vladimir Shvetsov
Hi Vladimir,

I just ran into exactly the same problem today.

In case you're still looking for a solution or if anyone else has this problem, the solution is to edit Vcl.ComCtrls.pas and comment out the following lines in the TTabSheet.UpdateControlOriginalParentSize procedure:

if (csLoading in ComponentState) then
begin
AOriginalParentSize.X := FDesignSize.X;
AOriginalParentSize.Y := FDesignSize.Y;
end;
Vladimir Shvetsov

Posts: 2
Registered: 12/14/15
Re: Wrong scaling of controls with anchors on a PageControl  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 16, 2018 4:55 AM   in response to: Mark Griffiths in response to: Mark Griffiths
Mark Griffiths wrote:

the solution is to edit Vcl.ComCtrls.pas
Thank you, Mark. I haven't yet solved the problem.
As far as I understand, you suggest to modify the sources of the VCL library. But this probably means that I have to recompile the library itself? I've never done this before. Do I need a VCL project file for this? Could you explain it in more detail?
Thank you in advance.
Alex Belo

Posts: 626
Registered: 10/8/06
Re: Wrong scaling of controls with anchors on a PageControl  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 16, 2018 10:41 PM   in response to: Vladimir Shvetsov in response to: Vladimir Shvetsov
Vladimir Shvetsov wrote:

the solution is to edit Vcl.ComCtrls.pas

As far as I understand, you suggest to modify the sources of the VCL
library. But this probably means that I have to recompile the library
itself? I've never done this before. Do I need a VCL project file for
this? Could you explain it in more detail?

You can patch system source files and use them in your project as
follows:

1) copy source file in question into your custom directory
2) make changes in source
3) include this file into project
4) disable runtime packages and dynamic RTL to link your project
statically (otherwise old original packages will be loaded at runtime;
also it will happen on client's computer too)
5) enjoy and good luck ...

--
Alex
Vladimir Shvetsov

Posts: 2
Registered: 12/14/15
Re: Wrong scaling of controls with anchors on a PageControl  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 16, 2018 1:22 PM   in response to: Alex Belo in response to: Alex Belo
Today I tried your solution and it works!!!
Alex, thank you very, very much!!!
I was in a great trouble really, as it was the complete stopper for my application: important functionality was blocked.
Gwyn Skone

Posts: 1
Registered: 11/28/01
Re: Wrong scaling of controls with anchors on a PageControl  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 18, 2018 3:06 PM   in response to: Mark Griffiths in response to: Mark Griffiths
Mark Griffiths wrote:
I just ran into exactly the same problem today.
So did I, and your solution worked for me too, thanks! I wonder what that code was meant to achieve, since removing it doesn't seem to have broken anything (yet...).
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02