什么时候调用OnResize表单? [英] When is OnResize form called?

查看:71
本文介绍了什么时候调用OnResize表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Form OnResize事件上放置了一些代码。但似乎仅在调整大小较大时才调用事件。有什么办法可以改变这个?

I put some code that happens on a Form OnResize event. But it Seems to only call the event when the resize is bigger. Is there any way to change this?

说我有

procedure TForm1.Resize(Sender: TObject);
begin
  RePaint();
end

我希望每次重新调整表单大小时都进行重新绘制(大或小)。我猜你可以添加一个检查宽度/高度的检查,但是如果要这样做,为什么还要使用事件调整大小?也许除了调整大小以外还有另一个事件可以做到吗?
谢谢
Glen

I would like to run repaint every time the form is re-sized (big or small). I guess you could add a check that checks width / height but if your going to do that why even use the event resize? Maybe there is another event besides resize that does both? thanks Glen

推荐答案

无论表单大小如何调整,都会触发OnResize事件,尽管

The OnResize event is triggered when the form is resized by any means, despite it is larger or smaller than before.

为了证明这一点,创建一个新项目,将备忘录放在干净的表单上,并将此代码添加到OnResize事件中:

To prove this, create a new project, put a Memo on a clean form and add this code to the OnResize event:

procedure TForm1.FormResize(Sender: TObject);
begin
  Memo1.Lines.Add(Format('%d,%d', [Width, Height]));
end;

执行您的项目,并拖动表格的边缘使其变大或变小,您将请注意,它总是被触发,并且也会触发该事件多少次。

Execute your project, and drag an edge of the form to make it greater and smaller, you'll notice it is fired always, and how many times the event is triggered also.

请注意,该表单还包含一个OnPaint事件,可能就是您要执行的操作。

Notice also the form has a OnPaint event that maybe is what you're after.

这篇关于什么时候调用OnResize表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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