Solved

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

Posted on 2010-08-17
6
1,511 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 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

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