在运行时插入控件集非常慢 [英] Inserting set of controls at runtime is extremely slow

查看:64
本文介绍了在运行时插入控件集非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个销售点应用程序,在此应用程序中,我们有一个滚动框容器。如果卖方选择一种产品,则会创建一个新产品行并将其插入到滚动框中。产品行组件是一个框架-内有文本框,按钮和标签。

We have a point-of-sale application and in this application we have a scrollbox container. If the seller selects a product, then a new product row is created and inserted into the scrollbox. The product row component is a frame - textboxes, buttons and labels in it.

但是,在运行时将此产品行控件插入到滚动框中会出现一个小问题。太慢了我可以看到选择产品是如何将edittext组件缓慢地拖动到滚动框中的。

But here's a little problem by inserting this product row control into the scrollbox at runtime. It's slow. I can see how selecting product draws edittext components slowly into the scrollbox.

我试图设置组件的可见性 ScrollBox.InsertControl 之前为false,然后在之后启用它,但这并不能大大加快处理速度。我也读过有关DisableAlign / EnableAlign的内容,但我不知道确切将代码行放在何处。

I tried to set the components' visibility to false before ScrollBox.InsertControl and enabling it after, but it doesn't help speed up things very much. Also I read about DisableAlign/EnableAlign thing, but I don't know exactly where I have to put this line of code.

如何加快插入此自定义组件的速度

How can I speed up inserting this custom component into the form's scrollbox container?

推荐答案

TScrollBox没有BeginUpdate / EndUpdate,但是您可以使用WM_SETREDRAW消息获得相同的效果。我可能会避免使用诸如 LockWindowUpdate

TScrollBox doesn't have BeginUpdate/EndUpdate, but you can get the same effect using WM_SETREDRAW messages. I would probably avoid more heavy handed methods like LockWindowUpdate.

  SendMessage(ScrollBox1.Handle, WM_SETREDRAW, 0, 0);
  try
    // add controls to scrollbox
    // set scrollbox height
  finally
    SendMessage(ScrollBox1.Handle, WM_SETREDRAW, 1, 0);
    RedrawWindow(ScrollBox1.Handle, nil, 0, RDW_ERASE or RDW_INVALIDATE or RDW_FRAME or RDW_ALLCHILDREN);
  end;

这篇关于在运行时插入控件集非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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