关于VISTA下世界坐标的转换问题!!!请高手指点,谢谢了!!!
我写了一段关于世界坐标转换的代码,用了API,但是实现不了矩形的旋转,是不是VISTA下不能用世界坐标的转换啊?急需高手解答,谢谢了啊!!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 Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Type XFORM
eM11 As Double
eM12 As Double
eM21 As Double
eM22 As Double
eDx As Double
eDy As Double
End Type
Private Sub Form_Paint()
Dim tempXForm As XFORM
Dim r As Long
Const twopi = 6.28318
'设置图形模式为增强的模式(允许世界坐标的转换)
r = SetGraphicsMode(hdc, GM_ADVANCED)
'在VGA的屏幕上世界定义坐标变换(坐标在半周内逆时针旋转依次旋转45°)
For i = 0 To 180 Step 45
tempXForm.eM11 = Cos(i * twopi / 360)
tempXForm.eM12 = -Sin(i * twopi / 360)
tempXForm.eM21 = Sin(i * twopi / 360)
tempXForm.eM22 = Cos(i * twopi / 360)
tempXForm.eDx = 640 / 2
tempXForm.eDy = 480 / 2
'这是旋转转换公式,详情见同一文件夹下的TXT文档。
r = SetWorldTransform(hdc, tempXForm)
'画适合VGA屏幕的矩形
r = Rectangle(hdc, 640 / 4, 480 / 4, 1280 / 4, 960 / 4)
Next i
End Sub