Toujours pas de réponse ! Impression de caractères avec rotation !!!!

denis - 25 août 2001 à 09:50
philoo91 Messages postés 46 Date d'inscription vendredi 14 février 2003 Statut Membre Dernière intervention 13 juillet 2009 - 2 juin 2004 à 09:37
J'ai trouvé la solution pour appliquer une rotation à un text dans un picturebox (à l'écran) en utilisant les fonctions GDI createfontindirect, selectOject, et textout.

En revanche lorsque j'utilise ces même fonctions sur l'imprimante, le texte s'imprime sans rotation ??

Ou est l'erreur, Merci...
Y-a-t-il une autre solution

Ci-joint le code que j'utilise
' déclaration
Public sortie As Object
Public Const LOGPIXELSX = 88 ' Logical pixels/inch in X
Public Const LOGPIXELSY = 90 ' Logical pixels/inch in Y
Public 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
Public Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Public Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Public Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long
Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
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 * 32
End Type
' fonction de rotation

Public Sub RotTexte(left As Single, Top As Single, ft As IFontDisp, ch As String, degre As Integer)
Dim ftrot As LOGFONT
Dim fsize As Long
Dim rfont As Long
Dim oldfont As Long
Dim x As Long
Dim y As Long

' Sortie Object de destination

If sortie Is Printer Then
x = left/ sortie.TwipsPerPixelX
y = top/ sortie.TwipsPerPixelY
Else
x = left/ Screen.TwipsPerPixelX
y = top/ Screen.TwipsPerPixelY
End If

fsize = ft.Size * GetDeviceCaps(sortie.hdc, LOGPIXELSY) / 72
fsize = Round(Fz(ft.Size * GetDeviceCaps(sortie.hdc, LOGPIXELSY) / 72))
With ftrot
.lfHeight = fsize
.lfWidth = 0
.lfEscapement = degre * 10
.lfOrientation = degre * 10
.lfWeight = ft.Weight
.lfItalic = ft.Italic
.lfUnderline = ft.Underline
.lfStrikeOut = ft.Strikethrough
.lfCharSet = ft.Charset
.lfOutPrecision = 0
.lfClipPrecision = 0
.lfQuality = 0
.lfPitchAndFamily = 0
.lfFaceName = ft.Name + Chr$(0)
End With
rfont = CreateFontIndirect(ftrot)
oldfont = SelectObject(sortie.hdc, rfont)
TextOut sortie.hdc, x, y, ch, Len(ch)
SelectObject sortie.hdc, oldfont
DeleteObject rfont
End Sub

1 réponse

philoo91 Messages postés 46 Date d'inscription vendredi 14 février 2003 Statut Membre Dernière intervention 13 juillet 2009
2 juin 2004 à 09:37
Bonjour,

Ton code fonctionne, pour l'avoir trouvé moi aussi.
Cependant quelles seraient les formules de trigonométrie à employer pour que ce texte (qui peut tenir sur plusieurs lignes) puisse tourner sur son centre et non sur le pixel situé en haut à gauche du rectangle contenant ce texte

Merci
0
Rejoignez-nous