Double Buffering in Memory

JCreationsInc

Active member
Joined
May 2, 2003
Messages
42
Location
San Jose Ca (Silicon Valley)
Hello everyone!

I am a vb6 verteran and I am just begining to learn vb.net and it is going pretty well. Luckily I have found this site with such skilled programmers to ask questions to! :D Well then on to my questions.

What I am doing is creating a Program for my Programs that would allow you to easily create "Skins" using a type of designer like vb.net that allows you to drag the images arround the window and place them were you like them to be. But in testing when I drag the image arround the window using drawimage, I get HORRIBLE flicker and I Have tried everything to circumvent it, but to no avail.

In vb6 double buffering was pretty easy, all you had to do was create a DC (Device Context) in memory using "CreateCompatibleDC" then Create a Surface for the image in the DC using "CreateCompatibleBitmap". Then you would draw on you surface and the paint it to your form or picture box.

Now comes GDI+ and Managed code, AAAAAAAAAAAHHHHHHHHHH!!!!!!!! :eek: GDI+ has some nice features and is VERY much more robust than gdi32, but creating a graphics object in memory is so confusing and frustraiting!

So then I google it and I come to this site with these forums and I learn that you can envoke a double buffering method built right into the windows controlstyles namespace. So then I attempt to research it and I get nothing but a headache and a wicked urge to just smash this computer with a 50lb sledge hammer! :mad:

Anyways what I am asking you fine people stuck in my lil box on top of my desk is, how do you Double buffer using an object created in memory? OR how do you use the double buffering built into the .Net Framework?

All imput will be greatly Appreciated!
 
To enable double buffering for a control, use the SetStyle method in the constructor to turn on AllPaintingInWmPaint and DoubleBuffer. That will enable it.

The next thing you must remember to do is do all your drawing in either the Paint event or the OnPaint method if youve overridden it (it doesnt matter which). Next, you must always use the instance of the Graphics class passed to that procedure in the e argument. You dont have to worry about doing anything with offscreen surfaces, Windows Forms takes care of that for you using the fastest possible way (DIB sections).

The only caveat is that you must do all your drawing in that procedure. Use the controls Invalidate method or Refresh method to cause it to be invoked if you need to.
 
Thanks you were a big help you poited me in the right direction!

One other thing how did you learn how to use vs.net? did you goto school? or did you read some books? and if you read books on the subject, do you recomend any for a guy like me?
 

Similar threads

D
Replies
0
Views
63
duoshock
D
J
Replies
0
Views
59
Jalil Sear [MCPD SharePoint]
J
Back
Top