StartPrinting with no StopPrinting?

Just starting out? Need help? Post your questions and find answers here.
fromVB
User
User
Posts: 82
Joined: Sun Jul 29, 2012 2:27 am

StartPrinting with no StopPrinting?

Post by fromVB »

This code works to return the printable area but exits without calling StopPrinting so as not to eject a blank page. The print job flashes briefly in the spooler window but gets removed as soon as the procedure returns:

Code: Select all

Procedure getPaperSize()
  If PrintRequester()
    If StartPrinting("Vector Printing")  
      If StartVectorDrawing(PrinterVectorOutput(#PB_Unit_Millimeter))
        Debug VectorOutputWidth()
        Debug VectorOutputHeight()
        StopVectorDrawing()
        ProcedureReturn 
      EndIf
      StopPrinting()
    EndIf
  EndIf
EndProcedure

getPaperSize()
Will this not calling of StopPrinting cause any kind of memory leak or device error down the road?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: StartPrinting with no StopPrinting?

Post by IdeasVacuum »

You would expect it to be a problem (by the way, your procedure does call StopPrinting())
If the app is only for Windows, a wealth of information can be collected from the printer via the API.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
fromVB
User
User
Posts: 82
Joined: Sun Jul 29, 2012 2:27 am

Re: StartPrinting with no StopPrinting?

Post by fromVB »

IdeasVacuum wrote:You would expect it to be a problem (by the way, your procedure does call StopPrinting())
If the app is only for Windows, a wealth of information can be collected from the printer via the API.
Hi IdeasVacuum. StopPrinting is not called because the procedure exits before reaching it. And the routine still works if StopPrinting is remmed out.

API works but not so accurately with vector output. This is a normal A4 paper:

Code: Select all

GetDeviceCaps_(pdc, #HORZRES) = 4760
GetDeviceCaps_(pdc, #VERTRES) = 6814

PrinterPageWidth() = 4760
PrinterPageHeight() = 6814

VectorOutputWidth() = 4771
VectorOutputHeight() = 6803
I am only able to get the vector width and height of the printer after calling StartPrinting. :evil:

What is the problem you said you expect if StopPrinting is not called?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: StartPrinting with no StopPrinting?

Post by IdeasVacuum »

PB5.42LTS x86, Win7x86
Well, I expected problems to arise because PB usually expects a Start to be followed with a Stop, but I don't know if that is the case in this instance. Certainly if another StartPrinting() is called after getPaperSize(), no harm seems to have been done, but since the print area available is device dependent, you would not expect to have to Start Printing before being able to verify the size of the print area. This works on my PC:

Code: Select all

Procedure getPaperSize()
  If PrintRequester()

      If StartVectorDrawing(PrinterVectorOutput(#PB_Unit_Millimeter))
        Debug VectorOutputWidth()
        Debug VectorOutputHeight()
        StopVectorDrawing()
      EndIf

  EndIf
EndProcedure

getPaperSize()
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
fromVB
User
User
Posts: 82
Joined: Sun Jul 29, 2012 2:27 am

Re: StartPrinting with no StopPrinting?

Post by fromVB »

IdeasVacuum wrote:PB5.42LTS x86, Win7x86
Well, I expected problems to arise because PB usually expects a Start to be followed with a Stop, but I don't know if that is the case in this instance. Certainly if another StartPrinting() is called after getPaperSize(), no harm seems to have been done, but since the print area available is device dependent, you would not expect to have to Start Printing before being able to verify the size of the print area. This works on my PC:

Code: Select all

Procedure getPaperSize()
  If PrintRequester()

      If StartVectorDrawing(PrinterVectorOutput(#PB_Unit_Millimeter))
        Debug VectorOutputWidth()
        Debug VectorOutputHeight()
        StopVectorDrawing()
      EndIf

  EndIf
EndProcedure

getPaperSize()
Thanks IdeasVacuum. Never thought of trying that. :oops:
Post Reply