Strange Painting[FIXED YAY!]

  • 15 years ago

    Awhile back I developed a button control.  Now I noticed that they are painting in VERY STRANGE ways.
    Like on one form that contains like 30 of them, for each button, around the outside where i dont draw, its black.  and one button draws its own image, but also images of other buttons... To make it even stranger, some buttons draw the text of the label that is next to them (!).


    I have no idea whats going on, nowhere in the Overriden OnPaint did i tell the buttons to render this way (obviously).  Anyone have any suggestions because Im going to have to redo most of the class if I cant find a solution (i could rework it to make it better, but not worth it...)


    Also, it seems whatever button had the mouse over it last gets painted into the upperleft corner of the buttons with flatstyle = popup.  What is happening here!?!?!

  • 15 years ago

    Is there anyone out there who has experiance with designing their own controls in .NET???
    Im really confused... I think this is how painting works if you inherit from 'Control'
    Even if you override OnPaint, the BackColor still gets painted over everything before the overriden OnPaint gets called.  Then your paint code is called and u paint to a buffer which then gets sent to the screen... am i missing something here because i have no clue how this behavior is happening... I guess I'll just redo the control.. sigh

  • 15 years ago

    the title says its fixed... is it?

  • 15 years ago

    Ya, apparantly setting the style to Opaque caused all this behavior, dont ask me how cause if you take it to mean the actual definition of opaque... its just means if something is solid or not.

  • 13 years ago

     i am also having same problem.

     in my application i m using a picture box control to draw a real time graph and this graph is plotting point and at the same time it moving a rectangle which color is same as background color so it will remove previous plotted  points, in my application i m using double buffring for the user control
     

      private void SetForDoubleBuffring()
            {
                this.SetStyle(ControlStyles.AllPaintingInWmPaint |
                                      ControlStyles.UserPaint |
                                      ControlStyles.OptimizedDoubleBuffer |
                                      ControlStyles.DoubleBuffer, true);
            }

    but still i m getting small flickering  , i want to remove this flickering  completely.

    i am expecting this problem is due to garbage collector, which refresh memory and result of that getting this flickering, i am not sure but may be this due to our weak reference, but still fighting with problem.

    please if anyone have any idea    please suggest me.

    Thanks in advance

    Jitendra
    [email protected]

     

     

     

     

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Linux is only free if your time has no value” - Jamie Zawinski