Bandit33x
12-11-2002, 12:14 PM
Can You put label and text boxes on an angle? |
View Full Version : Rotating Text Box
Can You put label and text boxes on an angle? |
hey, you can use the createfont and selectobject API to rotate text for a picture box very simply. here's quick little demo for ya... put a picture box on a form (leave as picture1) Private Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal H As Long, ByVal W As Long, ByVal E As Long, ByVal O As Long, ByVal W As Long, ByVal I As Long, ByVal u As Long, ByVal S As Long, ByVal C As Long, ByVal OP As Long, ByVal CP As Long, ByVal Q As Long, ByVal PAF As Long, ByVal F As String) 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 Public Sub changeFont(esc As Long) Dim New_Font_Hnd As Long Dim Old_Font_Hnd As Long ' to change the angle the text just change the value of "esc" New_Font_Hnd = CreateFont( _ 16, _ 16, _ esc, _ 0, _ 0, _ True, _ True, _ False, _ 0, _ 0, _ 0, _ 0, _ 0, _ "timenewroman") ' now select the new font for the picture object Old_Font_Hnd = SelectObject(Picture1.hdc, New_Font_Hnd) With Picture1 .ScaleMode = vbPixels .CurrentX = (.ScaleWidth / 2) - 100 - 16 * 3 .CurrentY = .ScaleHeight / 2 Form1.Picture1.Print "UseTheForce" End With '[clean up] ' now release new font and set back to old font New_Font_Hnd = SelectObject(Picture1.hdc, Old_Font_Hnd) ' delete our new font object DeleteObject New_Font_Hnd End Sub ' ------------------ Call routine ----------------- Private Sub Form_Load() Call changeFont(100) '<-- simply call routine like this End Sub enjoy Regan |