CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2006
    Posts
    357

    GDI Drawing on usercontrol causes excessive tearing

    Hey,

    I had a form that generated a simple graph that you can manipulate, all done through GDI and it works great, although i have double buffering on the form.

    Now im having to change alot of these forms into usercontrols so that i can house them all within tab pages in another form...

    Anyway now ive put them into the tab control and there is alot of tearing whenever i change the values (thats when it refreshes), the containers used to be:

    Form - GDI Drawing

    Now its

    Form
    |
    | - TabPanelControl
    | |
    | | - TabPageControl
    | | |
    | | | - CustomControl - GDI Drawing


    So im wondering if its down to it being placed in another control, ive set the form to double buffered, anyway if anyone has any advice let me know!

  2. #2
    Join Date
    Nov 2006
    Posts
    357

    Re: GDI Drawing on usercontrol causes excessive tearing

    Just incase anyone else has this problem i was able to solve this problem by adding this to the constructor of my control:

    Code:
    this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
                this.UpdateStyles();

  3. #3
    Join Date
    Jun 2008
    Posts
    2,477

    Re: GDI Drawing on usercontrol causes excessive tearing

    I didn't really know what you meant by 'tearing', but I guess now that you meant flashing. It was happening because your grid was no longer double buffered once you removed it as a child of the form. Setting a form to double buffered means that its graphics object will be double buffered, it does not propagate down to all the children.

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

Featured