Modul untuk memutarkan atau merotasi font berdasarkan derajat tertentu serta koordinat tertentu menggunakan VB6 - Bagaimana kode serta contoh penggunaannya, bisa Anda lihat di bawah ini:
Option Explicit
Public 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 As String * 33
End Type
Public Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long
Public Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Public Sub RotateFont(pic As PictureBox, fontsize As Integer, fontname As String, x As Integer, y As Integer, degree As Integer, txt As String)
On Error GoTo ErrHandler
Dim F As LOGFONT
Dim hPrevFont As Long
Dim hFont As Long
pic.Cls
F.lfEscapement = 10 * Val(degree)
F.lfFacename = fontname
F.lfHeight = (fontsize * -20) / Screen.TwipsPerPixelY
pic.fontname = "Arial Black" + Chr$(0)
hFont = CreateFontIndirect(F)
hPrevFont = SelectObject(pic.hdc, hFont)
pic.CurrentX = x
pic.CurrentY = y
pic.Print txt
hFont = SelectObject(pic.hdc, hPrevFont)
DeleteObject hFont
Exit Sub
ErrHandler:
MsgBox Err.Description
End Sub
Modul di atas memiliki 7 parameter, Adapun contoh penggunaannya sebagai berikut:
Private Sub Command1_Click()
RotateFont Picture1, 12, "Arial", 90, 2500, _
40, "khoiriyyah.blogspot.com"
'Keterangan:
' 1. Picture1 = PictureBox
' 2. 12 = ukuran huruf
' 3. Arial = nama huruf
' 4. 90 = koordinat X
' 5. 2500 = koordinat Y
' 6. 40 = derajat putaran (0 derajat = normal, 90 derajat = tegak lurus)
' 7. khoiriyyah.blogspot.com = text yang dimasukan ke dalam PictureBox
End Sub