PureBasic and general programming beginner here......
"Under Windows 7"
My report prints fine when hitting "Print" but if I wish to cancel,when I hit the cancel button on the Printer Select Window the program crashes.
My Report Procedure:
Code: Select all
Procedure Printout() ;Creates printed report
UsePNGImageDecoder()
UseJPEGImageDecoder()
UseTIFFImageDecoder()
LoadImage(#LOGO_FILE,Logo.s)
screenres.i=96
dpi.i=Val(PrinterRes.s)
w.i=600
h.i=400
printscale.i=dpi/screenres
xdpi.i=printscale*w.i
ydpi.i=printscale*h.i
LoadFont (20, "Arial", 20*printscale,#PB_Font_HighQuality)
LoadFont (12, "Arial", 12*printscale,#PB_Font_HighQuality)
If GetGadgetState(#CHECK_PRINT)=1
DefaultPrinter()
Else
PrintRequester()
EndIf
StartPrinting("test")
StartDrawing(PrinterOutput())
DrawingFont(FontID(20))
DrawText(300*printscale, 18*10*printscale,"Noise Power Ratio Test",RGB(0,0,0),RGB(255,255,255))
If range.f>=ValF(MinimumRange)
DrawText(350*Printscale, 55*10*Printscale,"PASSED",RGB(0,0,0),RGB(255,255,255))
Else
DrawText(350*Printscale, 55*10*Printscale,"FAILED",RGB(0,0,0),RGB(255,255,255))
EndIf
DrawingFont(FontID(12))
;DrawText(300, 44*14*Printscale, "S/N= "+GetGadgetText(#Gadget_Form1_SerialNumber),RGB(0,0,255),RGB(255,255,255))
;DrawText(300, 42*14*Printscale, "Customer="+Customer.s,RGB(0,0,255),RGB(255,255,255))
DrawText(75*Printscale, 21*10*Printscale,"___________________________________________________________________________",RGB(0,0,0),RGB(255,255,255))
;Information on the left
DrawText(75*Printscale, 28*10*Printscale,"Date: "+FormatDate("%mm/%dd/%yyyy", Date()) ,RGB(0,0,0),RGB(255,255,255))
DrawText(75*Printscale, 30*10*Printscale,"Technician: "+Tech ,RGB(0,0,0),RGB(255,255,255))
DrawText(75*Printscale, 32*10*Printscale,"Customer: "+Customer ,RGB(0,0,0),RGB(255,255,255))
DrawText(75*Printscale, 34*10*Printscale,"Minimum NPR: "+ GetGadgetText(#Gadget_Form1_MinNPR)+" dB",RGB(0,0,0),RGB(255,255,255))
DrawText(75*Printscale, 36*10*Printscale,"NPR Range: "+ range.f+" dB",RGB(0,0,0),RGB(255,255,255))
DrawText(75*Printscale, 38*10*Printscale,"Minimum Range: "+ MinimumRange +" dB",RGB(0,0,0),RGB(255,255,255))
DrawText(75*Printscale, 40*10*Printscale,"Peak NPR: "+ StrF(Peak.f,2)+" dB",RGB(0,0,0),RGB(255,255,255))
DrawText(75*Printscale, 42*10*Printscale,"Cross Over: "+ StrF(ValF(nprmin.s),2)+" dBmV/Hz",RGB(0,0,0),RGB(255,255,255))
DrawText(75*Printscale, 44*10*Printscale,"Serial Number: "+ GetGadgetText(#GADGET_FORM1_SERIALNUMBER),RGB(0,0,0),RGB(255,255,255))
DrawText(75*Printscale, 46*10*Printscale,"Assembly ID#: "+ GetGadgetText(#GADGET_FORM1_ASSYIDNUM),RGB(0,0,0),RGB(255,255,255))
;Information on the right
DrawText(400*Printscale, 28*10*Printscale,"Power LED, Check +5V and -5V Power Supply:" ,RGB(0,0,0),RGB(255,255,255))
DrawText(400*Printscale, 30*10*Printscale,"Clean Optical Connectors:" ,RGB(0,0,0),RGB(255,255,255))
DrawText(400*Printscale, 32*10*Printscale,"Laser Power:" ,RGB(0,0,0),RGB(255,255,255))
DrawText(400*Printscale, 34*10*Printscale,"Calibrate Optical Power Test Point 1V/mW:" ,RGB(0,0,0),RGB(255,255,255))
DrawText(400*Printscale, 36*10*Printscale,"Frequency Response Test, 5-65 MHz, +/- 1dB:" ,RGB(0,0,0),RGB(255,255,255))
DrawText(400*Printscale, 38*10*Printscale,"Adjust OMI:" ,RGB(0,0,0),RGB(255,255,255))
DrawText(400*Printscale, 40*10*Printscale,"Test Point -30 dB from RF Input(-24dBmV):" ,RGB(0,0,0),RGB(255,255,255))
DrawText(400*Printscale, 44*10*Printscale,"Signature of Conformance:__________________" ,RGB(0,0,0),RGB(255,255,255))
DrawText(400*Printscale, 46*10*Printscale,"Final QC:__________________" ,RGB(0,0,0),RGB(255,255,255))
;Draw the plot
DrawImage(ImageID(1),125*printscale,600*printscale,xdpi,ydpi)
DrawImage(ImageID(#LOGO_FILE),75*printscale,50*Printscale,(1585/10)*printscale,(784/10)*printscale)
StopDrawing()
StopPrinting()
EndProcedure