Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-08-17
6
Medium Priority
?
1,588 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
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 video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

670 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