
نوشته شده توسط
majid_vb_2008
ممنون از همه دوستان مشكل با اين Dll حل شد براتون مي زارم اگه خواستيد بگين براتون توضيح بدم
می دونم خیلی وقت از تاپیک گذشته اما بسیار نیازمند این دل ل هستم! ولی هیچ راهنمایی براش نیست
نمی تونم چرا اون زمان کسی توضیح نخواسته
اگر ممکنه یک راهنمایی کوچک یا بزرگ بکنید
من خودم یک نمونه دارم یعنی با کمی تغییرات کارم ر و راه انداخت
اما تبدیل به bitmap می کنه کیفیتش وحشتناک میاد پایین
نمی دونم راهی هست کیفیتش رو اصلاح کنیم؟
یا همینه!
اصلا خونده نمی شه متناش!
حالا اگر فرصت شد اونم اتچ می کنم
به درد دوستان بخوره
اما فعلا دنبال یک چیز بهترم اون
کدش این بود:
Imports System.Runtime.InteropServices
Imports System.Drawing.Printing
Public Class Form7
' Global Variables
Dim myBitmap As Bitmap
Dim WithEvents pd As PrintDocument
'Returns the Form as a bitmap
Function ngCaptureForm() As Bitmap
Dim g1 As Graphics = Me.CreateGraphics()
Dim MyImage = New Bitmap(Me.ClientRectangle.Width, (Me.ClientRectangle.Height), g1)
Dim g2 As Graphics = Graphics.FromImage(MyImage)
Dim dc1 As IntPtr = g1.GetHdc()
Dim dc2 As IntPtr = g2.GetHdc()
BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, (Me.ClientRectangle.Height), dc1, 0, 0, 13369376)
g1.ReleaseHdc(dc1)
g2.ReleaseHdc(dc2)
'saves image to c drive just, u can comment it also
MyImage.Save(Application.StartupPath & "\abc.bmp")
Return MyImage
End Function
<DllImport("gdi32.DLL", EntryPoint:="BitBlt", _
SetLastError:=True, CharSet:=CharSet.Unicode, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Private Shared Function 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 Boolean
' Leave function empty - DLLImport attribute forwards calls to MoveFile to
' MoveFileW in KERNEL32.DLL.
End Function
Private Sub ngPrintForm()
Try
Dim printDialog1 As PrintDialog = New PrintDialog
Dim result As DialogResult = printDialog1.ShowDialog
If (result = DialogResult.OK) Then
myBitmap = ngCaptureForm()
pd = New PrintDocument
pd.Print()
End If
Catch ex As Exception
End Try
End Sub
'this method will be called each time when pd.printpage event occurs
Sub pd_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles pd.PrintPage
Try
Dim x As Integer = e.MarginBounds.X
Dim y As Integer = e.MarginBounds.Y
e.Graphics.DrawImage(myBitmap, x, y)
e.HasMorePages = False
Catch ex As Exception
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call ngPrintForm()
End Sub
End Class
این الان مثله مرد کار می کنه فقط یک ذره تغییر لازم داره برای تعیین محل اونی که می خواین چاپش کنید
اما
خیلی کفیتیش پایینه
اصلا ضایعس
و ضمن اینکه اون طریق لود کردن دل ال الش رو نمی دونم درسته
یعنی بعدا مشکل ایجاد نمی کنه