![]() |
Tipp 0387
|
PictureBox-Inhalt drucken
|
 |
|
Autor/Einsender: Datum: |
|
Angie 18.03.2004 |
|
Entwicklungsumgebung: |
|
VB 6 |
|
|
Mit den folgenden zwei Zeilen Code kann eine in einer PictureBox geladene Grafik ausgedruckt werden:
|
|
|
Printer.PaintPicture Picture1.Picture
Printer.EndDoc
|
|
|
Sollen aber alle in einer PictureBox enthaltenen Elemente (also Grafik(en) und z.B. auch Steuerelemente, wie TextBox, CommandButton usw.) mit
ausgedruckt werden, benötigt man die API-Funktion SendMessage, um in eine 2. PictureBox das Image der auszudruckenden PictureBox zu kopieren.
|
|
|
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_PAINT = &HF
Private Const WM_PRINT = &H317
Private Const PRF_CLIENT = &H4&
Private Const PRF_CHILDREN = &H10&
Private Const PRF_OWNED = &H20&
Private Sub Form_Load()
With picToPrint
.Width = picSource.Width
.Height = picSource.Height
.Visible = False
End With
End Sub
Private Sub cmdPrint_Click()
cmdQuit.SetFocus
picToPrint.AutoRedraw = True
SendMessage picSource.hwnd, WM_PAINT, picToPrint.hDC, 0
SendMessage picSource.hwnd, WM_PRINT, picToPrint.hDC, _
PRF_CHILDREN + PRF_CLIENT + PRF_OWNED
picToPrint.Picture = picToPrint.Image
picToPrint.AutoRedraw = False
Printer.PaintPicture picToPrint.Image, 0, 0
Printer.EndDoc
End Sub
|
|
|
|
|
Windows-Version |
95 |
 |
|
98/SE |
 |
|
ME |
 |
|
NT |
 |
|
2000 |
 |
|
XP |
 |
|
Vista |
 |
|
Win
7 |
 |
|
|
VB-Version |
VBA 5 |
 |
|
VBA 6 |
 |
|
VB 4/16 |
 |
|
VB 4/32 |
 |
|
VB 5 |
 |
|
VB 6 |
 |
|
|
|
Download (9,1 kB)
|
Downloads bisher: [ 1845 ]
|
|
|