رامین مرادی
سه شنبه 11 بهمن 1390, 18:37 عصر
سلام دوستان یه تابع بود که فرم رو پرینت می کرد. با اون می تونم فرم رو چاپ کنم حالا...
من یه پیکجر باکس دارم توش چند تا هم کنترل دارم چه طور اونو پرینت کنم
ممنون
Payam Moradi
سه شنبه 11 بهمن 1390, 21:46 عصر
سلام
كد زير را در فرم خود كپي كرده و از تابع PrintPictureBox استفاده نماييد.
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& ' Draw the window's client area
Private Const PRF_CHILDREN = &H10& ' Draw all visible child
Private Const PRF_OWNED = &H20& ' Draw all owned windows
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
'Save ReDraw value
ar = .AutoRedraw
'Set persistance
.AutoRedraw = True
'Wake up printer
Printer.Print
'Draw controls to picture box
rv = SendMessage(.hwnd, WM_PAINT, .hDC, 0)
rv = SendMessage(.hwnd, WM_PRINT, .hDC, _
PRF_CHILDREN Or PRF_CLIENT Or PRF_OWNED)
'Refresh image to picture property
.Picture = .Image
'Copy picture to Printer
Printer.PaintPicture .Picture, X, Y
Printer.EndDoc
'Restore backcolor (Re-load picture if picture was used)
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 Error!"
End Sub
Private Sub Command1_Click()
PrintPictureBox Picture1, 0, 0
End Sub
موفق باشيد:چشمک:
MohammadGh2011
سه شنبه 11 بهمن 1390, 22:21 عصر
سلام عليکم
پرینت پیکچر باکس
Dim stdPicture As stdPicture
Set stdPicture = LoadPicture("c:\Pictur_Name.bmp")
Printer.PaintPicture stdPicture, 0, 0
Set stdPicture = Nothing
Printer.EndDoc
موفق باشيد
رامین مرادی
جمعه 14 بهمن 1390, 11:42 صبح
سلام دوستان
می خواستم ازتون تشکر کنم ولی این کد ها رو نتونستم اجرا کنم اگه ممکنه یه برنامه کوچولو به صورت نمونه بزارید ببینم ممنون می شم
Payam Moradi
جمعه 14 بهمن 1390, 18:08 عصر
اينم نمونش:چشمک:
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.