[blue]Private Sub TransformAndDraw(ByVal hdcTarget As Long, ByVal hdcSource As Long, ByVal aboutX As Long, ByVal aboutY As Long, ByVal rotate As Single)
Dim myXForm As XFORM
Dim mypoint As POINTAPI
Dim MemDC As Long
Dim oldBMP As Long
' tek-tips chages: introduce a memory DC rather than directly using DC of source
' picture box; this avoids unexpected beahviour of bitblt
' Create a memory DC compatible with the desktop
MemDC = CreateCompatibleDC(GetDC(GetDesktopWindow()))
' Select our bitmap into it
oldBMP = SelectObject(MemDC, Picture2.Picture.Handle)
' grab original settings so we can restore
GetWorldTransform hdcTarget, gOldWorld
SetGraphicsMode hdcTarget, GM_ADVANCED
' Change MapMode so that SetWorldTransform works properly
SetMapMode hdcTarget, MM_TEXT
' Build rotation transformation matrix
' In this case rotating 'rotate' degrees clockwise about point aboutX, aboutY
myXForm = buildXForm(aboutX, aboutY, rotate)
' Apply the transform
SetWorldTransform hdcTarget, myXForm
' Piece de resistance: bitmap gets rotated even though all we do is a normal BitBlt
BitBlt hdcTarget, 0, 0, 200, 200, MemDC, 0, 0, vbSrcCopy
SetWorldTransform hdcTarget, gOldWorld
SetGraphicsMode hdcTarget, GM_COMPATIBLE
' Clean up the extra stuff we introduced
DeleteDC MemDC
' Everything now back to normal, transform removed
End Sub[/blue]