humberto Level: VB Lord
 Registered: 13-01-2005 Posts: 246
|
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
|