' Draw the picture at (CurX, CurY).
Private Sub DrawPicture()
' Fix the part of the image that was covered.
BitBlt picCanvas.hDC, _
OldX, OldY, PicWid, PicHgt, _
picHidden.hDC, OldX, OldY, SRCCOPY
OldX = CurX
OldY = CurY
' Paint on the new image.
BitBlt picCanvas.hDC, _
CurX, CurY, PicWid, PicHgt, _
picXMask.hDC, 0, 0, MERGEPAINT
BitBlt picCanvas.hDC, _
CurX, CurY, PicWid, PicHgt, _
picX.hDC, 0, 0, SRCAND
' Update the display.
picCanvas.Refresh
End Sub
|
' Start moving the image.
Private Sub picCanvas_MouseUp(Button As Integer, Shift As _
Integer, x As Single, y As Single)
Dim dist As Single
' See where to move the image.
NewX = x - PicWid / 2
NewY = y - PicHgt / 2
If NewX < 0 Then NewX = 0
If NewX > Xmax Then NewX = Xmax
If NewY < 0 Then NewY = 0
If NewY > Ymax Then NewY = Ymax
' Calculate the moving offsets.
Dx = NewX - CurX
Dy = NewY - CurY
DistToMove = Sqr(Dx * Dx + Dy * Dy)
Dx = Dx / DistToMove * MOVE_OFFSET
Dy = Dy / DistToMove * MOVE_OFFSET
' Enable the move timer.
tmrMove.Enabled = True
End Sub
|