|
-
Feb 7th, 2006, 08:43 AM
#1
Thread Starter
Member
[RESOLVED] Second thread help needed - mail issue
Hello again
I know how to send mail and define the email body. Here's my issue:
I have a form with checkboxes and textfields which I want to print out. Is there any easy way to go about this?
I was thinking about transfering the information entered into a text file and print it out, but that just seems too stupid.
-
Feb 7th, 2006, 08:46 AM
#2
Re: Second thread help needed - mail issue
What does the printing have to do with the e-mail?
-
Feb 7th, 2006, 08:48 AM
#3
Re: Second thread help needed - mail issue
So are these just strings of text?? If so, check out a .NET printing class
If you wish to just print an image of the form, check out my sig for the "Easy Screen Capture Class" in order to get a snapshot of the form by its handle....
-
Feb 7th, 2006, 08:48 AM
#4
Thread Starter
Member
Re: Second thread help needed - mail issue
I mean printing... But I also have to send the form info to email. I forgot to say. Sorry
-
Feb 7th, 2006, 08:58 AM
#5
Thread Starter
Member
Re: Second thread help needed - mail issue
 Originally Posted by gigemboy
So are these just strings of text?? If so, check out a .NET printing class
If you wish to just print an image of the form, check out my sig for the "Easy Screen Capture Class" in order to get a snapshot of the form by its handle....
I will try this special class. Thank you.
-
Feb 7th, 2006, 09:21 AM
#6
Thread Starter
Member
Re: Second thread help needed - mail issue
Last thing thoug. The window img grabber works fine. Anybody know how to print directly from memory? This would be preferable so that I won't be messing with the clients harddrive.
And also. The printdocument class makes no sense to me.
-
Feb 7th, 2006, 04:29 PM
#7
Re: Second thread help needed - mail issue
Actually, the PrintDocument class and it's use are really quite simple, but widely misunderstood because they don't work how people expect printing to work.
1. You create a PrintDocument object.
2. You call its Print method.
3. You handle its PrintPage event and use GDI+ to print exactly what you want, exactly where you want.
The reason people get confused is that they don't know how to use GDI+ properly. It may seem like a lot of trouble to calculate exactly where on a page something has to be printed, what font to use and so on, but this method gives you absolute control over every aspect of your printing, so it's very powerful. Here's a quick example that will print three lines, one to a page, displaying the current page number:
VB Code:
Private pageNumber As Integer 'The number of the page being printed.
Private Sub Print()
Dim pd As New Printing.PrintDocument()
AddHandler pd.PrintPage, AddressOf PrintPage
'Set the initial page number.
Me.pageNumber = 1
'Start printing.
pd.Print()
End Sub
Private Sub PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Dim stringToPrint As String = String.Format("This is page {0}", Me.pageNumber)
Dim printFont As New Font(FontFamily.GenericSansSerif, 12)
Dim xLocation As Integer = 25
Dim yLocation As Integer = 25 + (Me.pageNumber - 1) * 50
'Draw the string on the printing surface.
e.Graphics.DrawString(stringToPrint, printFont, Brushes.Black, xLocation, yLocation)
If Me.pageNumber < 3 Then
'Print more pages.
Me.pageNumber += 1
e.HasMorePages = True
Else
'All pages have been printed.
e.HasMorePages = False
End If
End Sub
Note that if you set e.HasMorePages to True the PrintPage event will be raised again and you can print another page. This means that you need some way to keep track of where you are up to in the printing process. In this case I have used the class level variable named pageNumber. In a more complex scenario you may need to track more information between events. I've used the DrawString method to simply print a single string at a different location depending on the page. The Graphics object can draw strings, images and many different shapes, thus giving you an enormous range of things you can print.
-
Feb 7th, 2006, 04:43 PM
#8
Re: Second thread help needed - mail issue
The capture class does capture in memory (since you said it worked fine)... there are ways to just grab the image in an image object (CaptureWindow method), then you just use the graphics object to draw the image to print...
-
Feb 8th, 2006, 02:18 AM
#9
Thread Starter
Member
Re: Second thread help needed - mail issue
Thanks guys... Hopefully I can figure it out. I will something with the above code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|