A customer says that a program of mine isn't able to print.
I want to know if it is perhaps related to his PC or PC-knowledge, because I cannot find any bug.
Could you please try the following snippet, perhaps with default printing-properties set to landscape and high resolution under Start -> Printer -> <standard printer> ?
Or does anybody find a bug or has an idea how to improve the source to make the printing more reliable ?
Thanks a lot!
Code: Select all
#offsetX = 0
#offsetY = 0
#percentX = 1
#percentY = #percentX
Procedure PrintScreenEx(offsetX.f, offsetY.f, widthPercent.f, heightPercent.f)
    hDcDesktop  = GetDC_(GetDesktopWindow_())
    
    w = GetSystemMetrics_(#SM_CXSCREEN)
    h = GetSystemMetrics_(#SM_CYSCREEN)
    CreateImage(0, w, h)
     
    hDC = StartDrawing(ImageOutput(0))
      BitBlt_(hDC, 0, 0, w, h, hDcDesktop, 0, 0, #SRCCOPY)
    StopDrawing()
    ReleaseDC_(GetDesktopWindow_(), hDcDesktop)
    GrabImage(0, 1, offsetX * w, offsetY * h, widthPercent * w, heightPercent * h)
    FreeImage(0)
    DefaultPrinter()
    If 1.0 * ImageWidth(1) / PrinterPageWidth() >= 1.0 * ImageHeight(1) / PrinterPageHeight()
      pw = PrinterPageWidth()
      ph = ImageHeight(1) * PrinterPageWidth() / ImageWidth(1)
    Else 
      ph = PrinterPageHeight()
      pw = ImageWidth(1) * PrinterPageHeight() / ImageHeight(1)
    EndIf
    
    If StartPrinting("Print_Screen")
      If StartDrawing(PrinterOutput())
        DrawImage(ImageID(1), (PrinterPageWidth() - pw)/2, (PrinterPageHeight() - ph)/2, pw, ph)
        StopDrawing()
      EndIf
      StopPrinting()
    EndIf
    
    
EndProcedure
PrintScreenEx(#offsetX, #offsetY, #percentX, #percentY)






 )
 )