OVH Cloud OVH Cloud

Imprimer eu controle texte

2 réponses
Avatar
François ROLAND
Lorsque j'utilise un controle texte sur plusieur ligne, voudrai pouvoir
l'imprimer suivant la meme presentation. Comment puis je faire?

Cordialement

--

François ROLAND
francois.roland@free.fr

2 réponses

Avatar
ng
Salut,
Voici un exemple de code :

Public Sub ImprimeOb(sTxt As String, oDest As Object, pZoom As Double,
lTaille As Long, sPolice As String)
On Error GoTo errH
Dim i As Integer, sLignes() As String
oDest.ScaleMode = vbCentimeters
oDest.FontName = sPolice
oDest.FontSize = lTaille * pZoom
If TypeOf oDest Is PictureBox Then oDest.Cls
sLignes = Split(sTxt, vbCrLf, , vbTextCompare)
'CENTRE
'oDest.CurrentY = (oDest.ScaleHeight - oDest.TextHeight(sTxt)) / 2
'GAUCHE
oDest.CurrentY = 0
For i = 0 To UBound(sLignes)
'CENTRE
'oDest.CurrentX = (oDest.ScaleWidth - oDest.TextWidth(sTxt)) / 2
oDest.CurrentX = 0
oDest.Print sLignes(i)
Next
Erase sLignes
Exit Sub
errH::
MsgBox Err.Description, vbCritical, "Erreur n°" & Err.Number
End Sub

A appeler par :

Pour un apercu :
Call ImprimeOb(Text1.Text, Picture1, 1, 8, "Verdana")

Pour une impression :
Call ImprimeOb(Text1.Text, Printer, 1, 8, "Verdana")
Call Printer.EndDoc
--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/


"François ROLAND" a écrit dans le message de news:
eR$
Lorsque j'utilise un controle texte sur plusieur ligne, voudrai pouvoir
l'imprimer suivant la meme presentation. Comment puis je faire?

Cordialement

--

François ROLAND





Avatar
François ROLAND
Super, Merci


"ng" a écrit dans le message de news:

Salut,
Voici un exemple de code :

Public Sub ImprimeOb(sTxt As String, oDest As Object, pZoom As Double,
lTaille As Long, sPolice As String)
On Error GoTo errH
Dim i As Integer, sLignes() As String
oDest.ScaleMode = vbCentimeters
oDest.FontName = sPolice
oDest.FontSize = lTaille * pZoom
If TypeOf oDest Is PictureBox Then oDest.Cls
sLignes = Split(sTxt, vbCrLf, , vbTextCompare)
'CENTRE
'oDest.CurrentY = (oDest.ScaleHeight - oDest.TextHeight(sTxt)) / 2
'GAUCHE
oDest.CurrentY = 0
For i = 0 To UBound(sLignes)
'CENTRE
'oDest.CurrentX = (oDest.ScaleWidth - oDest.TextWidth(sTxt)) / 2
oDest.CurrentX = 0
oDest.Print sLignes(i)
Next
Erase sLignes
Exit Sub
errH::
MsgBox Err.Description, vbCritical, "Erreur n°" & Err.Number
End Sub

A appeler par :

Pour un apercu :
Call ImprimeOb(Text1.Text, Picture1, 1, 8, "Verdana")

Pour une impression :
Call ImprimeOb(Text1.Text, Printer, 1, 8, "Verdana")
Call Printer.EndDoc
--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/


"François ROLAND" a écrit dans le message de


news:
eR$
> Lorsque j'utilise un controle texte sur plusieur ligne, voudrai pouvoir
> l'imprimer suivant la meme presentation. Comment puis je faire?
>
> Cordialement
>
> --
>
> François ROLAND
>
>
>