Bien sur cela est perfectible. Celui qui proposera mieux aura toute ma gratitude.
Si j'ai été utile a plusieurs d'entre-vous, ce sera ma grande satisfaction.
Je suis a votre disposition pour toutes questions pertinentes.
Code : Tout sélectionner
;MLD le 07/02/2014
;PB 5.21 LTS
;COMMANDES
;Tous les placements de texte sont en millimètres ( sauf chiffres négatif); mesures de haut en bas et de gauche a droite
;MLD_impFont(nomfont$,grd.d,opt1.d,opt2.d,opt3.d,coul.d)
;MLD_impDrawText(mmhz ,mmvert,"txt") écrit une ligne
; si mmhz = -1 imprime aprés le dernier texte
; si mmhz = -2 centre le texte
; si mmvert = -1 garde la même ligne de texte
; si mmvert = -2 met un interligne (calcul automatique en fonction de la police)
;MLD_impcadre(X.d,Y.d,L.d,H.d,coul) trace un cadre, indiquez des millimètres
;MLD_implinehz(X.d,Y.d,L.d,Ep.d,coul) trace une ligne horizontale, indiquez des millimètres (Ep = épaisseur du trait. 0 = trait fin > 0 trait en mm)
; L = longeur du trait
; si X = -1 imprime aprés le dernier texte
; si X = -2 centre le trait sur la page
; si Y = -1 imprime sur la même ligne
; si y = -2 met un interligne (calcul automatique en fonction de la police)
;MLD_implinevert(X.d,Y.d,X2.d,ht.d,Ep.d,coul) trace une ligne verticale ht en mm = hauteur de la ligne, (Ep = épaisseur du trait. 0 = trait fin > 0 trait en mm)
; ht = hauteur du trait
; si X = -1 imprime aprés le dernier texte
; si X = -2 centre le trait sur la page
; si Y = -1 imprime sur la même ligne
; si y = -2 met un interligne (calcul automatique en fonction de la police)
;MLD_impFormatmonnaie(X.d,Y.d,valeur$,syb$,masque$)
; si X.d = -1 imprime après le dernier texte
; masque$ peut s'écrire comme ceci "### ### ###,##" pas plus de 2 chiffres après la virgule
;MLD_impTextV(hz.d,ht.d,txt$,itl.d,mcoul.d);imprime un texte verticalement
; itl = nombre d'interligne entre chaque lettre
; mcoul = mode de couleurs 0 = couleur de la police en cours -1 couleurs aléatoires par lettre imprimées
;MLD_impTextauto(mmhz.d,mmht.d,mmlgmax.d,text$) Permet l'impréssion d'un texte long, dans un espace définis, avec césure du texte en fin de ligne
; style courrier.(pas de mot coupés)
;MLD_impTextautojust(mmhz.d,mmht.d,mmlgmax.d,text$)Idem ci dessus mais le texte est fustifié
; (genre romans ou article de journal)
;MLD_ImpCttexte(mmhz.d,mmht.d,mmfn.d,txt$) imprime un texte centré entre deux bornes sur la feuille en partant de la gauche (exemple entre 90 et 180)
; mmhz.d = départ du texte (première borne)
; mmfn.d = deuxieme borne
;
Declare nbDPI()
Declare mmlH(nbmm.d)
Declare mmlV(nbmm.d)
Declare MLD_impFont(nomfont$,grd.i,opt1.i,opt2.i,opt3.i,coul.i)
Declare Intlig()
Declare MLD_impText(hz.d,ht.d,txt$)
Declare MLD_impcadre(X.d,Y.d,L.d,H.d,coul)
Declare MLD_implinehz(X.d,Y.d,L.d,Ep.d,coul)
Declare MLD_implinevert(X.d,Y.d,ht.d,Ep.d,coul)
Declare MLD_impFormatmonnaie(X.d,Y.d,valeur$,syb$,masque$)
Declare MLD_impTextV(hz.d,ht.d,txt$,itl.d,mcoul.d)
Declare MLD_ImpCttexte(mmhz.d,mmht.d,mmfn.d,txt$)
Declare MLD_impTextauto(mmhz.d,mmht.d,mmlgmax.d,text$)
Global FontID1
Global DPIHZ.d,MGH.d,Lgmax.d
Global DPIVT.d,MGV.d,Htmax.d
Global Ecrdpihz.d,Ecrdpivt.d
Global largtxt.d,lig.d,poshz.d
Procedure nbDPI();initialisation
hdc = GetDC_(GetDesktopWindow_())
If hdc :Ecrdpihz.d = GetDeviceCaps_(hdc, #LOGPIXELSX) :EndIf
If hdc :Ecrdpivt.d = GetDeviceCaps_(hdc, #LOGPIXELSY) : ReleaseDC_(GetDesktopWindow_(), hdc) : EndIf
If DefaultPrinter() <> 0
printer_DC.d = StartDrawing(PrinterOutput())
DPIHZ.d = GetDeviceCaps_(printer_DC,#LOGPIXELSX)
DPIVT.d = GetDeviceCaps_(printer_DC,#LOGPIXELSY)
MGH.d = GetDeviceCaps_(printer_DC,#PHYSICALOFFSETX)
MGV.d = GetDeviceCaps_(printer_DC,#PHYSICALOFFSETY)
Lgmax.d = GetDeviceCaps_(printer_DC,#PHYSICALWIDTH) - 2*MGH.d
Htmax.d = GetDeviceCaps_(printer_DC,#PHYSICALHEIGHT) - 2*MGV.d
StopDrawing()
EndIf
EndProcedure
nbDPI()
Procedure MLD_impFont(nomfont$,grd.i,opt1.i,opt2.i,opt3.i,coul.i)
StopDrawing()
K.d = DPIHZ.d/Ecrdpihz.d
FontID1 = LoadFont(1,nomfont$,grd * K,opt1.i | opt2.i | opt3.i)
StartDrawing(PrinterOutput())
DrawingMode(#PB_2DDrawing_Transparent)
FrontColor(coul.i)
DrawingFont(FontID(1))
EndProcedure
Procedure mmlH(nbmm.d)
res.d = ((DPIHZ.d * nbmm.d) / 25.4) - MGH.d
If res.d <= MGH.d ;pour ne pas être < a la marge imposée
res.d = MGH.d
EndIf
If res.d => Lgmax.d
res.d = Lgmax.d ;pour ne pas être > a la marge imposée a droite de la feuille
EndIf
poshz.d = res.d + largtxt.d
ProcedureReturn res
EndProcedure
Procedure mmlV(nbmm.d)
res.d = ((DPIVT.d * nbmm.d) / 25.4) - MGV.d
If res.d <= MGV.d ;pour ne pas être < a la marge imposée en haut
res.d = MGV.d
EndIf
If res.d => Htmax.d
res.d = Htmax.d ;pour ne pas être > a la marge imposée en bas de la feuille
EndIf
lig.d = res.d ;en pixels
ProcedureReturn res
EndProcedure
Procedure Intlig()
kintlig.d = TextHeight("AW")/3
Interlig.d = TextHeight("AW") + kintlig.d
lig.d = lig.d + Interlig.d
ProcedureReturn lig.d
EndProcedure
Procedure MLD_cadre(X.d,Y.d,L.d,H.d,coul)
DrawingMode(#PB_2DDrawing_Outlined)
larg .d = (DPIHZ.d * L.d) / 25.4
haut.d = (DPIVT.d * H.d) / 25.4
Box(mmlH(X.d),mmlV(Y.d),larg .d,haut.d,coul)
DrawingMode(#PB_2DDrawing_Transparent)
poshz.d = poshz.d + larg .d
lig.d = lig.d + haut.d
EndProcedure
Procedure MLD_linehz(X.d,Y.d,L.d,Ep.d,coul)
larg .d = (DPIHZ.d * L.d) / 25.4
Select x.d
Case -1
dephz.d = poshz.d
Case -2
dephz = ((Lgmax - MGH.d) - larg .d)/2
poshz.d = dephz
depv.d = mmlV(Y.d)
Default
dephz.d = mmlH(X.d)
depv.d = mmlV(Y.d)
EndSelect
Select Y.d
Case -1 ; reste sur la même ligne
depv.d = lig.d
Case -2
depv.d = Intlig() ; change de ligne
Default
depv.d = mmlV(Y.d)
EndSelect
If Ep.d = 0
Line(dephz.d,depv.d,larg .d,1,coul)
Else
Eps.d = (DPIVT.d * Ep.d) / 25.4
Box(dephz.d,depv.d,larg.d,Eps.d,coul)
EndIf
poshz.d = poshz.d + larg.d ;pour suivre le curseur en hz
lig.d = depv.d
EndProcedure
Procedure MLD_linevert(X.d,Y.d,ht.d,Ep.d,coul)
Eps.d = (DPIVT.d * Ep.d) / 25.4
Select x.d
Case -1
dephz.d = poshz.d
Case -2 ;centre
dephz = (Lgmax /2) - (Eps.d /2)
Default
dephz.d = mmlH(X.d)
EndSelect
Select Y.d
Case -1 ; reste sur la même ligne
depv.d = lig.d
htr.d = depv.d + ((DPIVT.d * ht.d) / 25.4)
Case -2 ; change de ligne
depv.d = Intlig()
htr.d = depv.d + ((DPIVT.d * ht.d) / 25.4)
Default
depv.d = mmlV(Y.d)
htr.d = mmlV(Y.d) +((DPIVT.d * ht.d) / 25.4)
EndSelect
haut2.d= (DPIVT.d* ht.d) / 25.4
If Ep.d = 0
LineXY(dephz.d,depv.d,dephz.d,htr.d,coul)
lig.d = htr.d
Else
Box(dephz.d,depv.d,eps.d,haut2.d,coul)
lig.d = haut2.d
EndIf
poshz.d = dephz.d + Eps.d
EndProcedure
Procedure MLD_impFormatmonnaie(X.d,Y.d,valeur$,syb$,masque$)
If X.d = -1
X.d = (poshz.d + MGH.d) * 25.4/DPIHZ.d
EndIf
If masque$ <> ""
masque$ = masque$ + "." + syb$
xmax.d = X.d + (TextWidth(masque$) * 25.4/DPIHZ.d)
EndIf
ind = 0
ReplaceString(valeur$, ".", ",", #PB_String_InPlace, 1)
For zz.w = Len(valeur$) To 1 Step -1
ind = ind + 1
valeur2$ = valeur2$ + Mid(valeur$,zz,1)
If Mid(valeur$,zz,1) = "," : ind = 0 :EndIf
If ind = 3
ind = 0
If Mid(valeur$,zz,1) <> ","
valeur2$ = valeur2$ + " "
EndIf
EndIf
Next
txt$ = ReverseString(valeur2$) + "." + syb$
If masque$ <> ""
posd.d = xmax.d - (TextWidth(ReverseString(valeur2$) + "." + syb$) * 25.4/DPIHZ.d)
If posd.d < X.d:posd.d = X.d:EndIf
Else
posd.d = X.d
EndIf
MLD_impText(posd.d,Y.d,txt$)
EndProcedure
Procedure MLD_impText(hz.d,ht.d,txt$)
largtxt.d = TextWidth(txt$);en pixel
Select hz.d
Case -1 ;écrit a la fin du dernier texte
chz.d = poshz.d
Case -2 ;centre
chz.d = ((Lgmax - MGH.d) - largtxt.d)/2
Default
chz.d = mmlH(hz.d);déplacement horizontal
EndSelect
Select ht.d
Case -1 ; reste sur la même ligne
cht.d = lig.d
Case -2 ;interligne
cht.d = Intlig()
Default
cht.d = mmlV(ht.d); déplacement vertical
EndSelect
DrawText(chz.d,cht.d,txt$)
poshz.d = chz.d + largtxt.d
lig.d = cht.d
EndProcedure
Procedure MLD_ImpCttexte(mmhz.d,mmht.d,mmfn.d,txt$)
cht.d = mmlV(mmht.d)
chz.d = mmlH(mmhz.d)
fn.d = mmlH(mmfn)
largtxt.d = TextWidth(txt$);en pixel
lgdp.d = fn.d - chz.d
dept.d = chz.d + ((lgdp.d - largtxt.d)/2)
DrawText(dept.d,cht.d,txt$)
poshz.d = dept.d + largtxt.d
lig.d = cht.d
EndProcedure
Procedure MLD_impTextV(hz.d,ht.d,txt$,itl.d,mcoul.d)
lig = mmlV(ht.d)
For zz = 1 To Len(txt$)
a$ = Mid(txt$,zz,1)
If mcoul = -1
DrawText(mmlH(hz.d),lig,a$,RGB(Random(255), Random(255), Random(255)))
Else
DrawText(mmlH(hz.d),lig,a$)
EndIf
If zz < Len(txt$)
If itl.d = 1 Or itl.d = 1
Intlig()
Else
For zx = 1 To itl.d
Intlig()
Next
EndIf
EndIf
Next
poshz.d = chz.d + TextWidth(a$)
EndProcedure
Procedure MLD_impTextauto(mmhz.d,mmht.d,mmlgmax.d,text$)
a$ = "":b$ = "":c$ = "":dp.b = 0
chz.d = mmlH(mmhz.d);dep horizontal en pixel
If mmht.d = -2
cht.d = Intlig()
Else
cht.d = mmlV(mmht.d);dep vertical
EndIf
lgmx.d = mmlH(mmlgmax.d);longeur max en pixel
lgdisp.d = lgmx.d - chz.d
lgtxt.d = TextWidth(text$)
If lgtxt.d < = lgdisp.d
DrawText(chz.d,cht.d,text$)
lig.d = cht.d
Else
nblet.d = Len(text$)
moypxl.d = lgtxt.d/nblet.d;largeur moyenne des lettres en pixel
nbletplgpos.w = lgdisp.d/moypxl.d
a$ = Left(text$,nbletplgpos.w)
For z = nbletplgpos.w To 1 Step -1
Select Mid(a$,z,1)
Case " ",",",".",";",")","'","-"
b$ = Left(a$,nbletplgpos.w - (nbletplgpos.w - z))
c$= RemoveString(text$,b$,0,1,1)
DrawText(chz.d,cht.d,b$)
lig.d = cht.d
dp.b = 1
Break
EndSelect
Next
EndIf
If dp = 1
MLD_impTextauto(mmhz.d,-2,mmlgmax.d,c$)
EndIf
EndProcedure
Procedure MLD_impTextautojust(mmhz.d,mmht.d,mmlgmax.d,text$)
a$ = "":b$ = "":c$ = "":dp.b = 0
chz.d = mmlH(mmhz.d);dep horizontal en pixel
If mmht.d = -2
cht.d = Intlig()
Else
cht.d = mmlV(mmht.d);dep vertical
EndIf
lgmx.d = mmlH(mmlgmax.d);longeur max en pixel
lgdisp.d = lgmx.d - chz.d
lgtxt.d = TextWidth(text$)
If lgtxt.d < = lgdisp.d
DrawText(chz.d,cht.d,LTrim(text$))
lig.d = cht.d
Else
nblet.d = Len(text$)
moypxlp.d = lgtxt.d/nblet.d;largeur moyenne des lettres en pixel
moypxl.d = moypxlp.d + ((moypxlp.d*5)/100);largeur moyenne des lettres en pixel rectifiée
nbletplgpos.d = lgdisp.d/moypxl.d
a$ = Left(text$,nbletplgpos.d)
For z = nbletplgpos.d To 1 Step -1
Select Mid(a$,z,1)
Case " ",",",".",";",")","'","-"
If Right(a$,1) = " " Or Left(a$,1) = " "
b$ = Trim(Left(a$,nbletplgpos.d - (nbletplgpos.d - (z-1))))
Else
b$ = Left(a$,nbletplgpos.d - (nbletplgpos.d - (z-1)))
EndIf
pl$ = Left(b$,1)
dl$ = Right(b$,1)
psdl.d = lgmx.d - TextWidth(dl$)
nblins.d = (Len(b$)-2);nombre de lettres a insérées
largdisp.d = psdl.d - (chz.d + TextWidth(pl$)) ;largeur disponible entre les deux lettres extremes
nbl.d = 0 : lgtlt.d = 0
For k = 2 To (Len(b$)-1)
If Mid(b$,k,1) = " ": nbl.d = nbl.d + 1:EndIf
lgtlt.d = lgtlt.d + TextWidth(Mid(b$,k,1))
Next
nbpxrtpb.d = (largdisp.d - lgtlt.d) / nbl.d ;nombre de pixel a répartir par blanc
DrawText(chz.d,cht.d,pl$);imprime la première lettre
For z = 2 To (Len(b$)-1)
If Mid(b$,z,1) = " " :chz.d = chz.d + nbpxrtpb.d:EndIf
chz.d = chz.d + (TextWidth(Mid(b$,z-1,1)))
DrawText(chz.d,cht.d,Mid(b$,z,1));Imprime les lettres intermédières
Next
DrawText(psdl.d,cht.d,dl$);Imprime la dernière lettre
c$= RemoveString(text$,b$,0,1,1)
lig.d = cht.d
dp.b = 1
Break
EndSelect
Next
EndIf
If dp = 1
MLD_impTextautojust(mmhz.d,-2,mmlgmax.d,c$)
EndIf
EndProcedure
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ DEMO ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Procedure imp1()
L1$ = "Marcel BAVARD"
L2$ = "AVOCAT AU BARREAU DE PARIS"
L3$ = "15 rue du Rire 75001 Paris"
L4$ = "Tel : 01 01 01 01 10 FAX : 01 01 01 01 11 Mail : bavardavocat@wanadoo.fr"
L5$ = "n° siret : 12345671547645 n° TVA intracom FR89439376"
L6$ = "Membre d’une Association Agréée. Le règlement des honoraires par chèque est accepté."
L7$ = "Spécialiste du droit des affaires"
If DefaultPrinter() <> 0
If StartPrinting("Mic")
StartDrawing(PrinterOutput())
MLD_impFont("Times New Roman",20,#PB_Font_HighQuality,#PB_Font_Bold,0,$0)
MLD_impText(15,20,L1$)
MLD_impFont("Times New Roman",14,#PB_Font_HighQuality,0,0,$0)
MLD_impText(15,-2,L2$)
MLD_impFont("Times New Roman",10,#PB_Font_HighQuality,0,0,$0)
MLD_impText(15,-2,L7$)
MLD_impFont("Times New Roman",14,#PB_Font_HighQuality,0,0,$0)
MLD_impText(-2,262,L3$)
MLD_impText(-2,-2,L4$)
MLD_impFont("Times New Roman",8,#PB_Font_HighQuality,0,0,$0)
MLD_impText(-2,276,L5$)
MLD_impText(-2,-2,L6$)
StopDrawing()
StopPrinting()
EndIf
EndIf
EndProcedure
Procedure imp2()
Dim L.s(14)
L(1) = "Michel DUCHIEN Amélie LECHAT"
L(2) = " Docteur vétérinaire diplomés de l'école d'Alfort"
L(3) = "Rennes le :" + FormatDate("%dd / %mm / %yyyy", Date())
L(4) = "Madame, Monsieur"
L(5) = " Nous vous informons que la date de vaccination de votre chien MEDOR arrive."
L(6) = "Pour une parfaite santé de votre animal, il serait souhaitable de prendre rendez-vous auprés de la clinique sous quinzaine."
;L(7) = "auprés de la clinique sous quinzaine."
L(7)= "Nous praticons un tarif forfaitaire de vaccination de TTC : " : L(8) = "45.35"
L(9) = "Restant a votre entière disposition."
L(10) = "Les Vétérinaires"
L(11) = "Clinique vétérinaire du Bison futé 7 rue du Grand singe 35000 Rennes"
L(12) = " Ouverture du lundi au samedi de 9H a 18H Tel : 01 01 01 01 10 FAX : 01 01 01 01 11 "
L(13) = "n° siret : 12345671547645 n° TVA intracom FR89439376"
L(14) = "Membre d’une Association Agréée. Le règlement des honoraires par chèque est accepté."
If DefaultPrinter() <> 0
If StartPrinting("Mic")
StartDrawing(PrinterOutput())
MLD_impFont("Georgia",18,#PB_Font_HighQuality,#PB_Font_Bold,0,$8B453B)
MLD_impText(-2,20,L(1))
MLD_impText(0,-2,"")
MLD_impFont("Georgia",14,#PB_Font_HighQuality,0,0,$8B453B)
MLD_impText(-2,-2,L(2))
MLD_impFont("Times New Roman",14,#PB_Font_HighQuality,0,0,$0)
MLD_impText(130,80,L(3))
MLD_impText(30,110,L(4))
MLD_impText(20,125,L(5))
MLD_impTextauto(20,135,180,L(6))
MLD_impText(0,-2,"")
MLD_impText(20,-2,L(7)):MLD_impFormatmonnaie(-1,-1,L(8),"€","")
MLD_impText(0,-2,"")
MLD_impText(20,-2,L(9))
MLD_impText(130,190,L(10))
MLD_impFont("Times New Roman",10,#PB_Font_HighQuality,0,0,$0)
MLD_impText(-2,265,L(11))
MLD_impText(-2,-2,L(12))
MLD_impText(0,-2,"")
MLD_impFont("Times New Roman",8,#PB_Font_HighQuality,0,0,$0)
MLD_impText(-2,-2,L(13))
MLD_impText(-2,-2,L(14))
StopDrawing()
StopPrinting()
EndIf
EndIf
FreeArray(L())
EndProcedure
Procedure imp3()
If DefaultPrinter() <> 0
If StartPrinting("Mic")
MLD_impFont("Comic Sans MS",24,#PB_Font_HighQuality,0,0,$0)
MLD_impTextV(23,20,"BONNE FÊTE MICHEL",1,-1)
MLD_ImpCttexte(60,25,195,"M E N U")
MLD_impFont("Comic Sans MS",16,#PB_Font_HighQuality,0,0,$0)
For x = 85 To 125 Step 20
MLD_ImpCttexte(60,x,195,"****")
Next
MLD_ImpCttexte(60,60,195,"Apéros divers")
MLD_ImpCttexte(60,75,195,"Amuses bouche. (Américains)")
MLD_ImpCttexte(60,95,195,"Caviar de la Baltique. (de chez Pétetropchian)")
MLD_ImpCttexte(60,115,195," Homard Breton a l'Armoricaine. (Pas congelé)")
MLD_ImpCttexte(60,135,195,"Agneau de Hollande. (de chez Ruth Veller)")
MLD_ImpCttexte(60,145,195,"Avec sa fabuleuse purée")
For xx = 155 To 195 Step 20
MLD_ImpCttexte(60,xx,195,"****")
Next
MLD_ImpCttexte(60,165,195,"Baba au rhum. (de chez Maurice Balat)")
MLD_ImpCttexte(60,185,195,"Grand vin de Bordeaux (a volonté)")
MLD_ImpCttexte(60,205,195,"Café - Pousse café")
StopDrawing()
StopPrinting()
EndIf
EndIf
EndProcedure
Procedure imp4()
If DefaultPrinter() <> 0
If StartPrinting("Mic")
MLD_impFont("Georgia",24,#PB_Font_HighQuality,0,0,$0)
MLD_impText(-2,20,"ASSOCIATION DES AMIS DE SPIDERBASIC")
MLD_cadre(25,40,160,90,coul)
MLD_impFont("Georgia",32,#PB_Font_HighQuality,0,0,$0)
MLD_ImpCttexte(25,50,185,"GRANDE TOMBOLA")
MLD_impFont("Georgia",20,#PB_Font_HighQuality,0,0,$0)
MLD_ImpCttexte(25,75,185,"Tirage le 29/02/2014")
MLD_impFont("Georgia",18,#PB_Font_HighQuality,0,0,$4E7833)
MLD_ImpCttexte(25,95,185,"Premier prix: Un abonnement de 99 ans a SpiderBasic")
MLD_ImpCttexte(25,110,185,"Deuxieme prix: Un abonnement de 50 ans a SpiderBasic")
MLD_impFont("Georgia",14,#PB_Font_HighQuality,0,0,$0)
MLD_ImpCttexte(25,150,185,"L'ors de cette journée d'autres prix seront distribués")
MLD_ImpCttexte(25,160,185,"Une buvette gratuite sera mise a disposition des participants")
MLD_linehz(-2,200,200,1,0)
MLD_ImpCttexte(25,202.5,185,"Coupez ici")
MLD_linehz(-2,210,200,1,0)
MLD_impFont("Georgia",16,#PB_Font_HighQuality,0,0,$0)
MLD_ImpCttexte(25,215.5,185,"Bulletin de participation")
MLD_impFont("Georgia",14,#PB_Font_HighQuality,0,0,$0)
MLD_impText(-2,230,"Mme Mr __________________________ Prénom: _____________________")
MLD_impText(-2,-2,"Adresse: _______________________ CP: _______ Ville: __________________")
MLD_impText(-2,-2,"Bulletin a faire parvenir accompagné d'un chèque de 2.€ à")
MLD_impText(-2,-2,"Mr FRED 411 avenue du Processeur 67000 Strasbourg")
StopDrawing()
StopPrinting()
EndIf
EndIf
EndProcedure
Procedure imp5()
Dim L.s(5)
L.s(1) = "Informations concernant les nombres flottants"
a$ = "Un nombre flottant est stocké de telle manière que la 'virgule flotte' autour de la partie réelle. De la sorte, "
b$ = "il est possible d'avoir des nombres dont la valeur peut être aussi bien grande que petite. Toutefois vous ne pouvez pas stocker"
c$ =" de grands nombres avec une précision aussi élevée que des petits nombres."
L.s(2) = a$ + b$ + c$
d$ = "Une autre limitation concernant les nombres flottants est qu'ils restent concrètement représentés sous une forme binaire. Ainsi, "
e$ = "ils ne peuvent être restitués qu'à partir de multiples et de divisions en base 2. Celà est important pour comprendre que la représentation"
f$ = " décimale lors de l'affichage ou du calcul n'est pas tout à fait identique à ce que l'on peut attendre dans une représentation humaine."
g$ = " Représenter 0.5 ou 0.125 est simple car ce sont des divisions parfaites de 2, cela est plus complexe pour des nombres comme"
h$ = " 0.11 ou 0.10999999. L'affichage approché de la valeur est toujours correct à un nombre limité de décimales, mais ne soyez pas "
i$ = "surpris si au-delà le nombre affiché s'écarte de la valeur que vous attendez!"
L.s(3) = d$ + e$ + f$ + g$ + h$ + i$
L.s(4) = "Ces remarques s'appliquent aux nombres flottants traités par ordinateur d'une manière générale et non spécifiquement à Purebasic."
j$ = "Comme leur nom l'indique, les 'doubles' sont des flottants 'double-precision' (64-bit) comparativement aux flottants 'simple-precision' que"
k$ = " sont les floats (32-bit). Donc, pour avoir plus de précision dans la manipulation des nombres à virgule, il est préférable d'utiliser"
l$ = " les 'doubles'."
L.s(5) = j$ + k$ + l$
If DefaultPrinter() <> 0
If StartPrinting("Mic")
MLD_impFont("Georgia",14,#PB_Font_HighQuality,#PB_Font_Bold,0,$0)
MLD_ImpCttexte(30,20,180,L.s(1))
MLD_impFont("Georgia",14,#PB_Font_HighQuality,0,0,$0)
MLD_impTextauto(30,40,180,L.s(2))
MLD_impText(30,-2,"")
MLD_impTextauto(30,-2,180,L.s(3))
MLD_impText(30,-2,"")
MLD_impTextauto(30,-2,180,L.s(4))
MLD_impText(30,-2,"")
MLD_impTextauto(30,-2,180,L.s(5))
StopDrawing()
StopPrinting()
EndIf
EndIf
FreeArray(L())
EndProcedure
Procedure imp6()
a$ = "Un nombre flottant est stocké de telle manière que la 'virgule flotte' autour de la partie réelle. De la sorte,"
b$ = " il est possible d'avoir des nombres dont la valeur peut être aussi bien grande que petite. Toutefois vous ne pouvez pas stocker "
c$ ="de grands nombres avec une précision aussi élevée que des petits nombres."
D$ = a$+ b$ + C$
e$ = "Une autre limitation concernant les nombres flottants est qu'ils restent concrètement représentés sous une forme binaire. Ainsi, "
f$ = "ils ne peuvent être restitués qu'à partir de multiples et de divisions en base 2. Celà est important pour comprendre que la représentation"
g$ = " décimale lors de l'affichage ou du calcul n'est pas tout à fait identique à ce que l'on peut attendre dans une représentation humaine."
H$ = e$ + f$ + g$
If DefaultPrinter() <> 0
If StartPrinting("Mic")
MLD_impFont("Georgia",11,#PB_Font_HighQuality,0,0,$0)
MLD_impTextautojust(50,20,165,D$)
MLD_linehz(-2,100,200,0,0)
MLD_impFont("Georgia",8,#PB_Font_HighQuality,0,0,$0)
MLD_impTextautojust(20,140,70,D$)
MLD_impTextautojust(90,140,140,H$)
StopDrawing()
StopPrinting()
EndIf
EndIf
EndProcedure
Enumeration
#btess1
#btess2
#btess3
#btess4
#btess5
#btess6
EndEnumeration
OpenWindow(1, 0, 0, 300, 290, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget)
ButtonGadget(#btess1,40, 30,220,30,"Test Imprimante 1 (Lettre a en-tête)")
ButtonGadget(#btess2,40, 70,220,30,"Test Imprimante 2 (circulaire commerciale)")
ButtonGadget(#btess3,40, 110,220,30,"Test Imprimante 3 (Pour les amis ou autres)")
ButtonGadget(#btess4,40, 150,220,30,"Test Imprimante 4 (Genre Assoc)")
ButtonGadget(#btess5,40, 190,220,30,"Test Imprimante 5 (Genre courrier)")
ButtonGadget(#btess6,40, 230,220,30,"Test Imprimante 6 (Articles ou Romans)")
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget() ; Gadgets
Case #btess1
imp1()
Case #btess2
imp2()
Case #btess3
imp3()
Case #btess4
imp4()
Case #btess5
imp5()
Case #btess6
imp6()
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
End
Michel