VB"De Print Yapma
-
Mesela programda bissürü yazı var.Adam da ekran görüntüsünü ya da ne biliyim işte programın görüntüsünü ya da yazıları print etcek.Mümkün mü ?
-
Mümkün :)
-
Option Explicit
Private Declare Function SendMessage Lib "user32.dll" 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&
Public Sub PrintPictureBox(Box As PictureBox, _
Optional X As Single = 0, _
Optional Y As Single = 0)
Dim rv As Long
Dim ar As Boolean
On Error GoTo Exit_Sub
With Box
ar = .AutoRedraw
.AutoRedraw = True
Printer.Print
rv = SendMessage(.hwnd, WM_PAINT, .hDC, 0)
rv = SendMessage(.hwnd, WM_PRINT, .hDC, _
PRF_CHILDREN Or PRF_CLIENT Or PRF_OWNED)
.Picture = .Image
Printer.PaintPicture .Picture, X, Y
Printer.EndDoc
Box.Line (0, 0)-(.ScaleWidth, .ScaleHeight), .BackColor, BF
'Restore ReDraw
.AutoRedraw = ar
End With
Exit_Sub:
If Err.Number Then MsgBox Err.Description, vbOKOnly, "Printer Hatası!"
End Sub
bunları load forma yaz
bide yazdır butonu için
buton ekle
içine bunları yaz
Private Sub Command1_Click()
PrintPictureBox Picture1, 1000, 1000
End Sub
ve bittii -
Sağol.
Toplam Hit: 2112 Toplam Mesaj: 4