Board index » delphi » Problem with flicker when resizing but not when moving?

Problem with flicker when resizing but not when moving?


2004-06-13 05:14:19 AM
delphi276
Hi everybody,
I have a very interesting flicker problem that I cannot solve...
I have a TShape (SH) and a TCustomControl (CC). CC lies on top of SH. When
CC is being moved or resized (by the mouse) it is programmed to move or
resizeSH with it.
SH and CC are placed on a scrollbox, which is their parent and
scrollbox.DoubleBuffered is set to true. I made the form CC's and SH's
owner.
Now, when I MOVE CC (and thus SH) there is no flicker. But when I RESIZE CC
(and thus again also SH) there is!
Can anybody tell me why this is? If I make it so that CC (the top control)
still receives the mouse input but does not actually resize itself and I
make ONLY SH resize, there is no flicker either. So it seems that flicker
occurs because the two controls BOTH are being resized. But why is there
then no flicker when both are moved?
I'm very curious about any answers you might have.
Thanks for reading sofar,
Vinz.
 
 

Re:Problem with flicker when resizing but not when moving?

Vincent Koopman writes:
Quote
But why is there
then no flicker when both are moved?

I'm very curious about any answers you might have.
I'd say moving doesn't change ClientWidth etc, so the CC has no reason to
repaint itself (because it is immobile within its container SH).
On a similar occasion (creating a TScrollImage) I noticed that panning
inside the scrollbox (by moving the origin of the contained image) produced
flicker. Panning by simply modifying the scrollbar positions didn't cause
any flicker.
Bottom line: Whenever you can, don't mess with children. Go after the
parents. :)
--
Ben
 

Re:Problem with flicker when resizing but not when moving?

Quote
I'd say moving doesn't change ClientWidth etc, so the CC has no reason to
repaint itself (because it is immobile within its container SH).

On a similar occasion (creating a TScrollImage) I noticed that panning
inside the scrollbox (by moving the origin of the contained image)
produced
flicker. Panning by simply modifying the scrollbar positions didn't cause
any flicker.

Bottom line: Whenever you can, don't mess with children. Go after the
parents. :)
But CC is simply on top of SH. it is not a container as you say. I am using
code to resize SH That code gets executed when CC is being resized.
Is there a way CC can be a container perhaps?
Regards,
Vinz.
 

Re:Problem with flicker when resizing but not when moving?

Vincent Koopman writes:
Quote
But CC is simply on top of SH. it is not a container as you say. I am using
code to resize SH That code gets executed when CC is being resized.

Is there a way CC can be a container perhaps?
What happens if you put both the Shape SH and the CustomControl CC into a
TPanel? Then you can align SH to alClient and manually resize CC in the
Panel's OnResize event handler.
--
Ben
 

Re:Problem with flicker when resizing but not when moving?

It's for a designer program. Compare it with the IDE of Delphi, or Rational
Rose or stuff like that. So the user 'drops' a control or UML object
whatever and my component will automatically put a handle on top that is
responsible for showing the black dots around the edges etc.
So using a panel is not a very cool option. Can a panel be made seethrough
for example? And it makes the component heavier too...
"Ben Hochstrasser" <bhoc@surfeu123^H^H^H.ch>writes
Quote
Vincent Koopman writes:

>But CC is simply on top of SH. it is not a container as you say. I'm
using
>code to resize SH That code gets executed when CC is being resized.
>
>Is there a way CC can be a container perhaps?

What happens if you put both the Shape SH and the CustomControl CC into a
TPanel? Then you can align SH to alClient and manually resize CC in the
Panel's OnResize event handler.

--
Ben
 

Re:Problem with flicker when resizing but not when moving?

Vincent Koopman writes:
Quote
So the user 'drops' a control or UML object whatever and my component
will automatically put a handle on top that is responsible for showing
the black dots around the edges etc.
Okay, now I finally see what you're after. ;-)
Okay. What are you resizing first, the Shape or the Control? Because
resizing either of them will trigger some repaint event which usually
results in a flicker. (resizing the control will cause the system to
repaint the shape, but resizing the shape won't cause the system to repaint
the control, because the latter is on top anyway).
Sounds mighty scientific, eh? Anyway, try to swap the resize code for the
shape and the control and see if that helps any.
--
Ben
 

Re:Problem with flicker when resizing but not when moving?

Quote
Okay. What are you resizing first, the Shape or the Control? Because
resizing either of them will trigger some repaint event which usually
results in a flicker. (resizing the control will cause the system to
repaint the shape, but resizing the shape won't cause the system to
repaint
the control, because the latter is on top anyway).
Sounds mighty scientific, eh? Anyway, try to swap the resize code for the
shape and the control and see if that helps any.
I tried that already for a simple event where you 'pull' on the right side
and it didn't seem to help.
Maybe I have to look at the repaints -again- ...
It seems that when the top-control is repainted the flicker occurs, not when
the bottom one is repainted.
Thanks for your help sofar mate,
Vinz.
 

