Board index » delphi » double buffering a form or component, Image component flickers when moved

double buffering a form or component, Image component flickers when moved

Hello
I think I saw a post related to this a while ago but missed it, and was
hoping someone could help me (again).
I my Delphi 6 app, I have an Image component that is owned by a Panel. The
image is bigger than the panel, so only a portion is displayed at any time,
and it is 'scrolled' by changing the left and top properties (i.e. Image.Top
: Image.Top - 10 to scroll down for example). This works very well and is
simple, but whenever I move the image this way it flickers and the
underlying panel shows through for a split second. How do I prevent this? I
remember seeing something about double buffering the form or component but
couldn't find anything to that effect in the delphi 6 help.
Can anyone help me? Otherwise this works perfectly.

Thanks,

Gino

 

Re:double buffering a form or component, Image component flickers when moved


Hi Gino,

As I recall, a Panel recieves a WM_ERASEBKGND event and paints the panel.
Right after it recieves a WM_PAINT event and your image is painted.

What you should do is, capture the WM_ERASEBKGND event and paint you image
(or do nothing) to prevent the panel painting it self.

Hope it helps

Regards
  Michael.

Quote
"Gino Costa" <gco...@beld.net> wrote in message news:3c031838_2@dnews...
> Hello
> I think I saw a post related to this a while ago but missed it, and was
> hoping someone could help me (again).
> I my Delphi 6 app, I have an Image component that is owned by a Panel. The
> image is bigger than the panel, so only a portion is displayed at any
time,
> and it is 'scrolled' by changing the left and top properties (i.e.
Image.Top
> : Image.Top - 10 to scroll down for example). This works very well and is
> simple, but whenever I move the image this way it flickers and the
> underlying panel shows through for a split second. How do I prevent this?
I
> remember seeing something about double buffering the form or component but
> couldn't find anything to that effect in the delphi 6 help.
> Can anyone help me? Otherwise this works perfectly.

> Thanks,

> Gino

Re:double buffering a form or component, Image component flickers when moved


Hello again.

Stupid question, but in Delphi, how do I capture this message?
Thanks,

Gino

Quote
"Michael Skovslund" <mich...@kolibri-online.dk> wrote in message

news:3c03a1d6$1_2@dnews...
Quote
> Hi Gino,

> As I recall, a Panel recieves a WM_ERASEBKGND event and paints the panel.
> Right after it recieves a WM_PAINT event and your image is painted.

> What you should do is, capture the WM_ERASEBKGND event and paint you image
> (or do nothing) to prevent the panel painting it self.

> Hope it helps

> Regards
>   Michael.

> "Gino Costa" <gco...@beld.net> wrote in message news:3c031838_2@dnews...
> > Hello
> > I think I saw a post related to this a while ago but missed it, and was
> > hoping someone could help me (again).
> > I my Delphi 6 app, I have an Image component that is owned by a Panel.
The
> > image is bigger than the panel, so only a portion is displayed at any
> time,
> > and it is 'scrolled' by changing the left and top properties (i.e.
> Image.Top
> > : Image.Top - 10 to scroll down for example). This works very well and
is
> > simple, but whenever I move the image this way it flickers and the
> > underlying panel shows through for a split second. How do I prevent
this?
> I
> > remember seeing something about double buffering the form or component
but
> > couldn't find anything to that effect in the delphi 6 help.
> > Can anyone help me? Otherwise this works perfectly.

> > Thanks,

> > Gino

Re:double buffering a form or component, Image component flickers when moved


In Delphi5 in the file "Controls.pas" there is a message handle for that
message (WM_ERASEBKGND), and I think that in Delphi6 there should be the
same handling so all you need is this "Control.DoubleBuffered := true" and
the flicker should be reduced if not disappear.

--
Liran Shahar
Com-N-Sense (www.com-n-sense.com)

Re:double buffering a form or component, Image component flickers when moved


Quote
Gino Costa wrote:

> Stupid question, but in Delphi, how do I capture this message?
> Thanks,

...
  protected
    procedure WMEraseBkgnd(var Message: TWmEraseBkgnd); message
WM_ERASEBKGND;
....

procedure TXXX.WMEraseBkgnd(var Message: TWmEraseBkgnd);
begin
  Message.Result := 1;
end;

--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia

Re:double buffering a form or component, Image component flickers when moved


heh... TImage cannot be double buffered coz it descendant of TGraphicControl
and
DoubleBuffered property refers to TWinControl

thats it... u need to move TImage code to new component that inherits from
TWinControl... it simple i done it in approx 1.5 days with debugging, now
TImage works fine even in control bar

Quote
"Gino Costa" <gco...@beld.net> wrote in message news:3c03b33d_2@dnews...
> Hello again.

> Stupid question, but in Delphi, how do I capture this message?
> Thanks,

> Gino

> "Michael Skovslund" <mich...@kolibri-online.dk> wrote in message
> news:3c03a1d6$1_2@dnews...
> > Hi Gino,

> > As I recall, a Panel recieves a WM_ERASEBKGND event and paints the
panel.
> > Right after it recieves a WM_PAINT event and your image is painted.

> > What you should do is, capture the WM_ERASEBKGND event and paint you
image
> > (or do nothing) to prevent the panel painting it self.

> > Hope it helps

> > Regards
> >   Michael.

> > "Gino Costa" <gco...@beld.net> wrote in message news:3c031838_2@dnews...
> > > Hello
> > > I think I saw a post related to this a while ago but missed it, and
was
> > > hoping someone could help me (again).
> > > I my Delphi 6 app, I have an Image component that is owned by a Panel.
> The
> > > image is bigger than the panel, so only a portion is displayed at any
> > time,
> > > and it is 'scrolled' by changing the left and top properties (i.e.
> > Image.Top
> > > : Image.Top - 10 to scroll down for example). This works very well and
> is
> > > simple, but whenever I move the image this way it flickers and the
> > > underlying panel shows through for a split second. How do I prevent
> this?
> > I
> > > remember seeing something about double buffering the form or component
> but
> > > couldn't find anything to that effect in the delphi 6 help.
> > > Can anyone help me? Otherwise this works perfectly.

> > > Thanks,

> > > Gino

Other Threads