Private Const LF_FACESIZE = 32
Private Type LOGFONT
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(1 To LF_FACESIZE) As Byte
End Type
Private Const OBJ_FONT = 6
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" _
(ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal lpString As String, _
ByVal nCount As Long) As Long
Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" _
(lpLogFont As LOGFONT) As Long
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" _
(ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Declare Function GetCurrentObject Lib "gdi32" _
(ByVal hdc As Long, ByVal uObjectType As Long) As Long
Private Declare Function SetTextColor Lib "gdi32" _
(ByVal hdc As Long, ByVal crColor As Long) 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 Long
Private Function GetFont(hdc As Long, Angle As Double) As Long
Dim hFont As Long
Dim lf As LOGFONT
hFont = GetCurrentObject(hdc, OBJ_FONT)
GetObject hFont, Len(lf), lf
lf.lfEscapement = CInt(Angle * 10)
lf.lfOrientation = lf.lfEscapement
GetFont = CreateFontIndirect(lf)
End Function
Private Sub DrawText(hdc As Long, Text As String, X As Integer, Y As Integer, _
Angle As Double, Color As Long)
Dim hFont As Long
Dim hPrevFont As Long
SetTextColor hdc, Color
hFont = GetFont(hdc, Angle)
hPrevFont = SelectObject(hdc, hFont)
TextOut hdc, X, Y, Text, Len(Text)
SelectObject hdc, hPrevFont
DeleteObject hFont
End Sub
Private Sub Form_Paint()
Dim TextToDraw As String
Dim X As Integer
Dim Y As Integer
Dim Angle As Double
Font.Name = "Arial"
Font.Bold = True
Font.Size = 36
TextToDraw = "http://nirsoft.cjb.net"
X = 20: Y = 350
Angle = 45
DrawText hdc, TextToDraw, X - 1, Y - 1, Angle, RGB(0, 0, 255)
DrawText hdc, TextToDraw, X + 1, Y + 1, Angle, RGB(0, 0, 0)
DrawText hdc, TextToDraw, X, Y, Angle, RGB(0, 0, 192)
End Sub
|