Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21314

Multiple BitBlt Routines Causing Flicker

$
0
0
I have created a subroutine that I can simply call whenever I need to use BitBlt:

Code:

Public Function DoBitBlt(theBuffer As PictureBox, THESTAGE As Object, THEBACKGROUND As PictureBox, THECHARACTER As PictureBox, THECHARACTERMASK As PictureBox, theCharacterNewX As Long, theCharacterNewY As Long)
theBuffer.Width = THEBACKGROUND.Width
theBuffer.Height = THEBACKGROUND.Height
THECHARACTERMASK.Width = THECHARACTER.Width
THECHARACTERMASK.Height = THECHARACTER.Height

BitBlt theBuffer.hdc, 0, 0, Val(theBuffer.Width / Screen.TwipsPerPixelX), Val(theBuffer.Height / Screen.TwipsPerPixelY), THEBACKGROUND.hdc, 0, 0, vbSrcCopy

BitBlt theBuffer.hdc, theCharacterNewX, theCharacterNewY, THECHARACTER.Width, THECHARACTER.Height, THECHARACTERMASK.hdc, 0, 0, vbSrcAnd
BitBlt theBuffer.hdc, theCharacterNewX, theCharacterNewY, THECHARACTER.Width, THECHARACTER.Height, THECHARACTER.hdc, 0, 0, vbSrcPaint

BitBlt THESTAGE.hdc, 0, 0, THESTAGE.ScaleWidth, THESTAGE.ScaleHeight, theBuffer.hdc, 0, 0, vbSrcCopy
End Function

In a Timer with an interval of 100, I am calling this subroutine twice (I have two separate pictures I am attempting to BitBlt). If I were to comment out one, the other would work flawlessly. However, when both are called, I get flicker. :eek:

One picture is animating. The other picture is non-animating. The problem is if you BitBlt one thing on a PictureBox, you have to do it to everything else that you want to appear. You can't just drop a PictureBox on the scenery picture... it just won't show.

Therefore, my question is: How do I BitBlt two or more pictures (animated and non-animated) without causing flicker?

Viewing all articles
Browse latest Browse all 21314

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>