IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

Imprimer en incliné


Sujet :

VB.NET

  1. #1
    Membre éprouvé
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Décembre 2010
    Messages
    100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2010
    Messages : 100
    Par défaut Imprimer en incliné
    Bonjour à tous,

    Je cherche le moyen d'imprimer en incliné selon un angle donné. L'idée est de faire un filigrane (genre "copy" sur une facture).
    J'utilise l'objet Graphics pour l'impression. J'ai bien cherché sur Google mais je ne parviens pas à mes fins.

    Voici une partie de mon code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    Private Sub GridToPrint_PrintPage(ByVal sender As System.Object, ByVal e As PrintPageEventArgs) Handles GridToPrint.PrintPage
            e.Graphics.PageUnit = GraphicsUnit.Millimeter
            'e.Graphics.FillRectangle(Brushes.Gray, 0, 0, 200, 200)
            PrintString(e, "Test Print", New Font("Arial", 25, FontStyle.Bold), Brushes.Black, 5, 10, 0)
            PrintString(e, InvoiceNumber, New Font("Arial", 18, FontStyle.Bold), Brushes.Black, 5, 25, 0)
            PrintString(e, Format(InvoiceDate, "dd/MM/yyyy"), New Font("Arial", 18, FontStyle.Bold), Brushes.Black, 5, 40, 0)
            PrintString(e, "Facture client", New Font("Arial", 25, FontStyle.Bold), Brushes.Black, 5, 60, 0)
            Dim bmp As Bitmap = New Bitmap(My.Resources.Resource1.Logo_Infotec___Copie)
            Dim imageWidth As Integer, imageHeight As Integer
            imageWidth = CInt(bmp.Width / 16)
            imageHeight = CInt(bmp.Height / 16)
            e.Graphics.DrawImage(bmp, 5, 150, imageWidth, imageHeight)
            e.HasMorePages = False
            'DrawAngledText(e.Graphics, New Font("Arial", 20, FontStyle.Bold), Brushes.Black, "COPY", 5, 70, 20, 5)
            'CurveText(e.Graphics, New Font("Arial", 20, FontStyle.Bold), Brushes.Black, "COPY", 5, 70, 20)
        End Sub
     
        Public Sub DrawAngledText(ByVal gr As Graphics, ByVal _
            the_font As Font, ByVal the_brush As Brush, ByVal txt _
            As String, ByVal x As Integer, ByVal y As Integer, _
            ByVal angle_degrees As Single, ByVal y_scale As Single)
            ' Translate the point to the origin.
            gr.TranslateTransform(-x, -y, _
                Drawing2D.MatrixOrder.Append)
     
            ' Rotate through the angle.
            gr.RotateTransform(angle_degrees, _
                Drawing2D.MatrixOrder.Append)
     
            ' Scale vertically by a factor of Tan(angle).
            Dim angle_radians As Double = angle_degrees * Math.PI / 180
            gr.ScaleTransform(1, y_scale, _
                Drawing2D.MatrixOrder.Append)
     
            ' Find the inverse angle and rotate back.
            angle_radians = Math.Atan(y_scale * Math.Tan(angle_radians))
            angle_degrees = CSng(angle_radians * 180 / Math.PI)
            gr.RotateTransform(-angle_degrees, _
                Drawing2D.MatrixOrder.Append)
     
            ' Translate the origin back to the point.
            gr.TranslateTransform(x, y, _
                Drawing2D.MatrixOrder.Append)
     
            ' Draw the text.
            gr.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAliasGridFit
            gr.DrawString(txt, the_font, the_brush, x, y)
        End Sub
     
        Private Sub PrintString(ByVal e As PrintPageEventArgs, ByVal Value As String, ByVal PrintFont As Font, ByVal ForeColor As Brush, ByVal X As Single, ByVal Y As Single, ByVal Align As Byte)
            e.Graphics.PageUnit = GraphicsUnit.Millimeter
            Dim TextAlign As New StringFormat
            Select Case Align
                Case 0
                    TextAlign.Alignment = StringAlignment.Near
                Case 1
                    TextAlign.Alignment = StringAlignment.Far
                Case 2
                    TextAlign.Alignment = StringAlignment.Center
            End Select
            e.Graphics.DrawString(Value, PrintFont, ForeColor, X, Y, TextAlign)
        End Sub
    Merci de votre aide,

  2. #2
    Membre chevronné
    Profil pro
    Inscrit en
    Février 2010
    Messages
    291
    Détails du profil
    Informations personnelles :
    Âge : 56
    Localisation : France

    Informations forums :
    Inscription : Février 2010
    Messages : 291
    Par défaut
    Bonjour,

    La magie de GDI+ ....

    La solution est soi de passer par les API32 ou de contourner la chose (mais dans le fond cela revient au même) en créant un objet Logfont GDI et en utilisant la méthode FromLogFont de l'objet system.drawing.font

    Je vous mets ci-dessous la structure LogFont dans sa définition VB6 a adapter pour .NET

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    Private 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(LF_FACESIZE) As Byte
    End Type

  3. #3
    Membre éprouvé
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Décembre 2010
    Messages
    100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2010
    Messages : 100
    Par défaut
    Merci de cette piste, auriez-vous un exemple que ce soit VB6 ou autre d'utilisation de logfont?
    J'avoue ne pas bien avoir compris comment je peux utiliser ce logfont.

    Cordialement,

  4. #4
    Membre chevronné
    Profil pro
    Inscrit en
    Février 2010
    Messages
    291
    Détails du profil
    Informations personnelles :
    Âge : 56
    Localisation : France

    Informations forums :
    Inscription : Février 2010
    Messages : 291
    Par défaut
    Bonjour,

    Heu ... c'est pas trivial, ci-dessous la fonction WriteText de ma composition, écrite en VB6, elle fait partie d'une classe donc vous aurez des références à des fonctions internes à cette classe, en gros ces fonctions permettent de mapper un DC en mode métrique et de dessiner en coordonnées réelles à l'aide des API, ce pour que vous compreniez l'essentiel. Attachez vous aux fonctions commentées, qui concernent le texte a proprement parler.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    Public Function writetext(MyText As String, x As Double, y As Double, Taille As Double, align As Long, angle As Double, Affiche As Boolean, Optional Color& = 0, Optional weight As Long = 0, Optional underline As Byte = 0)
    Dim lf As LOGFONT
    Dim oldfont&
    Dim alignorigin&
    Dim newfont&
    Dim Oldcolor&
    Dim Usecolor&
    Dim di&
    Dim pointattache As POINTAPI
    Dim pointlog As POINTAPI
    Dim p As POINTGEO
    Dim SI As Size
     
    setmetrique
    p.x = x
    p.y = y
    pointattache = RtoL(p)
    p.x = x + Taille
    p.y = y + Taille
    pointlog = RtoL(p)
     
    'Police logique courante par selection police systeme
    oldfont& = SelectObject(mhdc, GetStockObject(0))
    di& = GetObjectAPI(oldfont&, Len(lf), lf)
     
    'rétablit la police de départ
    di& = SelectObject(mhdc, oldfont&)
     
     
    lf.lfHeight = pointlog.y - pointattache.y
    lf.lfEscapement = -1 * Round(angle * 10, 0)
     
    If weight <> 0 Then
    lf.lfWeight = weight
    End If
     
    If underline = 1 Then
    lf.lfUnderline = 1
    End If
    'création d'une fonte à partir de logfont
    newfont& = CreateFontIndirect(lf)
    oldfont& = SelectObject(mhdc, newfont&)
    di& = GetTextExtentPoint32(mhdc, MyText, Len(MyText), SI)
    mrectText.Bottom = pointattache.y
    mrectText.Top = mrectText.Bottom + SI.Cy
    'stocke l'alignement d'origine
    'calcul l'ancrex en fonction de l'alignement
    'pas de y car pas d'alignement verticale Bottom obligatoire
     
    Select Case align
    Case 0
    alignorigin& = SetTextAlign(mhdc, TA_LEFT Or TA_BOTTOM Or TA_UPDATECP)
    mrectText.Left = pointattache.x
    Case 1
    alignorigin& = SetTextAlign(mhdc, TA_RIGHT Or TA_BOTTOM Or TA_UPDATECP)
    mrectText.Left = pointattache.x - SI.Cx
    Case 2
    alignorigin& = SetTextAlign(mhdc, TA_CENTER Or TA_BOTTOM Or TA_UPDATECP)
    mrectText.Left = pointattache.x - SI.Cx / 2
    End Select
     
     
    mrectText.Right = mrectText.Left + SI.Cx
    ConvertEspaceText
     
    If Affiche Then
    Oldcolor& = GetTextColor(mhdc)
    Usecolor& = Color&
    dummy& = SetTextColor(mhdc, Usecolor)
    di& = MoveToEx&(mhdc, pointattache.x, pointattache.y, pointlog)
    di& = TextOut(mhdc, 0, 0, MyText, Len(MyText))
    Usecolor& = SetTextColor(mhdc, Oldcolor)
    End If
     
    di& = SetTextAlign(mhdc, alignorigin&)
    di& = SelectObject(mhdc, oldfont&)
     
    DeleteObject (newfont&)
     
    exitmetrique
    End Function

  5. #5
    Expert éminent Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 204
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 204
    Par défaut
    dessiner le texte sur un graphics rotationné et l'appliquer sur l'autre
    enfin un truc dans le genre

    voir dans system.drawing ou system.drawing.drawing2d, il y a ce qu'il faut pour appliquer des transformations, dont les rotations
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  6. #6
    Membre éprouvé
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Décembre 2010
    Messages
    100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2010
    Messages : 100
    Par défaut
    Merci de vos réponses, je vais me débrouillé avec vos pistes, j'ai déjà trouvé un article intéressant:
    http://www.functionx.com/win32/Lesson14.htm

    Cordialement,

  7. #7
    Membre chevronné
    Profil pro
    Inscrit en
    Février 2010
    Messages
    291
    Détails du profil
    Informations personnelles :
    Âge : 56
    Localisation : France

    Informations forums :
    Inscription : Février 2010
    Messages : 291
    Par défaut
    Bonjour,

    Effectivement article très intéressant, qui va me permettre de modifier mon code VB6 pour utiliser autre chose que la police système par défaut.

    Bon courage

  8. #8
    Membre extrêmement actif
    Inscrit en
    Avril 2008
    Messages
    2 573
    Détails du profil
    Informations personnelles :
    Âge : 65

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 573
    Par défaut ecrire en incline
    bonjour Geo2A
    Tu n'as pas bien vu dans GDI+ a mon avis.
    Tu as GraphicsPath :
    -supporte les transformations(matrix).
    -Dawstring ou tu peux mettre du texte + des Shapes regroupes ensembles(outline).
    Matrix.Shear est une transformation qui fait l'inclinaison de tout ce qu'on veut.
    (etirement suivant x ou y ou les 2).
    bout de code pour Matrix.Shear :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
     
    'ajouter un control
    '-Panel pour desiner
    '-un NumericUpDown1
    Imports System.Drawing.Drawing2D
    Public Class frmShear
    	Public Sub New()
     
    		' Cet appel est requis par le Concepteur Windows Form.
    		InitializeComponent()
     
    		' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
    		Me.Font = New Font("Arial", 24)
    		Me.ClientSize = New Size(341, 266)
    		Me.Name = "frmShear"
    		Me.Text = "frm Shear"
    		Me.ResizeRedraw = True
    		'NumericUpDown
    		Me.NumericUpDown1.Dock = DockStyle.Top
    		Me.NumericUpDown1.Maximum = 5.0
    		Me.NumericUpDown1.Minimum = -5.0
    		Me.NumericUpDown1.DecimalPlaces = 2.0
    		Me.NumericUpDown1.Value = -1.0
    		'panel
    		Me.Panel1.BackColor = Color.White
    		Me.Panel1.Name = "Panel1"
    		Me.Panel1.Dock = DockStyle.Fill
     
    	End Sub
    	Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
    		Dim gr As Graphics = Graphics.FromHwnd(Me.Panel1.Handle)
    		Dim shear As Double = Me.NumericUpDown1.Value
    		Dim scale As Double = 2.0
    		'Chaine à imprimer
    		Dim strToPrint As String = "Shear(.5,0)"
    		gr.Clear(Color.White)
    		Me.SkewText(gr, strToPrint, shear, scale)
    	End Sub
     
     
    	Private Sub SkewText(ByVal gr As Graphics, ByVal strToPrint As String, ByVal shear As Double, ByVal scale As Double)
     
    		'Needed : initialize un rectangle pour  disposition du string
    		Dim layoutStr As SizeF = New SizeF(200.0F, 60.0F)
     
     
     
    		'Mesure le rectangle du string(a partir de taille)
    		Dim strSize As SizeF = gr.MeasureString(strToPrint, Me.Font, layoutStr)
    		Dim rectStr As RectangleF = New RectangleF(100, 100, layoutStr.Width, layoutStr.Height)
     
    		'Dessine le String au point (50, 100)
    		gr.DrawString(strToPrint, Me.Font, Brushes.Black, 50, 100)
    		'Dessine  un rectangle noir autour du String 
    		gr.DrawRectangle(Pens.Black, layoutStr.Height, 50, 100, rectStr.Height)
     
     
    		'Utilise un  Matrix pour le "skew"
    		Dim myMatrix = New Matrix()
    		gr.Transform = myMatrix
     
    		' Mets à Echelle   2
    		myMatrix.Scale(scale, scale, MatrixOrder.Append)
    		' Etire vers l'avant le sommet haut-gauche (valeur negative) :
    		' * direction  x seulement  
    		' *1 fois la hauteur du string( etirement=shear*Hauteur par defaut)
    		myMatrix.Shear(shear, 0)
    		gr.MultiplyTransform(myMatrix)
     
     
    		'Mesure le string apres transformation
    		strSize = gr.MeasureString(strToPrint, Me.Font, layoutStr)
    		rectStr = New RectangleF(100, 100, layoutStr.Width, layoutStr.Height)
    		Dim offsetX As Integer = CInt(shear * rectStr.Height)
    		If offsetX <= 0.0 Then
    			'Dessine et "fill"  un rectangle rouge autour du String 
    			Dim redPen As Pen = New Pen(Color.Red, 2.0)
    			gr.DrawRectangle(redPen, -offsetX, 0, rectStr.Width, rectStr.Height)
    			gr.FillRectangle(Brushes.Aquamarine, -offsetX, 0, rectStr.Width, rectStr.Height)
     
    			'Dessine le String a l'origine 
    			gr.DrawString(strToPrint, Me.Font, Brushes.Black, -offsetX, 0)
    		Else
    			'Dessine et "fill"  un rectangle rouge autour du String 
    			Dim redPen As Pen = New Pen(Color.Red, 2.0)
    			gr.DrawRectangle(redPen, 0, 0, rectStr.Width, rectStr.Height)
    			gr.FillRectangle(Brushes.Aquamarine, 0, 0, rectStr.Width, rectStr.Height)
     
    			'Dessine le String a l'origine 
    			gr.DrawString(strToPrint, Me.Font, Brushes.Black, 0, 0)
     
    		End If
     
     
    	End Sub
    bon code.............

  9. #9
    Membre Expert
    Profil pro
    Inscrit en
    Octobre 2006
    Messages
    700
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2006
    Messages : 700
    Par défaut
    Bonsoir
    Pour un texte en diagonale et incliné que l'on a l'habitude de voir sur certains documents.
    Un frm et un panel pour tester :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    Imports System.Drawing.Printing
    Imports System.Drawing.Drawing2D
     
    Public Class frmTxtDiadonal
     
        '*** Les variables globales de la matrice.
        '   *** Variation d'échelle sur l'axe des X.
        Private m11 As Single = 1.0F
        '   *** Inclinaison de l'axe des X.
        Private m12 As Single = 0.0F
        '   *** Inclinaison de l'axe des Y.
        Private m21 As Single = 0.0F
        '   *** Variation de l'échelle sur l'axe des Y.
        Private m22 As Single = 1.0F
        '   *** Translation ou déplacement sur l'axe des X.
        Private dx As Integer = 0
        '   *** Translation sur l'axe des Y.
        Private dy As Integer = 0
     
        '*** Autres variables
        '   *** Angle d'inclinaison en degrés.
        Dim anglDegre As Double
        '   *** Angle d'inclinaison en radians
        Dim anglRad As Double = 0
     
        Private Sub frmTxtDiadonal_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
     
            ' INITIALISATION
            Me.Panel1.Dock = DockStyle.Fill
     
            ' Facteurs d'échelle sur longueur et hauteur du texte.
            m11 = 5
            m22 = 7
            ' angle d'inclinaison en degrés.(par rapport à la verticale)
            anglDegre = -50
            anglRad = anglDegre * Math.PI / 180
            ' Origine de la matrice, soit le centre du Panel.
            dx = CInt(Me.Panel1.Width / 2)
            dy = CInt(Me.Panel1.Height / 2)
     
        End Sub
     
        Private Sub DrawTexte(ByVal gr As Graphics, ByVal txt As String, ByVal fontFamly As FontFamily, _
                              ByVal fontSty As FontStyle, ByVal em As Single) ', ByVal strFormat As StringFormat)
     
            'e.Graphics.PageUnit = GraphicsUnit.Millimeter
     
            gr.PixelOffsetMode = PixelOffsetMode.HighQuality
            gr.SmoothingMode = SmoothingMode.AntiAlias
            gr.CompositingQuality = CompositingQuality.HighQuality
     
            'Repère du centre du Panel (pour info).
            gr.DrawEllipse(Pens.Blue, dx, dy, 2, 2)
     
            'On fait appel à un dessin de tracés auquel on ajoute des éléments et auquel on apporte les transformation voulues,
            'et que l'on collera sur le conteneur choisi en final.
            Dim gpVu As GraphicsPath = New GraphicsPath
     
            ' Calcul du facteur inclinaison.
            m12 = CSng(m11 * Math.Cos(anglRad) / Math.Sin(anglRad))
     
            ' Calcul du rectangle enveloppant du texte.
            Dim sizeTxt As New SizeF
            sizeTxt = MeasureStringSizeFFormatInts(gr, txt, New Font(fontFamly, em, fontSty))
     
            ' Ajout du texte au GraphicsPath, avec centre du text = centre du panel (empirique).
            gpVu.AddString(txt, fontFamly, fontSty, em, New PointF((1 - (sizeTxt.Width / 2.65F)), _
                                                                   (1 - (sizeTxt.Height / 3.0F))), StringFormat.GenericDefault)
            ''Ajout du rectangle enveloppant ( pour info).
            'gpVu.AddRectangle(New RectangleF((1 - (sizeTxt.Width / 2.0F)), (1 - (sizeTxt.Height / 2.0F)), sizeTxt.Width, sizeTxt.Height))
     
            ' Application de la matrice de transformation.
            gpVu.Transform(New Matrix(m11, m12, m21, m22, dx, dy))
     
            ' Couleur avec ou sans transparence.
            Dim OneThirdArgb As Color = Color.FromArgb(85, 255, 0, 0)
            Dim OneThirdArgbBrush As New SolidBrush(OneThirdArgb)
            Dim mySolidBrushRed As New SolidBrush(Color.Red)
     
            gr.FillPath(mySolidBrushRed, gpVu) '(OneThirdArgbBrush, gpVu)
     
        End Sub
     
        Private Function MeasureStringSizeFFormatInts(ByVal gr As Graphics, ByVal txt As String, ByVal stringFont As Font) As SizeF
     
            Dim stringSize As New SizeF
            stringSize = gr.MeasureString(txt, stringFont) ', newStringFormat, charactersFitted, linesFilled)
            Return stringSize
     
        End Function
     
        Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
            Dim gr As Graphics = e.Graphics
            DrawTexte(gr, "PROJET", New FontFamily("Arial"), FontStyle.Bold, 20.0F) ', StringFormat.GenericTypographic)
        End Sub

  10. #10
    Expert éminent Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 204
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 204
    Par défaut
    on lit vraiment des choses étranges ici ...
    vous pourriez aussi passer de l'assembleur tant que vous y êtes !

    pour écrire en diagonale (sur une imprimante ou un control) il ne faut pas taper 20 lignes de code étranges, encore moins faire de l'appel d'api non sûr dans le temps, mais juste une ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    legraphics.RotateTransform(angle)
    puis drawstring écrit en diagonale
    legraphics.resettransform pour rétablir sans transformation

    et pour info appeler gdi+ directement depuis .net n'est pas utile, tout est wrappé dans system.Drawing (sauf quelques fonctions certes, mais rarement utiles)
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Imprimer un label incliné, possible ?
    Par Droïde Système7 dans le forum Débuter
    Réponses: 7
    Dernier message: 31/05/2009, 01h00
  2. Comment imprimer des tabulations ?
    Par Invité dans le forum C++Builder
    Réponses: 2
    Dernier message: 27/11/2002, 11h30
  3. [VB6][Flexgrid] Imprimer
    Par tiboleo dans le forum VB 6 et antérieur
    Réponses: 4
    Dernier message: 24/10/2002, 14h14
  4. [VB6] [Outlook] Imprimer un mail en VB
    Par der dans le forum VB 6 et antérieur
    Réponses: 4
    Dernier message: 12/09/2002, 14h20
  5. Comment imprimer le contenu d'un TStringGrid
    Par scorpiwolf dans le forum C++Builder
    Réponses: 2
    Dernier message: 19/06/2002, 15h41

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo