'精彩100之VB源程序:
Private Type LOGFONT_TYPE
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lffacename As String * 32
End Type
Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT_TYPE) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As LongPublic Sub RotateText(Degrees As Integer, obj As Object, fontname As String, Fontsize As Single, X As Integer, Y As Integer, Caption As String)
Dim RotateFont As LOGFONT_TYPE
Dim CurFont As Integer, rFont As Integer, foo As Integer
RotateFont.lfEscapement = Degrees * 10
RotateFont.lffacename = fontname & Chr$(0)
If obj.FontBold Then
RotateFont.lfWeight = 800
Else
RotateFont.lfWeight = 400
End If
RotateFont.lfHeight = (Fontsize * -20) / Screen.TwipsPerPixelY
rFont = CreateFontIndirect(RotateFont)
CurFont = SelectObject(obj.hdc, rFont)
obj.CurrentX = X
obj.CurrentY = Y
obj.Print Caption
'Restore
foo = SelectObject(obj.hdc, CurFont)
foo = DeleteObject(rFont)
End SubPrivate Sub Command1_Click(Index As Integer)
Select Case Index
Case 0
RotateText HScroll1.Value, Picture1, "宋体", 16, Picture1.Width / 2, Picture1.Height / 2, "hello world"
Case 1
Picture1.Cls
End Select
End SubPrivate Sub HScroll1_Change()
Label2.Caption = HScroll1.Value
End SubPrivate Sub CommandExit_Click()
End
End Sub
Private Type LOGFONT_TYPE
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lffacename As String * 32
End Type
Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT_TYPE) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As LongPublic Sub RotateText(Degrees As Integer, obj As Object, fontname As String, Fontsize As Single, X As Integer, Y As Integer, Caption As String)
Dim RotateFont As LOGFONT_TYPE
Dim CurFont As Integer, rFont As Integer, foo As Integer
RotateFont.lfEscapement = Degrees * 10
RotateFont.lffacename = fontname & Chr$(0)
If obj.FontBold Then
RotateFont.lfWeight = 800
Else
RotateFont.lfWeight = 400
End If
RotateFont.lfHeight = (Fontsize * -20) / Screen.TwipsPerPixelY
rFont = CreateFontIndirect(RotateFont)
CurFont = SelectObject(obj.hdc, rFont)
obj.CurrentX = X
obj.CurrentY = Y
obj.Print Caption
'Restore
foo = SelectObject(obj.hdc, CurFont)
foo = DeleteObject(rFont)
End SubPrivate Sub Command1_Click(Index As Integer)
Select Case Index
Case 0
RotateText HScroll1.Value, Picture1, "宋体", 16, Picture1.Width / 2, Picture1.Height / 2, "hello world"
Case 1
Picture1.Cls
End Select
End SubPrivate Sub HScroll1_Change()
Label2.Caption = HScroll1.Value
End SubPrivate Sub CommandExit_Click()
End
End Sub
http://www.5ivb.net/zyl910/zyl910_Rotate.zip