Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 141031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:42:40+00:00 2026-05-11T07:42:40+00:00

Is there a way to suspend all anchored controls on a form from moving

  • 0

Is there a way to suspend all anchored controls on a form from moving or resizing themselves temporarily? i.e.:

procedure ScaleFormBy(AForm: TForm; n, d: Integer); begin     AForm.SuspendAnchors();     try        AForm.ScaleBy(n, d);     finally        AForm.ResumeAnchors();     end; end; 

I need to do this because I’m calling

AForm.ScaleBy(m, d); 

Which does not handle anchored controls properly. (it pushes left+right or top+bottom anchored controls off the edge of the form.

Note: I want to disable Anchors, not Alignment.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:42:40+00:00Added an answer on May 11, 2026 at 7:42 am

    Guy had a good idea, but it didn’t handle child control (i.e. TPanel, TPageControl, etc)

    Here’s a variant that uses recursion. Also, notice that i don’t actually disable anchors – turn out that ScaleBy doesn’t work with no anchors either.

    So now you can scale a form using:

    procedure ScaleFormBy(AForm: TForm; M, D: Integer); var    StoredAnchors: TAnchorsArray; begin    StoredAnchors := DisableAnchors(AForm);    try        AForm.ScaleBy(M, D);    finally        EnableAnchors(AForm, StoredAnchors);    end; end; 

    With the support library functions:

    TAnchorsArray = array of TAnchors;  function DisableAnchors(ParentControl: TWinControl): TAnchorsArray; var    StartingIndex: Integer; begin    StartingIndex := 0;    DisableAnchors_Core(ParentControl, Result, StartingIndex); end;  procedure EnableAnchors(ParentControl: TWinControl; aAnchorStorage: TAnchorsArray); var    StartingIndex: Integer; begin    StartingIndex := 0;    EnableAnchors_Core(ParentControl, aAnchorStorage, StartingIndex); end;  procedure DisableAnchors_Core(ParentControl: TWinControl; var aAnchorStorage: TAnchorsArray; var StartingIndex: Integer); var    iCounter: integer;    ChildControl: TControl; begin    if (StartingIndex+ParentControl.ControlCount+1) > (Length(aAnchorStorage)) then       SetLength(aAnchorStorage, StartingIndex+ParentControl.ControlCount+1);     for iCounter := 0 to ParentControl.ControlCount - 1 do    begin       ChildControl := ParentControl.Controls[iCounter];       aAnchorStorage[StartingIndex] := ChildControl.Anchors;        if ([akLeft, akRight ] * ChildControl.Anchors) = [akLeft, akRight] then          ChildControl.Anchors := ChildControl.Anchors - [akRight];        if ([akTop, akBottom] * ChildControl.Anchors) = [akTop, akBottom] then          ChildControl.Anchors := ChildControl.Anchors - [akBottom];        Inc(StartingIndex);    end;     //Add children    for iCounter := 0 to ParentControl.ControlCount - 1 do    begin       ChildControl := ParentControl.Controls[iCounter];       if ChildControl is TWinControl then          DisableAnchors_Core(TWinControl(ChildControl), aAnchorStorage, StartingIndex);    end; end;  procedure EnableAnchors_Core(ParentControl: TWinControl; aAnchorStorage: TAnchorsArray; var StartingIndex: Integer); var    iCounter: integer;    ChildControl: TControl; begin    for iCounter := 0 to ParentControl.ControlCount - 1 do    begin       ChildControl := ParentControl.Controls[iCounter];       ChildControl.Anchors := aAnchorStorage[StartingIndex];        Inc(StartingIndex);    end;     //Restore children    for iCounter := 0 to ParentControl.ControlCount - 1 do    begin       ChildControl := ParentControl.Controls[iCounter];       if ChildControl is TWinControl then          EnableAnchors_Core(TWinControl(ChildControl), aAnchorStorage, StartingIndex);    end; end;   end; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to suspend Bitlocker for a drive programmatically from .NET?
Is there a way to temporarily suspend / pause Sharepoint Server 2010, IIS and
Is there way to get file from windows xp command prompt? I tried to
is there way how to get name ov event from Lambda expression like with
Is there way that I can read the file from remote server using fopen
Is there any way to suspend execution of javascript until whole page is loaded
Is there any way to suspend an app in the Apple Store. My app
Is there a way in C# to check if an object is suspend? I
Is there way to capture and print out all of the requests and responses
Is there way to automatically maximize the output window on hitting build and then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.