Solved

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

Posted on 2010-08-17
6
1,475 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
ID: 33465819
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
ID: 33466642
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
ID: 33467193
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:sn1fflez
ID: 33467514
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
ID: 33467557
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
ID: 33467928
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

22 Experts available now in Live!

Get 1:1 Help Now