Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Problem with double buffering in GDI+

Problem with double buffering in GDI+

Scheduled Pinned Locked Moved C#
winformsgraphicshelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    djkno3
    wrote on last edited by
    #1

    I'm having a problem double buffering my form. I use SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); and the last line gives me a System.ArgumentException. The additional info is Invalid argument used... I checked out the MSDN and it says to use them like this. They are inside the Form() constructor. Anybody have any clue why this is happening?

    N J 2 Replies Last reply
    0
    • D djkno3

      I'm having a problem double buffering my form. I use SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); and the last line gives me a System.ArgumentException. The additional info is Invalid argument used... I checked out the MSDN and it says to use them like this. They are inside the Form() constructor. Anybody have any clue why this is happening?

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      public Form1()
      {
      //
      // Required for Windows Form Designer support
      //
      InitializeComponent();
      //
      // TODO: Add any constructor code after InitializeComponent call
      //
      SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true);

      }

      This code itself does not cause a compile time error, as I placed the code inside a blank application itself and it compiles fine, you may have other issues inside your constructor.


      Nick Parker

      Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein

      D 1 Reply Last reply
      0
      • N Nick Parker

        public Form1()
        {
        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();
        //
        // TODO: Add any constructor code after InitializeComponent call
        //
        SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true);

        }

        This code itself does not cause a compile time error, as I placed the code inside a blank application itself and it compiles fine, you may have other issues inside your constructor.


        Nick Parker

        Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein

        D Offline
        D Offline
        djkno3
        wrote on last edited by
        #3

        I figured it out :-D I was looping the call to the OnPaint() and inside I used a graphics object. I mistakenly Dispose()'ed of the PaintEvenArg instead of the graphics object.. I guess it doesn't like that :-D because I took the call to Dispose() out and it works fine now :-D

        1 Reply Last reply
        0
        • D djkno3

          I'm having a problem double buffering my form. I use SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); and the last line gives me a System.ArgumentException. The additional info is Invalid argument used... I checked out the MSDN and it says to use them like this. They are inside the Form() constructor. Anybody have any clue why this is happening?

          J Offline
          J Offline
          Jon Rista
          wrote on last edited by
          #4

          You have to do it like this: SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); Each successive call to SetStyle eleminates the previous setting and changes it to the new one. So, essentially, your just calling SetStyle(ControlStyles.DoubleBuffer). Because double buffering has to be used in conjunction with UserPaint and AllPaintingInWmPaint, you get the error Invalid Argument Used. Using a bitwise or, you combine the values of all three into one setting. Hope this helps.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups