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 9219377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:06:12+00:00 2026-06-18T03:06:12+00:00

We have a win control object which moves its clients to some other coordiantes.

  • 0

We have a win control object which moves its clients to some other coordiantes. The problem is, when there are too many children – for example 500 controls – the code is really slow.
It must be because of each control being repainted each time I set Left and Top property. So, I want to tell the WinControl object stop being repainted, and after moving all objects to their new positions, it may be painted again (Something like BeginUpdate for memo and list objects). How can I do this?
Here’s the code of moving the objects; it’s quite simple:

for I := 0 to Length(Objects) - 1 do begin
  with Objects[I].Client do begin
    Left := Left + DX;
    Top := Top + DY;
  end;
end;
  • 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. Editorial Team
    Editorial Team
    2026-06-18T03:06:13+00:00Added an answer on June 18, 2026 at 3:06 am

    As Cosmin Prund explains, the cause for the long duration is not an effect of repainting but of VCL’s realignment requisites at control movement. (If it really should take as long as it does, then you might even need to request immediate repaints).

    To temporarily prevent realignment and all checks and work for anchors, align settings and Z-order, use DisableAlign and EnableAlign. And halve the count of calls to SetBounds by called it directly:

    procedure TForm1.FormCreate(Sender: TObject);
    var
      I: Integer;
      Control: TControl;
    begin
      for I := 0 to 499 do
      begin
        Control := TButton.Create(Self);
        Control.SetBounds((I mod 10) * 40, (I div 10) * 20, 40, 20);
        Control.Parent := Panel1;
      end;
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
      I: Integer;
      C: TControl;
    begin
      // Disable Panel1 paint
      SendMessage(Panel1.Handle, WM_SETREDRAW, Integer(False), 0);  
      Panel1.DisableAlign;
      try
        for I := 0 to Panel1.ControlCount - 1 do
        begin
          C := Panel1.Controls[I];
          C.SetBounds(C.Left + 10, C.Top + 5, C.Width, C.Height);
        end;
      finally
        Panel1.EnableAlign;
        // Enable Panel1 paint  
        SendMessage(Panel1.Handle, WM_SETREDRAW, Integer(True), 0);
        // Update client area   
        RedrawWindow(Panel1.Handle, nil, 0, RDW_INVALIDATE or RDW_UPDATENOW or RDW_ALLCHILDREN); 
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I am using ms chart control in win-forms application. I have a problem
I have problem with databinding in the Win.Forms DataGridView control. Example: public class A
I have a win form, on which there are several radionbuttons and labels and
Simple question I hope.... I have a Win Form with a Tab Control and
I have created a simple win 32 application..in which it has a textbox and
I have a legacy MFC C++ application for Win CE 4.2 (x86 ONLY) which
i have a button on win form , which delete row on grid view.
I have a win 32 application written in c++ which sets the low level
I have to process enter (among other keys) on win form without it producing
I have a WinForms C# application. There is a WebBrowser control on the form

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.