Solved

What are Alternatives to the AutoRedraw Property  (vb6) not available in VB.NET

Posted on 2010-08-17
6
1,447 Views
Last Modified: 2013-12-21
Hello everyone,

Okay, so I've put together an example program demonstrating the effect of not having the autoredraw property (in vb.net) had on my program.
The example program consists of two forms a picturebox and a couple of buttons. I've used the tao framework wrapper for the graphics and all of my code is within the paint event handler. This, apperantly, is not enough to make the graphics persistent. I have included the tao framework installation needed to run the example program in the zip file attached to this question.
Please run the example program, outline what you think is going on in the problem, and give your suggestion to making the graphics more consistently persistent.
I would like to award as many points as possible to every person who has contributed a helpful suggestion (if anyone can tell me how to do this without creating another post) otherwise I will give the best solution/suggestion all of the points.
Things to keep in mind when making suggestions: I must use the picturebox control and opengl (tao framework). I also need to be able to use the code to produce animations so saving the contents of the picturebox and setting it to the .image of the picturebox may not be too practical but I would like to hear opinions on this.
Any and all replies will be greatly appreciated.
Thank you for your time,
Sn1fflez     GraphicsFlicker3.zip
0
Comment
Question by:sn1fflez
  • 3
  • 3
6 Comments
 
LVL 11

Expert Comment

by:ladarling
Comment Utility
What exactly is the example project supposed to do? Ive downloaded and run the example. but the only result I get is that clicking the "Apply" button on the popup invalidates a picture box on the background form and disables it...?
0
 

Author Comment

by:sn1fflez
Comment Utility
Oh I'm sorry I forgot to explain what you should see when you run the project. The sample project should show a disk on a black background. When you first load the project nothing will be shown but if you invalidate the picturebox by moving it off the screen a little the graphics should be drawn. With the graphics drawn, if you then click the button on the upper right of the background form another form should pop up but in doing so the graphics in the picturebox are lost. If you click okay then the graphics should come back but the portion of the screen that was covered by the popup form should not have been repainted correctly.
I beleive losing the graphics on form loads etc. to be a consequence of not having the autoredraw property in vb.net. I would like to know if maybe there is something else that might be going on and an efficient solution to the problem. Hope this helps clarify things a bit better.
0
 
LVL 11

Accepted Solution

by:
ladarling earned 500 total points
Comment Utility
I think a lot of it has to do with your choice of canvas ... I moved the draw code to an override of the main forms OnPaint Event, enabled Double buffering for the form to prevent flicker, and the draw was persistent after a "manual" invalidation (resizing the form, etc... still flakey).... its like the PictureBox object paint event was firing independent of order of the form's event sequence....
So I replaced the picturebox with a standard Panel, and everything works like a charm. If you absolutely -have- to use a picturebox control, then you may have extend or completely control the OnPaint event for it.

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)

        MyBase.OnPaint(e)

        Gl.glLoadIdentity()

        Gl.glClearColor(CInt(&HFF And screencolor) / 255, ((&HFF00 And screencolor) \ 256) / 255, ((&HFF0000 And screencolor) \ 65536) / 255, 0)

        Gl.glClear(Gl.GL_COLOR_BUFFER_BIT Or Gl.GL_DEPTH_BUFFER_BIT)



        Call CameraPrespective()

        Glu.gluLookAt(-4, -2, 2.5, 0, 0, 0, 0, 0, 1)



        Gl.glNewList(1, Gl.GL_COMPILE)

        Gl.glPushMatrix()





        Glu.gluDisk(QuadObj, 2, 3, 32, 64)



        Gl.glPopMatrix()

        Gl.glEndList()

        Gl.glPushMatrix()

        Gl.glCallList(1)

        Gl.glPopMatrix()

        Gl.glFlush()

        Gdi.SwapBuffers(hDC)

    End Sub

Open in new window

0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:sn1fflez
Comment Utility
ladarling:
Thanks for the response, I will look into the changes your suggesting. But, if I do end up going with a picture box:
What do you think about overriding all of the painting handlers for a picturebox to do nothing and then create my own event to handle 100% of all the drawing  done on the picturebox with opengl? would it be possible to override all of the paint handlers of the picturebox to do nothing? which ones are they? onpaint, onpaintbackground, and paint?
0
 

Author Comment

by:sn1fflez
Comment Utility
ps. I want to accept your above post as a solution but I also would like to see more responses from other people. I think the system is set up to distribute the 500 points between all the accepted solutions which I don't think anyone would want so maybe I should just give the 500 with an A grade to the best solution?
0
 
LVL 11

Expert Comment

by:ladarling
Comment Utility
It is possible to override 100% if you create a custom PictureBox that inherits from the original. I have not tried it, but if the base class has the OnPaint function marked as NonOverrideable (unlikely) then you can use the Shadows modifier to nullify its effect.
 
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now