Real Software Forums
http://forums.realsoftware.com/

DoubleBuffer/EraseBackground Help requested
http://forums.realsoftware.com/viewtopic.php?f=6&t=39429
Page 1 of 2

Author:  lenpartico [ Wed Jun 15, 2011 8:51 am ]
Post subject:  DoubleBuffer/EraseBackground Help requested

Hello,

I have this code in the open event of Canvas1:

#If TargetWin32 then //Windows only
Me.DoubleBuffer = True
Me.EraseBackground = False

#else //Linux and Macintosh

#endif

and when I scroll I still see the background being erased and get flickering.

How can I fix that?

Thanks.

Lennox.

Author:  kermit [ Wed Jun 15, 2011 10:05 am ]
Post subject:  Re: DoubleBuffer/EraseBackground Help requested

How are you scrolling?

Author:  lenpartico [ Wed Jun 15, 2011 10:19 am ]
Post subject:  Re: DoubleBuffer/EraseBackground Help requested

This is the code in ScrollBar1

In the ScrollBar1.ValueChanged event:
#If TargetWin32 then //Windows only
Canvas1.DoubleBuffer = True
Canvas1.EraseBackground = False

#else //Linux and Macintosh

#endif

Canvas1.Refresh



In the ScrollBar1ScrollBar1.Open event:
ScrollBar1.Maximum = Max(Canvas1.Height - self.Height, 0)
ScrollBar1.Value = Min(ScrollBar1.Value, ScrollBar1.Maximum)


Lennox

Author:  timhare [ Wed Jun 15, 2011 2:37 pm ]
Post subject:  Re: DoubleBuffer/EraseBackground Help requested

Canvas.Refresh defaults to EraseBackground = True. That is causing your flicker. Call it as
canvas1.refresh(false)

Author:  lenpartico [ Wed Jun 15, 2011 7:43 pm ]
Post subject:  Re: DoubleBuffer/EraseBackground Help requested

Thanks timhare,
I did that but no improvements.
Lennox

Author:  timhare [ Wed Jun 15, 2011 11:07 pm ]
Post subject:  Re: DoubleBuffer/EraseBackground Help requested

What are you scrolling? Are you drawing an image in Paint? Do you have controls sitting on the canvas? I don't see you calling canvas.scroll. Are you drawing offset by scrollbar.value? We need more information.

Author:  kermit [ Thu Jun 16, 2011 12:17 am ]
Post subject:  Re: DoubleBuffer/EraseBackground Help requested

If you have a big picture and a small canvas:
You want to scroll the picture around so that you see part of it through the canvas.

Set the canvas erasebackground = false in design time. Doesnt matter if it is set on the Mac too.
I dont think doublebuffer makes much difference

In the scrollbar valuechanged event, use canvas1.invalidate false

Set hscroll maximum to picture.width - canvas.width
set vscroll maximum to picture.height - canvas.height

In the canvas paint event,

g.drawpicture bigpicture,0,0,canvas.width,canvas.height,hscroll1.value *-1,vscroll1.value *-1


Do NOT set the .background of the canvas in code as that causes a flash no matter what settings you use.

Author:  lenpartico [ Thu Jun 16, 2011 6:55 am ]
Post subject:  Re: DoubleBuffer/EraseBackground Help requested

Thanks timhare and kermit and sorry about me not being specific.

I have controls sitting on the canvas and I am drawing offset by scrollbar.value.

Lennox

Author:  timhare [ Thu Jun 16, 2011 11:32 am ]
Post subject:  Re: DoubleBuffer/EraseBackground Help requested

If you have controls on the canvas, you will have flicker.

Author:  swort [ Thu Jun 16, 2011 11:48 am ]
Post subject:  Re: DoubleBuffer/EraseBackground Help requested

timhare wrote:
If you have controls on the canvas, you will have flicker.

that should be fixed long time ago.. is there still a feedback report for this?
If so, let's all add +1 to it..;)

I can get up to no other dev env wich has the same problem on windows...(yet)

Author:  lenpartico [ Fri Jun 17, 2011 8:52 am ]
Post subject:  Re: DoubleBuffer/EraseBackground Help requested

OK thanks, flicker cannot be avoided on scrolling because of the canvas redrawing process I figure.

I have several bevelButtons on the canvas and if I mouse-over them fast they become invisible and then visible again, I have no code in their MouseEnter or MouseExit events. What is causing that and how can that be fixed.

Thanks.

Lennox

Author:  pawn [ Fri Jun 17, 2011 9:23 am ]
Post subject:  Re: DoubleBuffer/EraseBackground Help requested

lenpartico wrote:
OK thanks, flicker cannot be avoided on scrolling because of the canvas redrawing process I figure.

I have several bevelButtons on the canvas and if I mouse-over them fast they become invisible and then visible again, I have no code in their MouseEnter or MouseExit events. What is causing that and how can that be fixed.

Thanks.

Lennox


drawinto should get the job done

Author:  lenpartico [ Fri Jun 17, 2011 10:53 am ]
Post subject:  Re: DoubleBuffer/EraseBackground Help requested

Thanks pawn,
I checked drawinto in the LR and got this

RectControl.DrawInto
Method
RectControl.DrawInto ( g as Graphics,x as Integer, y as Integer )
Draws the contents of the RectControl into the specified Graphics context. The parameters x and y are the coordinates of the top, left corner.

I am using this in Canvas1 Paint event:
Bevelbutton1.Top = 100 - ScrollBar1.value
Bevelbutton2.Top = 150 - ScrollBar1.value
Bevelbutton3.Top = 200 - ScrollBar1.value
Bevelbutton4.Top = 250 - ScrollBar1.value
.
.
.

How do I use Drawinto with those parameters?

Thanks.

Lennox

Author:  pawn [ Sat Jun 18, 2011 10:08 pm ]
Post subject:  Re: DoubleBuffer/EraseBackground Help requested

Actually i'm not sure if it'll help with the way you're doing it

But with what you have its probably worth attempting at least,

Bevelbutton1.DrawInto(g,Bevelbutton1.left,Bevelbutton1.top)
Bevelbutton2.DrawInto(g,Bevelbutton2.left,Bevelbutton2.top)
Bevelbutton3.DrawInto(g,Bevelbutton3.left,Bevelbutton3.top)
Bevelbutton4.DrawInto(g,Bevelbutton4.left,Bevelbutton4.top)

Author:  swort [ Sun Jun 19, 2011 8:20 am ]
Post subject:  Re: DoubleBuffer/EraseBackground Help requested

I always do this for windows:

#if TargetWin32 then
me.doubleBuffer = True
me.EraseBackground =Flase
#endif


when refreshing a canvas use (on windows):
Canvas.Refresh(False)

Page 1 of 2 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/