Newsgroup: it.comp.lang.visual-basic
Titolo: Testi ruotati

Esiste un metodo o una funzione che mi permette di ruotare i testi
di 90 gradi per quotature in verticale di disegni?
Se qualcuno si è già cimentato con tale problema mi permetterebbe
di risparmiare un sacco di tempo.
Grazie     
gva...@tin.it

...

Per ruotare i testi l'unico sistema che ho trovato e' stato quello di
utilizzare l'API di windows
per fare cio' e' necessario inserire in un modulo il seguente codice:
Global Const LF_FACESIZE = 32
Type LOGFONT
    lfheight As Integer
    lfwidth As Integer
    lfescapement As Integer
    lforientation As Integer
    lfweight As Integer
    lfitalic As String * 1
    lfunderline As String * 1
    lfstrikeout As String * 1
    lfcharset As String * 1
    lfoutprecision As String * 1
    lfclipprecision As String * 1
    lfquality As String * 1
    lfpitchandfamily As String * 1
    lffacename As String * LF_FACESIZE
End Type
#If Win32 Then
     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
     Declare Function CreateFontIndirect Lib "gdi32" Alias
"CreateFontIndirectA" _
     (lpLogFont As LOGFONT) As Long
     Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal _
     hObject As Long) As Long
     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
     Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As
Long
     Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal
nIndex _
     As Long) As Long
     Declare Function GetTextFace Lib "gdi32" Alias "GetTextFaceA" (ByVal
hdc As _
     Long, ByVal nCount As Long, ByVal lpFacename As String) As Long
 #Else
     Declare Function CreateFont% Lib "GDI" (ByVal H%, ByVal W%, ByVal E%,
ByVal _
     O%, ByVal n%, ByVal I%, ByVal u%, ByVal S%, ByVal C%, ByVal OP%, ByVal
CP%, _
     ByVal Q%, ByVal j%, ByVal F$)
     Declare Function CreateFontIndirect Lib "GDI" Alias
"createfontindirect" _
     (lpLogFont As LOGFONT) As Integer
     Declare Function SelectObject Lib "GDI" Alias "selectobject" (ByVal
hdc%, _
     ByVal object%) As Integer
     Declare Function TextOut Lib "GDI" Alias "textout" (ByVal hdc%, ByVal
X%, _
     ByVal y%, ByVal text$, ByVal nCount%) As Integer
     Declare Sub DeleteObject Lib "GDI" Alias "deleteobject" (ByVal object%)
     Declare Function GetDeviceCaps Lib "GDI" Alias "getdevicecaps" (ByVal
hdc%, _
     ByVal nIndex%) As Integer
     Declare Function GetTextFace Lib "GDI" Alias "gettextface" (ByVal hdc
As _
     Integer, ByVal nCount As Integer, ByVal lpname As String) As Integer
#End If
Global Const PROOF_QUALITY = 2
Global Const FW_NORMAL = 400
poi inserisci un pulsante di comando e una picturebox nel form, quindi nel
pulsante di comando
inserisci il sequente codice.
Private Sub Command1_Click()
     '------------------------scrive il titolo verticale sull'asse y
     '-----------------------------------------inizio  rotazione testo
     Dim hfont As Integer, holdfont As Integer
     Dim font As LOGFONT
     nvalue = GetDeviceCaps(Picture1.hdc, 34)
     'font.lfheight = 12
     font.lfheight = 14  'determina la grandezza del carattere
     font.lfescapement = 3100 'determina la larghezza in senso verticale
     font.lfweight = 900     'determina l'inclinazione
     font.lfpitchandfamily = Chr$(1)     ' determina lo spessore
     'font.lffacename = "Courier New" + Chr$(0)
     hfont = CreateFontIndirect(font)
     holdfont = SelectObject(Picture1.hdc, hfont)
     szfacename$ = Space$(80)
     retval% = GetTextFace(Picture1.hdc, 79, szfacename$)
     nchars = Len(sometext$)
     CurrentX = 5
     Picture1.CurrentY = 1500
     Picture1.Print "rotazione tesro"
     '------------------------Fine scrittura titolo verticale
End Sub
quindi cliccando sul pulsante di comando sara' possibile vedere il testo
ruotato di novanta gradi.
Ciao Paolo