Is there a way to use the Double Buffer property and keep Transparency? I have several Canvas Controls that function as buttons but when I set them to either Enable True or False there is a momentary flicker on each canvas. I need the Canvas Buttons to be set Enable False depending on the circumstances.
I know that Windows doesn’t Auto Double Buffer like Mac OS X. I need the transparency and Double Buffer. Is there a way to have both.
I am simply using a tmpImage for each Canvas Button with the Paint Event and calling Refresh(False) when I first set the image and only when the image changes.
I haven’t done Double Buffering in RealBasic with Windows for several years so I’m a little out of date.
Double-buffer only means that you don’t do many small paints but one big one. So if you keep all your paints into a transparent picture the double-buffering should work transparently with transparency.
You have a g as graphics in the paint event. Instead of doing your drawing there create a picture and use it’s graphics property. Then do paint the picture to your original graphics.
[quote=170306:@Charles Fasano]Is there a way to use the Double Buffer property and keep Transparency? I have several Canvas Controls that function as buttons but when I set them to either Enable True or False there is a momentary flicker on each canvas. I need the Canvas Buttons to be set Enable False depending on the circumstances.
I know that Windows doesn’t Auto Double Buffer like Mac OS X. I need the transparency and Double Buffer. Is there a way to have both.
I am simply using a tmpImage for each Canvas Button with the Paint Event and calling Refresh(False) when I first set the image and only when the image changes.
I haven’t done Double Buffering in RealBasic with Windows for several years so I’m a little out of date.[/quote]
Double buffer or not, I do not see any flicker when I set enabled false or true. Would you post a test project demonstrating ?
Double buffer works if you paint every pixel. Transparency implies not painting certain pixels. So double buffer plus transparency only works if you never paint the “transparent” pixels and always paint the opaque pixels.
No. You can only do simulated transparency. For windows, the secret to flicker free drawing is:
DoubleBuffer = True.
EraseBackground = False.
Never use Refresh, RefreshRect, or Invalidate with the default EraseBackground parameter left as true. I usually override these methods to call the super version with false so that I can’t screw it up.
Never overlap controls.
But this means you lose transparency. Fact of life.
How do I do simulated transparency? I know it involves grabbing a portion of the background and combining it with the top image but it’s been quite some time since I did that so I need a refresher.
Put you canvas with DoubleBuffer off, EraseBackground off, Trasparent ON
in the open event put:
#if TargetWin32
me.DoubleBuffer=True
#Endif
use invalidate to “refresh” the canvas
in the Paint event if you want to simulate transparency set g.trasparency=value where value must be between 0 (solid) to 100 (transparent)
Don’t forget to put Use GDI Plus ON in the windows build setting
g.Transparency=100 does nothing when DoubleBuffer is True
I finally figured out (after much trial and error) how to get the simulated transparency by taking the part of the background image and combining it with the button image.