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. Oh, OnPaintBackground!

Oh, OnPaintBackground!

Scheduled Pinned Locked Moved C#
csharpwinformsbeta-testingcode-review
4 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
    Arun Bhalla
    wrote on last edited by
    #1

    Ah, apparently if I do this: SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); and then override OnPaint, it should look something like this: protected override void OnPaint(PaintEventArgs pe) { base.OnPaintBackground(pe); base.OnPaint(pe); ... } The base.OnPaintBackground(pe) being key to a derived class (say, from a Panel) having its background updated properly. I wasn't aware of this before, and it explains some past frustrations with the WinForms. Any feedback and better suggestions welcome.

    L 1 Reply Last reply
    0
    • A Arun Bhalla

      Ah, apparently if I do this: SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); and then override OnPaint, it should look something like this: protected override void OnPaint(PaintEventArgs pe) { base.OnPaintBackground(pe); base.OnPaint(pe); ... } The base.OnPaintBackground(pe) being key to a derived class (say, from a Panel) having its background updated properly. I wasn't aware of this before, and it explains some past frustrations with the WinForms. Any feedback and better suggestions welcome.

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Or just make UserPaint false, then u draw over the background :) The is also a PaintBackground option AFAIK. leppie::AllocCPArticle("Zee blog");
      Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.

      A 1 Reply Last reply
      0
      • L leppie

        Or just make UserPaint false, then u draw over the background :) The is also a PaintBackground option AFAIK. leppie::AllocCPArticle("Zee blog");
        Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.

        A Offline
        A Offline
        Arun Bhalla
        wrote on last edited by
        #3

        Hmm, I can't find the PaintBackground option. But anyway, I have UserPaint set to true because I want to use DoubleBuffer. It's not exactly clear to me what each other style (e.g. UserPaint, AllPaintingInWmPaint) enables when DoubleBuffer is on. Or, it's not exactly clear to me what I'd lose/gain by making UserPaint false when I have DoubleBuffer on.

        L 1 Reply Last reply
        0
        • A Arun Bhalla

          Hmm, I can't find the PaintBackground option. But anyway, I have UserPaint set to true because I want to use DoubleBuffer. It's not exactly clear to me what each other style (e.g. UserPaint, AllPaintingInWmPaint) enables when DoubleBuffer is on. Or, it's not exactly clear to me what I'd lose/gain by making UserPaint false when I have DoubleBuffer on.

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          Here you go, its called: Opaque If true, the control is drawn opaque and the background is not painted. leppie::AllocCPArticle("Zee blog");
          Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.

          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