大多数人在学习编程的过程中,往往都会通过不断的代码编写来积累经验达到一个运用熟练的地步。那么对于VB.NET语言的学习同样需要遵循这样一个规律。下面就让我们一起来看看VB.NET窗体打印的实现代码,从中增加我们的代码编写经验。
在聂拉木等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站设计、成都网站建设 网站设计制作按需策划设计,公司网站建设,企业网站建设,成都品牌网站建设,全网营销推广,成都外贸网站建设,聂拉木网站建设费用合理。
VB.NET窗体打印代码示例:
- Imports System
- Imports System.Drawing.Printing
- Public Class Form1
- < System.Runtime.InteropServices.
DllImport("gdi32.dll")>- _Public 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 Integer) As Boolean- End Function
- < System.Runtime.InteropServices.
DllImport("User32.dll")> _- Public Shared Function GetWindowDC
(ByVal hwd As IntPtr) As IntPtr- End Function
- < System.Runtime.InteropServices.
DllImport("User32.dll")> _- Public Shared Function ReleaseDC
(ByVal hwd As IntPtr, ByVal dc As
IntPtr) As Integer- End Function
- < System.Runtime.InteropServices.
DllImport("user32.dll")> _- Public Shared Function GetWindowRect
(ByVal hWnd As IntPtr, ByRef lpRect
As RECT) As Boolean- End Function
- < Serializable(), System.Runtime.
InteropServices.StructLayout(System.
Runtime.InteropServices.LayoutKind.
Sequential)> _- Public Structure RECT
- Public Left As Integer
- Public Top As Integer
- Public Right As Integer
- Public Bottom As Integer
- End Structure
- Private memoryImage As Bitmap
- Private Sub CaptureScreen()
- Dim mygraphics As Graphics = Me.
CreateGraphics()- Dim r As RECT
- GetWindowRect(Me.Handle, r)
- Dim s As RectangleRectangle =
Rectangle.FromLTRB(r.Left, r.Top,
r.Right, r.Bottom)- memoryImage = New Bitmap(s.Width,
s.Height, mygraphics)- Dim memoryGraphics As Graphics
Graphics = Graphics.FromImage(memoryImage)- Dim dc1 As IntPtr = GetWindowDC(Me.Handle)
- Dim dc2 As IntPtr = memoryGraphics.GetHdc()
- BitBlt(dc2, 0, 0, s.Width, s.Height,
dc1, 0, 0, 13369376)- ReleaseDC(Me.Handle, dc1)
- memoryGraphics.ReleaseHdc(dc2)
- End Sub
- Private Sub Document_PrintPage(ByVal
sender As System.Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs)- e.Graphics.DrawImage(memoryImage, 0, 0)
- End Sub
- Private Sub Button1_Click_1(ByVal sender
As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click- CaptureScreen()
- PrintDialog1.ShowDialog()
- Dim pd As PrintDocument = New
PrintDocument- pd.PrinterSettings = PrintDialog1.
PrinterSettings- AddHandler pd.PrintPage, AddressOf
Document_PrintPage- pd.Print()
- End Sub
怎么样,通过本文介绍的VB.NET窗体打印的实现方法,大家应该可以充分掌握这一应用技巧了。
新闻标题:VB.NET窗体打印代码解读
本文地址:http://www.shufengxianlan.com/qtweb/news5/42055.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联