Results 1 to 6 of 6

Thread: Printing multiple Pictureboxes

  1. #1

    Thread Starter
    Addicted Member run_GMoney's Avatar
    Join Date
    May 2002
    Location
    Detroit
    Posts
    186

    Printing multiple Pictureboxes

    Can you print more than one picturebox on the same piece of paper? I'm looking to do something like this:

    VB Code:
    1. Private Sub cmdPrintPicture_Click()
    2.  
    3. Printer.PaintPicture Picture1.Image, 0, 0
    4. For i = 5 To 45
    5.     If Check1(i).Value = 1 Then
    6.         Picture2.Print Check1(i).Caption
    7.     End If
    8. Next
    9. Printer.PaintPicture Picture2.Image, 10, 0
    10. Printer.EndDoc
    11.  
    12. End Sub
    Where the first PictureBox prints a graph and the second PictureBox prints the corresponding checkboxes. I know the above code won't work but it should at least give an idea of what I want to do. Thanks
    Last edited by run_GMoney; Jan 13th, 2003 at 02:19 PM.
    Place Your VBForums Ad Here

  2. #2
    Frenzied Member McGenius's Avatar
    Join Date
    Jan 2003
    Posts
    1,199
    You don't really need the second Picturebox.
    VB Code:
    1. Private Sub cmdPrintPicture_Click()
    2.  
    3.     Printer.PaintPicture Picture1.Image, 0, 0
    4.     'adjust Printer.CurrentX/Y - 'set actual number so text will appear under your graph
    5.     Printer.CurrentX = 100
    6.     Printer.CurrentY = 1000
    7.     For i = 5 To 45
    8.         If Check1(i).Value = 1 Then
    9.             Printer.Print Check1(i).Caption
    10.         End If
    11.     Next
    12.     Printer.EndDoc
    13.  
    14. End Sub
    McGenius

  3. #3

    Thread Starter
    Addicted Member run_GMoney's Avatar
    Join Date
    May 2002
    Location
    Detroit
    Posts
    186
    Thanks for that. My next question is can I, instead of using the Check1(i).Caption, print an actual copy of the checkboxes that are checked? I don't even know if that's possible but it would look a lot better. Thanks again for that code though, it works great.

    *EDIT: One more thing. Does a PictureBox not AutoSize if text is sent to it? I've set AutoSize = True on a PictureBox and sent some text to it but no Autosizing. Just curious if anyone knew.
    Last edited by run_GMoney; Jan 13th, 2003 at 03:40 PM.
    Place Your VBForums Ad Here

  4. #4
    Frenzied Member McGenius's Avatar
    Join Date
    Jan 2003
    Posts
    1,199
    Originally posted by run_GMoney
    Thanks for that. My next question is can I, instead of using the Check1(i).Caption, print an actual copy of the checkboxes that are checked? I don't even know if that's possible but it would look a lot better. Thanks again for that code though, it works great.
    Everything (well almost) is possible, but in this case it would be total overkill - you need to clip (capture) a particular region, then create a context device, and then ... so, it's not worth it. BTW, (it just came to mind) you may create an image of your Checkbox and print that instead.

    *EDIT: One more thing. Does a PictureBox not AutoSize if text is sent to it? I've set AutoSize = True on a PictureBox and sent some text to it but no Autosizing. Just curious if anyone knew.
    When you print to a Picturebox you are actually setting its Image and not Picture, therefore Autosize property wont be affected.
    McGenius

  5. #5

    Thread Starter
    Addicted Member run_GMoney's Avatar
    Join Date
    May 2002
    Location
    Detroit
    Posts
    186
    Originally posted by McGenius
    BTW, (it just came to mind) you may create an image of your Checkbox and print that instead.
    How would I accomplish something like that?


    When you print to a Picturebox you are actually setting its Image and not Picture, therefore Autosize property wont be affected.
    Well that's just darn inconvenient. Shouldn't be a huge problem though. Don't s'pose there's any way to alter that is there? I mean, my users can select anywhere from 1 to 40 different rounds so I was hoping to just have the Picturebox Autosize.
    Place Your VBForums Ad Here

  6. #6
    Frenzied Member McGenius's Avatar
    Join Date
    Jan 2003
    Posts
    1,199
    1. At run time press Alt+Print Scrn and paste it onto Paintbrush. Crop your Checkbox and save it as a small bmp file. In your project create an Image control directly on the Picturebox and load that bmp into it. Set cvisible to False. Show it before printing and hide it afterwords. It's an ugly method but it will work at some extent.

    2. Not really - that's not what the Picturebox is primarily designed for: displaing images.
    McGenius

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