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
  1. Home
  2. General Programming
  3. C#
  4. Paintdesktop Api with back buffer

Paintdesktop Api with back buffer

Scheduled Pinned Locked Moved C#
graphicscsharpjsontutorialquestion
3 Posts 2 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.
  • A Offline
    A Offline
    AndyBob
    wrote on last edited by
    #1

    Hi all. I'm trying to use the paintdesktop api call in a c# application. I'm using the following code in the paint event of the form, but this causes a lot of flickering when it draws.

       Graphics g = this.CreateGraphics(); // Create compatible graphics object
       IntPtr hdc = g.GetHdc(); // Get HDC of graphics
       PaintDesktop(hdc); // Draw the system wallpaper
       g.ReleaseHdc(); // Release HDC so other drawing can take place
       g.DrawImage(Interface, 0, 0); // Draw the interface over wallpaper
       g.Dispose(); // Dispose graphics object
    

    I presume that I need to use some form of backbuffering to stop this flickering, however trying to draw the wallpaper with paintdesktop to a system.drawing.bitmap fails. I *think* I would be able to draw it to a bitmap created with the api createbitmap, but don't really know how to use this call or then get a HDC to such a bitmap and haven't been able to find any simple instructions for .net. Can anyone provide a sample or a link to an *easy* article which explains it, or suggest another way reduce the flickering? Or does anyone have any experience with or links to articles about paintdesktop with .net that they could share? Thanks!

    H 1 Reply Last reply
    0
    • A AndyBob

      Hi all. I'm trying to use the paintdesktop api call in a c# application. I'm using the following code in the paint event of the form, but this causes a lot of flickering when it draws.

         Graphics g = this.CreateGraphics(); // Create compatible graphics object
         IntPtr hdc = g.GetHdc(); // Get HDC of graphics
         PaintDesktop(hdc); // Draw the system wallpaper
         g.ReleaseHdc(); // Release HDC so other drawing can take place
         g.DrawImage(Interface, 0, 0); // Draw the interface over wallpaper
         g.Dispose(); // Dispose graphics object
      

      I presume that I need to use some form of backbuffering to stop this flickering, however trying to draw the wallpaper with paintdesktop to a system.drawing.bitmap fails. I *think* I would be able to draw it to a bitmap created with the api createbitmap, but don't really know how to use this call or then get a HDC to such a bitmap and haven't been able to find any simple instructions for .net. Can anyone provide a sample or a link to an *easy* article which explains it, or suggest another way reduce the flickering? Or does anyone have any experience with or links to articles about paintdesktop with .net that they could share? Thanks!

      H Offline
      H Offline
      Hayder Marzouk
      wrote on last edited by
      #2

      Hi, I Created an application that allows user to draw shapes, pictures,... I had also flickering problem and a single line of code resolved my problem. Try this line in the Initilization of ure Control/Form : SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); Change the first argument to ure needs. HTH. Hayder Marzouk

      A 1 Reply Last reply
      0
      • H Hayder Marzouk

        Hi, I Created an application that allows user to draw shapes, pictures,... I had also flickering problem and a single line of code resolved my problem. Try this line in the Initilization of ure Control/Form : SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); Change the first argument to ure needs. HTH. Hayder Marzouk

        A Offline
        A Offline
        AndyBob
        wrote on last edited by
        #3

        Thanks for the suggestion, but using that line causes just the form to be blank - from what I can gather paindesktop doesn't support double-buffering in that way :(

        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