Re:Problem with flicker when resizing but not when moving?

Vincent Koopman writes:
Quote
It seems that when the top-control is repainted the flicker occurs,
not when the bottom one is repainted.
Did you find out with what type of controls (TEdit, TListBox, TMemo) the
flickering occurs? Will some flicker more than others? Would BeginUpdate/
EndUpdate help in such cases?
--
Ben
 

Re:Problem with flicker when resizing but not when moving?

A move generates only two small bands of update area, while a resize
generates the complete shape surface as update area.
To get more control over update areas and repainting, you can try our
TVirtualScrollbox, which is specifically aimed towards that. Perhaps
DtpDocuments might also interest you, as a base for your own shapes,
completely flicker free and automatic support for rotation and
alpha-blending, as well as resize and rotate handles.
www.simdesign.nl/virtualscrollbox.html
www.simdesign.nl/dtpdocuments.html
Kind regards,
Nils Haeck
PS I am Dutch too.
"Vincent Koopman" writes news:XXXX@XXXXX.COM...
Quote
Hi everybody,

I have a very interesting flicker problem that I cannot solve...

I have a TShape (SH) and a TCustomControl (CC). CC lies on top of SH. When
CC is being moved or resized (by the mouse) it is programmed to move or
resizeSH with it.

SH and CC are placed on a scrollbox, which is their parent and
scrollbox.DoubleBuffered is set to true. I made the form CC's and SH's
owner.

Now, when I MOVE CC (and thus SH) there is no flicker. But when I RESIZE
CC
(and thus again also SH) there is!

Can anybody tell me why this is? If I make it so that CC (the top control)
still receives the mouse input but does not actually resize itself and I
make ONLY SH resize, there is no flicker either. So it seems that flicker
occurs because the two controls BOTH are being resized. But why is there
then no flicker when both are moved?

I'm very curious about any answers you might have.

Thanks for reading sofar,

Vinz.


 

Re:Problem with flicker when resizing but not when moving?

More information:
I did a test putting my TStretchControl over a TShape. TStretchControl =
class (TCustomControl)
The StretchControl has a property 'Control' where the Shape is being put.
The stretchcontrol gets the mouse input and as it moves it moves the shape
underneath with it. They both have the same parent and parent.doublebuffered
:= true;
Now I also created another TShape without a stretchcontrol on top. Same
parent. If I resized this one (using it is own mousedown/over events) there
was NO flicker. So the flicker seems to be caused by the stretchcontrol.
Settings Stretchcontrol.Doublebuffered := true doesn't help either.
Is that any help?
Cheers,
Vinz.
PS: BeginUpdate and EndUpdate do not apply here I think?
"Ben Hochstrasser" <bhoc@surfeu123^H^H^H.ch>writes
Quote
Vincent Koopman writes:

>It seems that when the top-control is repainted the flicker occurs,
>not when the bottom one is repainted.

Did you find out with what type of controls (TEdit, TListBox, TMemo) the
flickering occurs? Will some flicker more than others? Would BeginUpdate/
EndUpdate help in such cases?

--
Ben
 

Re:Problem with flicker when resizing but not when moving?

Vincent Koopman writes:
Quote
Now I also created another TShape without a stretchcontrol on top.
Same parent. If I resized this one (using it is own mousedown/over
events) there was NO flicker. So the flicker seems to be caused by the
stretchcontrol. Settings Stretchcontrol.Doublebuffered := true doesn't
help either.

Is that any help?
Well, in some way it is - looks as if the Stretchcontrol, when resized,
fires other events that make it flicker. (typically this happens when you
in the OnResize handler mangle the dimensions of the control without
temporarily disabling the OnResize event).
Dumb question: will it flicker only with the TShape underneath it or will
it flicker anyway?
--
Ben
 

Re:Problem with flicker when resizing but not when moving?

Hi Vincent,
Quote
I have a very interesting flicker problem that I cannot solve...

I have a TShape (SH) and a TCustomControl (CC). CC lies on top of SH. When
CC is being moved or resized (by the mouse) it is programmed to move or
resizeSH with it.
Is your custom control "transparent" ?
type
TStretchControl = class(TCustomControl)
{...}
protected
procedure CreateParams(var Params: TCreateParams); override;
{...}
end;
procedure TStretchControl.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle + WS_EX_TRANSPARENT;
end;
Regards,
Jean-Marie
 

Re:Problem with flicker when resizing but not when moving?

Hi JM,
The StretchControl is indeed transparent. Is that a problem or should that
help?
Regards,
Vinz.
Quote
Is your custom control "transparent" ?

type
TStretchControl = class(TCustomControl)
{...}
protected
procedure CreateParams(var Params: TCreateParams); override;
{...}
end;

procedure TStretchControl.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle + WS_EX_TRANSPARENT;
end;

Regards,

Jean-Marie


 

Re:Problem with flicker when resizing but not when moving?

Quote
The StretchControl is indeed transparent. Is that a problem or should that
help?
Yes, normally, this should help...
J.M.