Msflexgrid l'impression !

Contenu du snippet

Juste une procedure d'impression de l'objet MSflexgrid, pour aider d'autre personne !

2 Objets:
1 bouton=command1
et une Msflexgrid=msf1

Source / Exemple :


Private Sub Command1_Click()
Call imprime(msf1)
End Sub

Private Sub Form_Load()
 'pour adapter a la resolution
  Dim X, Y As Integer
  X = Screen.Width / Screen.TwipsPerPixelX
  Y = Screen.Height / Screen.TwipsPerPixelY
  rx = X / 800
  ry = Y / 600
  '*************
   msf1.Cols = 10
   msf1.Font.Size = 10

   msf1.FixedCols = 0
   msf1.ColWidth(0) = 2800 * rx ' client
   msf1.ColWidth(1) = 500 * rx 'logo
   msf1.ColWidth(2) = 1000 * rx 'ville
   msf1.ColWidth(3) = 2000 * rx 'materiel
   msf1.ColWidth(4) = 1000 * rx 'situation
   msf1.ColWidth(5) = 1000 * rx 'date appel
   msf1.ColWidth(6) = 0    ' la clef n'apparait pas dans le tableau
   msf1.ColWidth(7) = 1000 * rx 'intervention
   msf1.ColWidth(8) = 1000 * rx 'technicien
   msf1.ColWidth(9) = 1000 * rx 'pret
    
msf1.TextMatrix(0, 0) = "Clients"
msf1.TextMatrix(0, 1) = "Logo"
msf1.TextMatrix(0, 2) = "Ville"
msf1.TextMatrix(0, 3) = "Materiel"
msf1.TextMatrix(0, 4) = "Situation"
msf1.TextMatrix(0, 5) = "Date appel"
msf1.TextMatrix(0, 6) = "clef"
msf1.TextMatrix(0, 7) = "Date intervention"
msf1.TextMatrix(0, 8) = "Technicien"
msf1.TextMatrix(0, 9) = "Pret"
msf1.Rows = 12
For a% = 1 To 10
msf1.TextMatrix(a%, Int((8 * Rnd) + 1)) = "N'importe quoi"
Next a%
   
End Sub
Sub imprime(grille As MSFlexGrid)
    Printer.ScaleMode = 6
    offset% = Printer.CurrentY
    Printer.FontName = "ARIAL"
    Printer.FontSize = 8.3
    Printer.FontBold = False
    'pour adapter a la resolution
    Dim X, Y As Integer
    
    X = Screen.Width / Screen.TwipsPerPixelX
    Y = Screen.Height / Screen.TwipsPerPixelY
    rx = X / 800
    ry = Y / 600
    '*******
    hh% = grille.CellTop / ry
    Y1% = offset%
    For a% = 0 To grille.Rows - 1
        grille.Row = a% 'ligne active
        Y1% = Y1% + ((grille.CellHeight / ry) / 56.7)
        If Y1% > 270 Then Printer.NewPage: Y1% = 10
    
        Y2% = Y1% + ((grille.CellHeight / ry) / 56.7)
        For b% = 0 To grille.Cols - 1
            grille.Col = b% 'colonne ative
            X1% = (grille.CellLeft / rx) / 56.7
            X2% = X1% + ((grille.CellWidth / rx) / 56.7)
            coul = grille.CellBackColor
            If coul = 0 Then coul = RGB(255, 255, 255)
            Printer.FillStyle = 0 'rectangle plein
            Printer.FillColor = coul
       
            Printer.Line (X1%, Y1%)-(X2%, Y2%), , B
            Printer.CurrentX = X1% + 0.5
            Printer.CurrentY = Y1%
            t$ = grille.Text
            tt$ = ""
            If grille.CellWidth > 0 Then
                For ac% = 1 To Len(t$)
                    tt$ = Left(t$, ac%)
                    wc% = Printer.TextWidth(tt$) ' twips
                    If X1% + wc% > X2% - 2 Then Exit For
                Next ac%
                tb$ = Left(tt$, ac%)
             For i% = 1 To Len(tb$)
                ie% = InStr(tb$, Chr$(13) + Chr$(10))
                If ie% > 0 Then
                    tbb$ = Left(tb$, ie% - 1)
                    tb$ = Mid(tb$, ie% + 2)
                    Printer.CurrentX = X1% + 0.5
                    Printer.Print tbb$
                    i% = ie% + 2
                Else
                    Printer.CurrentX = X1% + 0.5
                    Printer.Print tb$
                Exit For
                End If
             Next i%
                
            End If
        Next b%
    Next a%
    Printer.EndDoc
End Sub

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.