-
I Have 3 Pictures
All Variables... StdPictures
Code:
Option Explicit
'API
'
Private Declare Function BitBlt Lib "gdi32.dll" (ByVal hdcDest As Long, ByVal nXDest As Long, ByVal nYDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal nYSrc As Long, ByVal dwRop As Long) As Long
'
'Types
Private Type MPicture
ForeLayer As StdPicture
Layer2 As StdPicture
Sprite(10) As StdPicture
Enbedded As StdPicture
End Type
'
'Variables
'
Private ForePicture As MPicture
Sub Render()
ConbinePics
BitBlt FrmTop.Picture, 0, 0, ForePicture.Enbedded.Width, ForePicture.Enbedded.Height, ForePicture.Enbedded.Picture, 0, 0, vbSrcCopy
End Sub
Private Sub ConbinePics()
BitBlt ForePicture.Enbedded.Picture, 0, 0, ForePicture.ForeLayer.Width, ForePicture.ForeLayer.Height, ForePicture.ForeLayer.Picture, 0, 0, vbSrcCopy
BitBlt ForePicture.Enbedded.Picture, 0, 0, ForePicture.Sprite(0).Width, ForePicture.Sprite(0).Height, ForePicture.Sprite(0).Picture, 0, 0, vbSrcCopy
End Sub
It puts together images then it
puts them on the screen ( to the theory
that I think that will stop the flashing
and I should have smooth rendering)
Help?
-
The error occurs when you have datatypes (ie StdPicture) that require initialization before being able to be used.
In order to initialize something you need to use a "Set" command... hence the "Variable not Set" occuring.
There are a few ways of doing this depending on what type of object it is.
Dim objItem as NEW datatype
Or with pictures I think there is a way of using the "Set picObject = loadPicture()" to initialize the object.
Try it ;)
-
I've told him that...
YES, you can use SET to set stdpictures.
I've told you that...
-
As for it giving you smooth rendering and stop the "flashing" I hate to inform you this but it wont.
Not even CLOSE.
The "flashing" is a result of screen updating occuring out of sync with the refresh of the monitor among other things.
The way "graphics" people get around it is called "double-buffering". They create a second version of the screen with the new positions and then "swap" the screens around, working on the hidden screen and swapping again.
Unfortunately unless you are specifically using a DirectX screen map or some other graphical method, the standard form display on VB does not allow you to have any of this kind of functionality.
The flash is there to stay.
-
No, its not.
The flash can be gotten rid of.
For double-buffering using plain VB forms, you can do this:
1. Create a hidden picturebox set its AutoRedraw to True
2. In the refresh code, BitBlt etc onto the picturebox
3. At the end of the refresh code, BitBlt the picturebox onto the form
4. Observe your flickering disappear.
-
You may want to set the PictureBox to have no border as well.
Sorry. My oversight.
-
Great idea.