Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
Scroll my control without flicker effect
This article has not been rated yet. After reading, feel free to leave comments and rate it.
(see also: My control flickers when it gets repainted!)
The easiest way to scroll the elements of a control is to force a complete repaint of the control.
Unfortunately this produces the flicker effect. You may use
InvalidateRect (MyControl.Handle, NIL, FALSE);
(important: last parameter = FALSE) to cause a complete redraw without erasing the background.
The best way to reduce this flickering is to use the ScrollWindow or ScrollWindowEx Windows API function. Look them up in your Win32.HLP file.
Another source of flickering can be from Windows using two messages to
paint: WM_PAINT and WM_ERASEBKGND.
You may want to intercept all of the WM_ERASEBKGND messages and do all of your painting,
including the background, in response to WM_PAINT messages in the Paint method:
 | |  | |
type
TMyComponent = class(TWinControl)
protected
procedure WMEraseBkgnd(var message: TWMEraseBkgnd);
message WM_ERASEBKGND;
end;
procedure TBMyComponent.WMEraseBkgnd(var message: TWMEraseBkgnd);
begin
message.Result := 0
end; | |  | |  |
Comments:
|
anonymous from Brazil
|
|
|
|
|
|