|
-
Oct 11th, 2001, 09:44 PM
#1
Thread Starter
PowerPoster
BitBlt - not for the faint-hearted...
Hi all, I am making a drawing prog which will place tiles in a square in a nxn grid of 32x32 squares.
The user simply drags a tile to where they want it and Voila!
However, so the user can see where their tile is gonna go (without drawing gridlines on the picture), I want an outline box to position itself where a tile would go as the user drags said tile around the picture.
I am using BitBlt to draw the tiles.
The following sub is called as the user drags a tile around the picture:
********************
Private Sub pictureFront_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
X = (X - (X Mod 32))
Y = (Y - (Y Mod 32))
If ((X = lastX) And (Y = lastY)) Then Exit Sub
lastX = X
lastY = Y
'Draw the outline
BitBlt pictureDragOutlineBuffer.hDC, X, Y, dragOutlineBox.Width / 2, dragOutlineBox.Height, dragOutlineBox.hDC, dragOutlineBox.Width / 2, 0, vbSrcPaint 'The mask, important for transparency
BitBlt pictureDragOutlineBuffer.hDC, X, Y, dragOutlineBox.Width / 2, dragOutlineBox.Height, dragOutlineBox.hDC, 0, 0, vbSrcAnd 'The player himself
'Flip (Copy the buffer to the screen)
#1: BitBlt FrontDC, 0, 0, pictureFront.Width, pictureFront.Height, pictureDragOutlineBuffer.hDC, 0, 0, vbSrcCopy
#2: BitBlt FrontDC, 0, 0, pictureFront.Width, pictureFront.Height, BackDC, 0, 0, vbSrcCopy
Dim A, B
'Draw the background tiles
For A = 0 To pictureFront.Width / Tile.Width
For B = 0 To pictureFront.Height / Tile.Height
BitBlt pictureDragOutlineBuffer.hDC, A * Tile.Width, B * Tile.Height, Tile.Width, Tile.Height, Tile.hDC, 0, 0, vbSrcCopy 'Just copy the memory so no mask
Next
Next
End Sub
********************
However, this doesn't work very well.The lines marked #1 & #2 have the following effect:
#1: draws the pictureBox which has the outline in it onto the canvas
#2: draws the pictureBox which has the actual picture onto the canvas.
If I remove #1, I get no outline when dragging...
If remove #2, the actual picture draws itself over the outline as I go...
As you may have noticed, the outline and the actual picture are 'stored' in two different 'buffer' picture boxes...
Any suggestions?
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|