PDA

View Full Version : سوال: commondialog



ali-software
چهارشنبه 25 شهریور 1388, 15:40 عصر
چطور میشه با commondialog فقط از textbox پرینت گرفت.دوستان تاکید می کنم فقط از textbox نه از فرم.

r0ot$harp
چهارشنبه 25 شهریور 1388, 16:27 عصر
چطور میشه با commondialog فقط از textbox پرینت گرفت.دوستان تاکید می کنم فقط از textbox نه از فرم.

شما می خواهید از طریق چاپگر محتوای داخل یک TextBox رو با CommonDialog چاپ کنید ؟

درست متوجه شدم ؟



باتشکر احسان

ali-software
پنج شنبه 26 شهریور 1388, 12:20 عصر
بله .چه طور می تونم این کار رو انجام بدم لطفا کمک کنید.ممنون

pcdownload.bloghaa.com
دوشنبه 30 شهریور 1388, 02:39 صبح
می تونی محتوای تکست باکس را در یک فرم خالی نوشته وسپس از فرم پرینت بگیری
me.aoutoredraw=true
me.print text1.text
و سپس با شی پرینتر
یا کامند دیالوگ پرینت بگیر.

ali-software
دوشنبه 30 شهریور 1388, 15:02 عصر
یعنی چه جوری.میشه یک مثال بزنید؟؟

pcdownload.bloghaa.com
دوشنبه 30 شهریور 1388, 15:33 عصر
کدشو تو وی بی دات نت بلدم که خودت می تونی تبدیل کنی:

Private WithEvents pd As Printing.PrintDocument
' storage for form image
Dim formImage As Bitmap
' create API prototype
Private Declare Function BitBlt Lib "gdi32.dll" Alias _
"BitBlt" (ByVal hdcDest As IntPtr, _
ByVal nXDest As Integer, ByVal nYDest As _
Integer, ByVal nWidth As Integer, _
ByVal nHeight As Integer, ByVal _
hdcSrc As IntPtr, ByVal nXSrc As Integer, _
ByVal nYSrc As Integer, _
ByVal dwRop As System.Int32) As Long


Private Sub pd_PrintPage(ByVal sender As Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
Handles pd.PrintPage
e.Graphics.DrawImage(formImage, 100, 100)
End Sub

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' create an instance of the PrintDocument component
pd = New Printing.PrintDocument
Me.StartPosition = FormStartPosition.CenterScreen
End Sub

Private Sub btnPrintForm_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) _
Handles btnPrintForm.Click
' initiate the printdocument component
GetFormImage()
pd.Print()
End Sub

Private Sub GetFormImage()
Dim g As Graphics = Me.CreateGraphics()
Dim s As Size = Me.Size
formImage = New Bitmap(s.Width, s.Height, g)
Dim mg As Graphics = Graphics.FromImage(formImage)
Dim dc1 As IntPtr = g.GetHdc
Dim dc2 As IntPtr = mg.GetHdc
' added code to compute and capture the form
' title bar and borders
Dim widthDiff As Integer = _
(Me.Width - Me.ClientRectangle.Width)
Dim heightDiff As Integer = _
(Me.Height - Me.ClientRectangle.Height)
Dim borderSize As Integer = widthDiff \ 2
Dim heightTitleBar As Integer = heightDiff - borderSize
BitBlt(dc2, 0, 0, _
Me.ClientRectangle.Width + widthDiff, _
Me.ClientRectangle.Height + heightDiff, dc1, _
0 - borderSize, 0 - heightTitleBar, 13369376)

g.ReleaseHdc(dc1)
mg.ReleaseHdc(dc2)
End Sub