Results 1 to 5 of 5

Thread: Printing Problema...

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    10

    Printing Problema...

    Is there anyway of printing a Form that is bigger than the screen (A4 size) using the PrintForm Method?

    I'm having a problem with an application that i created. People are complaining that sometimes the form isn't totally printed, only 2/3 appears...
    What is strange is that most of the times the print goes well, but there are times where it goes wrong and if we insist it eventually goes well...
    Particulary in my system i dont remeber see this kind of bad behaviour...

    For me it only can be one of 2 things:
    - the fact that the Form height exceeds the screen size ;
    - or that is a limitation in PrintForm method when printing to a remote shared Printer (HP 840C in this case).

    can someone help me???
    Do i have to forget PrintForm method and start using Printer object ? I have to many controls in the form but if i have to do it...

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    Try this
    VB Code:
    1. Option Explicit
    2. 'Prntform sample from BlackBeltVB.com
    3. ' [url]http://blackbeltvb.com[/url]
    4.  
    5. Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    6. Private Const VK_MENU As Byte = &H12
    7. Private Const VK_SNAPSHOT As Byte = &H2C
    8. Private Const KEYEVENTF_KEYUP = &H2
    9. Private Sub Command1_Click()
    10.  
    11.     Dim lWidth As Long
    12.     Dim lHeight As Long
    13.    
    14.     Clipboard.Clear
    15.     Call keybd_event(VK_MENU, 0, 0, 0)
    16.     Call keybd_event(VK_SNAPSHOT, 0, 0, 0)
    17.     DoEvents
    18.     Call keybd_event(VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0)
    19.     Call keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0)
    20.    
    21.     Printer.Print
    22.    
    23.     If Width > Printer.ScaleWidth Then
    24.         lWidth = Printer.ScaleWidth
    25.         lHeight = (Printer.ScaleWidth / Width) * Height
    26.     Else
    27.         lWidth = Width
    28.         lHeight = Height
    29.     End If
    30.    
    31.     Printer.PaintPicture Clipboard.GetData, 0, 0, lWidth, lHeight
    32.     Printer.EndDoc
    33.  
    34. End Sub

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106
    Also, be sure you have the latest service packs. I remember being pretty frustrated printing in VB. I finally tracked one of the problems down to a bug in the compiler. Microsoft acknowledged that it was a bug, directed me to a service pack, and a couple of other bugs that I hadn't examined went away at the same time.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    10
    MartinLiss

    unfortunelly i didn't got time yet to try your code but i will do it But tell me one thing what the code does is a "snapshot" of the screen isn't it? that won't do for me because in my application is possible that i may have to print more than 1A4 sheet. This because i have a listbox with several information on it, and when the listbox is to big that doesn't fit on 1sheet i have to use another template hidden form to print the 2nd,3rd,...,nth sheet.

    at the moment i'm using 2templates hidden forms, the second is used when the first can't hold by itself all the information. This is working quit well in my system but as i told you, in other systems the print doesn't go well all the times.

    Is that because the form exceeds the screen size?

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    10
    Shaggy Hiker

    hi! have you ever had problems like the one i mentioned? sometimes the printing goes well another time goes bad? and in your case service packs was the solution?


    tkx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width