borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Printing Webbrowser O/P & Text at the same time)Next Topic (How do i print crystal report in dos mode using vb6) New Topic New Poll Post Reply
AndreaVB Forum : Printing : PictureBox contents and Form
Poster Message
sydek
Level: Trainee

Registered: 04-02-2005
Posts: 1

icon PictureBox contents and Form

Okay I have read a couple of posts about how to print the actual PictureBox, but I need to know how to print the whole form including the PictureBox and its contents.

Right now I have a simple "print" command that has the code me.printform.  When I click on this command the form prints but without the numbers that are supposed to be inside.  When I run the program they are there, but when I print they disappear.

Thanks for the help!

04-02-2005 at 09:47 PM
View Profile Send Email to User Show All Posts | Quote Reply
humberto
Level: VB Lord

Registered: 13-01-2005
Posts: 246
icon Re: PictureBox contents and Form

Private Declare Sub keybd_event Lib "user32" ( _
                    ByVal vBk As Byte, _
                    ByVal vScan As Byte, _
                    ByVal dwFlags As Long, _
                    ByVal dwExtraInfo As Long)

Const VK_SNAPSHOT As Byte = &H2C 'PrintScrn
Const VK_MENU = &H12 'Alt
Const KEYEVENTF_KEYUP = &H2


Public Sub PrntForm(ByVal frmWidth As Single, _
                    ByVal frmHeight As Single)

Dim sWidth As Single
Dim sHeight As Single
Dim sMargin As Single

Clipboard.Clear


keybd_event VK_MENU, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0

DoEvents

Printer.Print

If frmWidth > Printer.ScaleWidth - (2 * sMargin) Then
sWidth = Printer.ScaleWidth - (2 * sMargin)
sHeight = (sWidth / frmWidth) * frmHeight
Else
sWidth = frmWidth
sHeight = frmHeight
End If

Printer.PaintPicture Clipboard.GetData, sMargin, sMargin, sWidth, sHeight

Printer.CurrentX = sMargin
Printer.CurrentY = (sMargin * 1.5) + sHeight
Printer.Print Format$(Now, "mm/dd/yyyy hh:mm")

Printer.EndDoc

End Sub

Private Sub Command1_Click()

PrntForm Form1.ScaleWidth, Form1.ScaleHeight

End Sub

11-02-2005 at 11:43 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Printing : PictureBox contents and Form
Previous Topic (Printing Webbrowser O/P & Text at the same time)Next Topic (How do i print crystal report in dos mode using vb6) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder