Results 1 to 9 of 9

Thread: [RESOLVED] [2005] GDI drawing disappears with DoubleBuffer on

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Resolved [RESOLVED] [2005] GDI drawing disappears with DoubleBuffer on

    I have created my own control using GDI+. I have overriden the OnPaint event of the user control. The problem is there is a lot of flickering, so I added doublebuffering. But when I do that the control flashes info drawn with GDI flashed twice and disappears. What am I doing wrong?
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: [2005] GDI drawing disappears with DoubleBuffer on

    I've done loads of .net graphics now and I have never seen any evidence that the DoubleBuffer property does anything at all.

    I say turn it off again and handle low level drawing yourself. This is easier than it sounds really although it is harder than VB6's AutoRedraw property...

    Not sure how much you already know about backbuffering (the proper name for doublebuffering ) but basically it means tha you have an image hidden away in RAM tha is the same size as the dimensions of your control. The thing about this RAM buffer is that it never gets messed up by other forms getting in the way o anything like that.

    The ram buffer is completely under your control. From your control's perspective all it has to do to implement backbuffering is to copy the ram buffer onto its own surface in it paint event. Thats it!

    So if you want to (for example) draw a line on the control all you have to do is draw it onto the RAM buffer INSTEAD and then simply invalidate() the control and as if by magic you have persistent graphics.

    If you want higher speed redrawing then you need to use control.SetStyle(...) to set a few flags in the control that determine how much control MS Windows has over your own drawing procedures. You need to set the UserPaint flag and a few others (i can't remember the names offhand, i'll get back to you if you PM me).
    Last edited by wossname; Mar 31st, 2006 at 01:05 PM.
    I don't live here any more.

  3. #3
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2005] GDI drawing disappears with DoubleBuffer on

    Quote Originally Posted by wossname
    Not sure how much you already know about backbuffering (the proper name for doublebuffering )
    Proper name? Wouldn't the "proper name" be BitBlt?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: [2005] GDI drawing disappears with DoubleBuffer on

    Thanks for the info Woss, I think I found a good how to for dealing with the low level drawing. I'll try that out.
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  5. #5
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    Re: [2005] GDI drawing disappears with DoubleBuffer on

    Proper name? Wouldn't the "proper name" be BitBlt?
    no, i dont think so

    because the doublebuffer technique is about drawing all the things in memory before displaying the final version of the graphics once on screen ( that is how it prevents flickering while drawing several details on screen).

    so according to this discription i think it is back buffereing than bitbilt

  6. #6
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2005] GDI drawing disappears with DoubleBuffer on

    Quote Originally Posted by maged
    no, i dont think so

    because the doublebuffer technique is about drawing all the things in memory before displaying the final version of the graphics once on screen ( that is how it prevents flickering while drawing several details on screen).

    so according to this discription i think it is back buffereing than bitbilt
    Back buffering and double buffering are the same as BitBlit. They all draw everything off the screen and then load it onto the screen.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: [2005] GDI drawing disappears with DoubleBuffer on

    It worked like a charm Woss. This is going to help me udles.
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  8. #8
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    Re: [2005] GDI drawing disappears with DoubleBuffer on

    yes i know,

    we were just arguing about the proper name.

    anyway i just answered to teaze him

  9. #9
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: [2005] GDI drawing disappears with DoubleBuffer on

    Quote Originally Posted by kasracer
    Back buffering and double buffering are the same as BitBlit. They all draw everything off the screen and then load it onto the screen.
    Kasracer, get a grip. BitBlt is the name of a Function in GDI. It means "Bit Block Transfer". It is often used during the backbufferig process but it is only PART of that process.

    You can quite easily use BitBlt between 2 onscreen buffers, there is no reason to assume that BitBlt is only used for backbuffering. Thats like saying that a screwdriver is only ever used in building Ikea coffee tables.

    mpdeglau, great I'm glad to help.
    I don't live here any more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width