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
21 juil. 2009 à 12:34
Ton code marche trèèèèèèès bien !
30 mars 2008 à 21:04
Bravo pour votre code, il fonctionne à merveille.
En revanche il est trop petit sur un format A4...
Comment prendre toute la surface en largeure et ainsi grandir la vision de la chose toujours sur un format A4.
Merci.
26 août 2005 à 10:48
lire en :
"... des informations de tri et filtre afin qu'il soit affiché par ..."
plutôt:
... des informations de tri et filtre afin qu'elles soient affichées par ...
@RJLFRANCE : Déjà j'ai testé ta source les résultats sont approximatifs, néanmoins je sais maintenant comment envoyer directement à l'imprimante depuis un recordset c'est l'essentiel. Aurais tu une idée sur la gestion des pages?. Il suffit de me dire quelles isntructions ou API et je me charge du reste.
Merci dans tous les cas.
Asimengo
25 août 2005 à 10:52
Je suis interessé parce que l'objet implementation de recordset (voir source http://www.vbfrance.com/code.aspx?ID=33090) que j'ai développé renvoie des informations de tri et filtre afin qu'il soit affiché par celui qui utilise cet objet. Avec ACCESS c'est facile tu peux demander à afficher une requête dans un état et le pb est résolu. j'ai pas encore trouvé un tel objet qui communiquerait avec les objets VB qui me ferait visualiser l'état (je préfère) ou l'éditer directement.
Si quelqu'un peut m'indiquer ou le trouver j'en serais reconnaissant
Asimengo
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.