 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Eugene V. Goldberg Guest
|
Posted: Sat May 28, 2005 9:37 am Post subject: moving the form |
|
|
Hi there guys,
I am looking for some better tecniques to display a moving form
in the panel...To avoid any flicker and have the whole process
smooth and looks good.
I have the following code:
var
Frm: TfrmMovingOne;
i: Integer;
begin
Frm := TfrmMovingOne.Create(nil);
try
Frm.Parent := pnMovingHost;
Frm.Left := 800;
Frm.Top := 0;
Frm.Show;
Frm.Update;
repeat
Frm.Left := Frm.Left - 1;
Frm.Update;
for i := 1 to 10000 do
Application.ProcessMessages;
until Frm.Left < 300;
finally
Frm.Release
end
end;
Any better techniques/ideas?
Thank you,
Eugene.
|
|
| Back to top |
|
 |
Scott H Guest
|
Posted: Sat May 28, 2005 2:20 pm Post subject: Re: moving the form |
|
|
You can try
Form.refresh;
Form.repaint;
setting Form.DoubleBuffered := True; sometimes helps reduce flickering.
The following is a serious of notes about flickering.
They arent well organized, but might help you.
Scott
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To prevent a form from repainting its background every time it does a paint, which can cause flicker even when using the double
buffering trick, put the following in the
FormCreate: Form1.ControlStyle := Form1.ControlStyle + [csOpaque];
But while using csOpaque may seem desirable, it can also introduce problems with a dynamic TLabel. See the LineCursors examples:
LineCursors.ZIP. Note that when csOpaque is enabled, the (X,Y) values are not displayed correctly if they "grow" and then later
"shrink."
Adding the csOpaque flag to the ControlStyle of the component
should eliminate the repainting of the component's background.
I think this can only be done during the constructor
Example:
constructor TMyControl.Create;
begin
inherited;
ControlStyle := ControlStyle + [csOpaque];
end;
Reduce flickering during animation
form.DoubleBuffered := true
add csOpaque to ControlStyle
MyControl.ControlStyle := MyControl.ControlStyle + [csOpaque];
The key to prevent excessive flicker is to *not* redraw the complete object on
every step. Instead you use the ScrollWindow API function (or
TWincontrol.ScrollBy) to directly move the client area content one or two
pixels left and then you redraw only the one or two pixels column newly
exposed by this operation on the right. Do not use double-buffering with
this approach, it will only get in the way.
Table.DisableControls;
Table.EnableControls;
Force window / component area to update
======================================
This has worked in some cases for me:
InvalidateRect (SELF.Handle, NIL {whole window}, FALSE {don't erase background});
RedrawWindows (SELF.Handle, NIL, 0, RDW_UPDATENOW);
SELF can be any component or even the form I think
Prevent window / component from updating
======================================
http://community.borland.com/article/0,1410,16349,00.html
temporarily prevent any given window from updating
Make a call to the Windows API function LockWindowUpdate with
the handle of the Window you wish to lock as a parameter. Send
a zero as a parameter to enable updating and to restore the
drawing.
LockWindowUpdate(Memo1.Handle);
|
|
| Back to top |
|
 |
Eugene V. Goldberg Guest
|
Posted: Sat May 28, 2005 3:50 pm Post subject: Re: moving the form |
|
|
Thanx Scott.
"Scott H" <noone (AT) nowhere (DOT) com> wrote
| Quote: |
You can try
Form.refresh;
Form.repaint;
setting Form.DoubleBuffered := True; sometimes helps reduce flickering.
The following is a serious of notes about flickering.
They arent well organized, but might help you.
Scott
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To prevent a form from repainting its background every time it does a
paint, which can cause flicker even when using the double
buffering trick, put the following in the
FormCreate: Form1.ControlStyle := Form1.ControlStyle + [csOpaque];
But while using csOpaque may seem desirable, it can also introduce
problems with a dynamic TLabel. See the LineCursors examples:
LineCursors.ZIP. Note that when csOpaque is enabled, the (X,Y) values are
not displayed correctly if they "grow" and then later
"shrink."
Adding the csOpaque flag to the ControlStyle of the component
should eliminate the repainting of the component's background.
I think this can only be done during the constructor
Example:
constructor TMyControl.Create;
begin
inherited;
ControlStyle := ControlStyle + [csOpaque];
end;
Reduce flickering during animation
form.DoubleBuffered := true
add csOpaque to ControlStyle
MyControl.ControlStyle := MyControl.ControlStyle + [csOpaque];
The key to prevent excessive flicker is to *not* redraw the complete
object on
every step. Instead you use the ScrollWindow API function (or
TWincontrol.ScrollBy) to directly move the client area content one or two
pixels left and then you redraw only the one or two pixels column newly
exposed by this operation on the right. Do not use double-buffering with
this approach, it will only get in the way.
Table.DisableControls;
Table.EnableControls;
Force window / component area to update
======================================
This has worked in some cases for me:
InvalidateRect (SELF.Handle, NIL {whole window}, FALSE {don't erase
background});
RedrawWindows (SELF.Handle, NIL, 0, RDW_UPDATENOW);
SELF can be any component or even the form I think
Prevent window / component from updating
======================================
http://community.borland.com/article/0,1410,16349,00.html
temporarily prevent any given window from updating
Make a call to the Windows API function LockWindowUpdate with
the handle of the Window you wish to lock as a parameter. Send
a zero as a parameter to enable updating and to restore the
drawing.
LockWindowUpdate(Memo1.Handle);
.
.
LockWindowUpdate(0);
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|