Code:
Option Explicit
Private Type XFORM
eM11 As Single
eM12 As Single
eM21 As Single
eM22 As Single
eDx As Single
eDy As Single
End Type
Private Declare Function SetGraphicsMode Lib "gdi32" (ByVal hdc As Long, ByVal iMode As Long) As Long
Private Declare Function SetWorldTransform Lib "gdi32" (ByVal hdc As Long, lpXform As XFORM) As Long
Private Declare Function ModifyWorldTransform Lib "gdi32" (ByVal hdc As Long, lpXform As XFORM, ByVal iMode As Long) As Long
Private Const MWT_IDENTITY = 1
Private Const MWT_LEFTMULTIPLY = 2
Private Const MWT_RIGHTMULTIPLY = 3
Private Const GM_ADVANCED = 2
Private Const GM_COMPATIBLE = 1
Private Sub Form_Load()
SetGraphicsMode Me.hdc, GM_ADVANCED
End Sub
Private Sub Form_Paint()
Dim mtx1 As XFORM, mtx2 As XFORM, c As Single, s As Single, p As IPicture
ModifyWorldTransform Me.hdc, mtx1, MWT_IDENTITY
Me.Line (0, 0)-(Me.ScaleWidth, Me.ScaleHeight), Me.BackColor, BF
c = Cos(hsbAngle.Value / 100)
s = Sin(hsbAngle.Value / 100)
mtx1.eM11 = c: mtx1.eM12 = s: mtx1.eM21 = -s: mtx1.eM22 = c: mtx1.eDx = Me.ScaleWidth / 2: mtx1.eDy = Me.ScaleHeight / 2
mtx2.eM11 = 1: mtx2.eM22 = 1: mtx2.eDx = -Me.ScaleWidth / 2: mtx2.eDy = -Me.ScaleHeight / 2
SetWorldTransform Me.hdc, mtx1
ModifyWorldTransform Me.hdc, mtx2, MWT_LEFTMULTIPLY
End Sub
Private Sub hsbAngle_Change()
Me.Refresh
End Sub