I need to know how big the graphics area of the printer is … without displaying any dialog boxes up front…
and I don’t want to activate the printer (ie. print a blank page)
dim g as graphics
g=OpenPrinter
g.PrintingCancelled=true
I THOUGHT I could do it this way… but even though the LangRef says you can assign a value to PrintingCanceled… .the compiler says no.
I need the Graphics Size at default settings (72dpi, Portrait)… from that I can determine actual PAPER size, margins etc…
Dim s As String
Dim theps As PrinterSetup
Dim DPI_x As Integer
Dim DPI_y As Integer
Dim Paper_W As Integer
Dim Paper_H As Integer
Dim Print_W As Integer
Dim Print_H As Integer
Dim Margin_T As Integer
Dim Margin_L As Integer
Dim margin_B As Integer
Dim margin_R As Integer
Theps = New PrinterSetup // third go around, now all properties are accurate
DPI_x=thePS.HorizontalResolution
DPI_y=thePS.VerticalResolution
Paper_W=thePS.PageWidth
Paper_H=thePS.PageHeight
Print_W=thePS.Width
Print_H=thePS.Height
Margin_T=Abs(thePS.PageTop)
Margin_L=Abs(thePS.PageLeft)
Margin_B=Paper_H-Print_H-Margin_T
Margin_R=Paper_W-Print_W-Margin_L
s = "DPI Resolution = " + Format(DPI_x, "-###") + "x" + Format(DPI_y, "-###") + EndOfLine +EndOfLine _
+"INFORMATION IN PIXELS"+EndOfLine _
+ "Paper Size=" + Format(paper_w, "-##,###")+"x"+Format(paper_H, "-##,###") + EndOfLine _
+ "Print Size= " + Format(print_W, "-##,###") +"x"+Format(print_H, "-##,###") + EndOfLine _
+ "Margin= " + Format(Margin_T, "-#")+","+Format(Margin_L,"##,###")+","+Format(Margin_B,"##,###")+","+Format(Margin_R,"##,###") +EndOfLine _
+ EndOfLine _
+"INFORMATION IN INCHES"+EndOfLine _
+ "Paper Size=" + Format(paper_w/DPI_x, "-#0.000")+"x"+Format(paper_H/DPI_y, "-#0.000") + EndOfLine _
+ "Print Size = " + Format(print_W/DPI_x, "-#0.000") +"x"+Format(print_H/DPI_y, "-#0.000") + EndOfLine _
+ "Margin= " + Format(Margin_T/DPI_Y, "-#0.000")+","+Format(Margin_L/DPI_X,"-#0.000")+","+Format(Margin_B/DPI_Y,"-#0.000")+","+Format(Margin_R/DPI_x,"-#0.000")
MsgBox s