How can I make my form resize more smoothly?

淺唱寂寞╮ 提交于 2020-01-11 15:51:08

问题


When resizing a form with many controls, the form looks bad because of flickering. What are some tips to have a smoother form resizing?


回答1:


procedure TForm1.WMEnterSizeMove(var Message:TWMMove);
begin
  Self.DisableAlign;
end;

procedure TForm1.WMExitSizeMove(var Message:TWMMove);
begin
  Self.EnableAlign;
end;



回答2:


Try using WM_SETREDRAW (not LockWindowUpdate).

You might also have a look at DeferWindowPos.




回答3:


Complex forms are often made up of nested panels, and the repaint process may cause flickering. If this is the case with your project there are two easy solutions that might help:

  1. Disable the property FullRepaint on your panels.
  2. Enable the property DoubleBuffered on your form. You won't find this property on the object inspector, so put DoubleBuffered := true; in FormCreate.



回答4:


I've got around this as follows:

  1. In the 'OnResize' event of the form, have a routine to hide all child controls and then start a timer with a tick of about 500ms.
  2. When the timer fires, disable it and then set all child controls to visible.

By playing around with this activity you get a form that goes blank whilst you are sizing it, but then populates itself neatly when you 'let go'.

Bri




回答5:


I avoid flicker by aligning no more than 1 non-alClient component per parent, always paired with a alClient (e.g. a TPanel) to contain all other components. Group them in panels without borders.

Say you want to allign three things: alLeft, alTop and alClient for the main view. Dont do this: Form alTop alLeft alClient // your main view

But instead embed these as follows: Form alTop alClient // panel to avoid flicker alLeft alClient // your main view

Same story for embedding several alTop elements.



来源:https://stackoverflow.com/questions/1454190/how-can-i-make-my-form-resize-more-smoothly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!