Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Picture Box Data Problem 1

Status
Not open for further replies.

rb74

Programmer
May 5, 2002
64
US
Hi,

I have a small app, where data is entered on one form, and calculations are generated and printed to a picture box on a second form. I would like the user to be able to print to data generated. I can't use .printform because the text box is smaller than the viewable data (hence I have scroll bars to view all of the data.) I am also trying to implement this using the print dialog. Am I hosed and have to print to a Rich Text Box, or is this possible?

Thanks,

Rob
 
You could use the printer object. Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
rb74,

Not 100% sure if I understand your problem. Is all of the data printed onto the picturebox and you want to print that? If so you can use:

Printer.paintpicture picture1.image,0,0,"the width you want", "the height you want"

If you are wanting the data to be printed on the picturebox from a textbox, you can set the currentx and currenty and use the print statement.

picture1.currentx=100
picture1.currenty=100
picture1.print text1.text

Hope I am not way off,

tsmith
 
tsmith,

You are right. I will try to explain further. I have a data entry form, and when you click a calculate button, a new form is generated with the calculated data. The form with the calculated data consists of two picture boxes with one inside the other, to allow scrolling to view all of the data(this is another issue I have...see below). Ladyhawk suggested using the Printer object, and it worked, but the data did not print until I closed the application(weird, do you know to get around that?). I was looking for a method to print the contents of the picture box like you would if you were to use a rich text box. I am using a Print Dialog box to allow the user to set some parameters. I used your first suggestion, and it only printed a blank page. I think the reason why is because the data is not an image, but rather data printed to the picture box. I chose a picture box to allow me to format the calculations according to the user's specifications, but I was wondering if a rich text box might be better? So, since the Printer.Paintpicture Picture1.image,0,0,"the width you want", "the height you want" didn't work, any suggestions?

My other issue is if I scroll the picture box. First, if the font size of the picture box is too large, and the data is beyond the viewable area of the picture box, the data below the viewable area is not there. If I make the font size of the picture box smaller, and I scroll up or down, the data that is not viewable at the top due to scrolling disappears. Should I use the Picture1.Refresh function?


Rob
 
Rob,

After sending the information to the printer you have to end the document to print it. Use Printer.enddoc.

ie...
printer.print "to print this use printer.enddoc"
printer.enddoc

end sub

that should take care of the information printing after you close your app.

Question about the picturebox. How is the information placed in the picturebox. If it is printed using the print statement

ie...
picture1.print "calculated data"

then the picture1.paintpicture....will print the image. You have to make sure that the picturebox's autoredraw property is set to true. All of the data that is printed to the picturebox while this property is set to false will NOT be printed.

ie...
sub print_stuff()

'assuming picture1's autoredraw property is false
picture1.print "This data will not be printed"
picture1.autoredraw=true
picture1.print "This stuff will be printed"
printer.paintpicture picture1.image,0,0 printer.width,printer.height
'this will stretch the picturebox to fit the printer.width and height.
'if you want to print the picturebox as is then replace printer.width, printer.height with picture1.width and picture1.height.

If the calculated data is place onto the picturebox in controls. ie. picture1.label1.caption="calculated data"

then the paintpicture method will not work. What you can use is the sendmessage api to capture a snapshot and save it to a picture(bmp) then load this picture into the picturebox and print the picturebox's picture. With out knowing the specific size of your picturebox this is probably how I would handle your scrolling problem.

If you need more info on the sendmessage api you can e-mail me at tsmith1@elp.rr.com

good luck,

tsmith
 
tsmith,

Thanks a lot, that did it. It's been a while since I programmed in VB, and I never used the autoredraw function in other programs. I used picture1.width and picture1.height for the boundaries to print the data. By setting the autoredraw to True, this solved my scrolling problem as well.

Thanks again, and May the Force be with you.

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top