Board index » delphi » Using TSplitter without flicker

Using TSplitter without flicker


2003-10-03 06:06:27 AM
delphi147
I'm splitting a form with TSplitter. On the left, I am painting my own
control. The TSplitter is set to ResizeStyle := rsUpdate. When I move
the splitter at runtime, I get lots of flicker on the left where I'm
painting.
I've tried putting a TImage on the left. I have also tried TPaintBox.
I've used a TBevel and painted directly on the form. I've
double-buffered the image to paint. Every way I have tried it, I get flicker.
Is there any way to move the splitter and paint the image without the
automatic clear?
 
 

Re:Using TSplitter without flicker

"Gary" <XXXX@XXXXX.COM>writes
Quote
I'm splitting a form with TSplitter. On the left, I am painting my own
control. The TSplitter is set to ResizeStyle := rsUpdate. When I move
the splitter at runtime, I get lots of flicker on the left where I'm
painting.

I've tried putting a TImage on the left. I have also tried TPaintBox.
I've used a TBevel and painted directly on the form. I've
double-buffered the image to paint. Every way I have tried it, I get
flicker.

Is there any way to move the splitter and paint the image without the
automatic clear?
Are you by any chance running Windows XP or XP themes? If so, you may want to
check that your control has its ParentBackground property set to False.
Alan.
 

Re:Using TSplitter without flicker

Alan Garny writes:
Quote

Are you by any chance running Windows XP or XP themes? If so, you may want to
check that your control has its ParentBackground property set to False.
Yes, I am running XP themes. None of the controls I have used have a
ParentBackground property.
 

Re:Using TSplitter without flicker

Hi,
Quote
>>Are you by any chance running Windows XP or XP themes? If so, you may
>>want to
>check that your control has its ParentBackground property set to
>False.

Yes, I am running XP themes. None of the controls I have used have a
ParentBackground property.
At least in Delphi 7 TWinControls have the CS_HREDRAW and CS_VREDRAW styles
set when the window class is created. This cause the entire window to
be redrawn EVERY time the size is changed, even if the window is
getting SMALLER. You can create decendants and remove these styles in
CreateParams and see what happens.
--
Jim
Posted with XanaNews 1.15.6.3
 

Re:Using TSplitter without flicker

Jim Kueneman writes:
Quote
At least in Delphi 7 TWinControls have the CS_HREDRAW and CS_VREDRAW styles
set when the window class is created. This cause the entire window to
be redrawn EVERY time the size is changed, even if the window is
getting SMALLER. You can create decendants and remove these styles in
CreateParams and see what happens.
Thanks for the tip, but that doesn't help. I have even turned off themes
in XP and still have the same problem.
 

Re:Using TSplitter without flicker

On Thu, 02 Oct 2003 22:59:07 -0400, Gary<XXXX@XXXXX.COM>said ...
Quote
Jim Kueneman writes:
>At least in Delphi 7 TWinControls have the CS_HREDRAW and CS_VREDRAW styles
>set when the window class is created. This cause the entire window to
>be redrawn EVERY time the size is changed, even if the window is
>getting SMALLER. You can create decendants and remove these styles in
>CreateParams and see what happens.
Does it help if you disable the painting code when the mouse button is
down.
Marc
 

Re:Using TSplitter without flicker

"Gary" <XXXX@XXXXX.COM>writes
Quote
Jim Kueneman writes:
>At least in Delphi 7 TWinControls have the CS_HREDRAW and CS_VREDRAW styles
>set when the window class is created. This cause the entire window to
>be redrawn EVERY time the size is changed, even if the window is
>getting SMALLER. You can create decendants and remove these styles in
>CreateParams and see what happens.

Thanks for the tip, but that doesn't help. I have even turned off themes
in XP and still have the same problem.

Are you handling WM_ERASEBKGND ?
If you are painting your own control completely then you might not need the
background erasing in which case you could add:
procedure WMEraseBkgnd(var Message: TWmEraseBkgnd); message WM_ERASEBKGND;
... to your control and return non-zero (I think) in the message to pretend
you've done it yourself.
Regards
Ian Stuart
 

Re:Using TSplitter without flicker

Ian Stuart writes:
Quote
Are you handling WM_ERASEBKGND ?

If you are painting your own control completely then you might not need the
background erasing in which case you could add:

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

... to your control and return non-zero (I think) in the message to pretend
you've done it yourself.
Thanks, Ian. I tried that, too, but it didn't help. I finally figured
out how to do it. I use a TPaintBox and in the form's OnCreate event, I
do this:
PaintBox1.ControlStyles := PaintBox1.ControlStyles + [csOpaque];
Interestingly, this doesn't work with a TImage, because TImage
dynamically sets and clears the csOpaque flag itself on the fly.