PrintScreen in VB9 (VS2008) RRS feed

  • 問題

  • Hi.

    I have a program that I am developing and it is coming along pretty well with a major exception.  That exception is a print-screen function.  I need to be able to print the window(form). 


    The program main form is large (1242x645); too large to fit on an ordinary printer.    A gif of it is here:


    I appologize for the smearing but you never know nowdays.


    I found some code that does a printscreen.  A copy of that code is here:


    and I thank the originator though unfortunetly I have lost track of who he/she is.


    Now my problem is that it does not fit.  The code sends it to the printer full size and set to portrait.  Of course I want to set it to landscape and make it smaller so it will print on the standard 8.5 x11.


    If anyone has any suggestions, they will be greatly appreciated.


    Kind Regards to all.

    2009年1月29日 18:41


  • Hi Taylor

    I would suggest you to try to modify the code which does the print screen function

    dim A4Width as decimal = A4SizeWidth In Pixel
    Dim A4Height as Decimal = (objSize.Height/objSize.Width) *A4Width
    (I am not sure how many pixal it is on a A4Size paper, hope you can find it)

      bmpScreenshot = New Bitmap(A4Width , A4Height , objGraphics)
    Dim objGraphics2 As Graphics = Graphics.FromImage(bmpScreenshot)
    Dim deviceContext1 As IntPtr = objGraphics.GetHdc
    Dim deviceContext2 As IntPtr = objGraphics2.GetHdc

    Please have a look at the URL below for more information about how to resize image to A4 size and print it landscape.
    Hope this can help.
    Please forgive me if it does not work.
    2009年1月29日 22:15
  • For Landscape issue, you may try the follow in your code

    1 If MyPrintDialog.ShowDialog = DialogResult.OK Then   
    2     MyPrintDocument.DefaultPageSettings.Landscape = true  
    3     MyPrintDocument.Print()  
    4 End If 


    Microsoft MVP, Microsoft Community Star(TW & HK), MCT, MCSD, MCAD, MCSE+I, MCDBA, MCDST, MCSA
    2009年2月4日 2:57