vb.net如何打印form,.net好象没有了printform(谢谢各位高人!!!)

liujiweijun 2006-03-16 03:17:39
vb.net如何打印form,.net好象没有了printform(谢谢各位高人!!!)
...全文
570 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
alan001 2006-04-24
  • 打赏
  • 举报
回复
Up
sz_lgp 2006-04-24
  • 打赏
  • 举报
回复
up
liujiweijun 2006-03-20
  • 打赏
  • 举报
回复
谢谢大家!!!!!!!!!!!
cegcegceg 2006-03-20
  • 打赏
  • 举报
回复
private pndPrintDoc As new System.Drawing.Printing.PrintDocument

private Sub CaptureScreen()

Dim mygraphics As Graphics = Me.CreateGraphics()
Dim s As Size = Me.Size
memoryImage = New Bitmap(s.Width, s.Height, mygraphics)
Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
Dim dc1 As IntPtr = mygraphics.GetHdc
Dim dc2 As IntPtr = memoryGraphics.GetHdc
BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, Me.ClientRectangle.Height, dc1, 0, 0, 13369376)
mygraphics.ReleaseHdc(dc1)
memoryGraphics.ReleaseHdc(dc2)

End Sub


Private Sub PrintDocumentPrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pndPrintDoc.PrintPage

e.Graphics.DrawImage(memoryImage, 0, 0)

End Sub


sub PrintForm()

Try
CaptureScreen()
ptdPrint.Document = pndPrintDoc
If ptdPrint.ShowDialog() = DialogResult.OK Then
pndPrintDoc.Print()
End If
Catch ex As Exception
End Try
End Sub
yrh2008sql 2006-03-17
  • 打赏
  • 举报
回复
截屏
liujiweijun 2006-03-17
  • 打赏
  • 举报
回复
SendKeys.SendWait("%{PRTSC}")
什么意思!谢谢!!
夜雨悠扬 2006-03-17
  • 打赏
  • 举报
回复
SendKeys.SendWait("%{PRTSC}")
这句的意思是模拟一个按键动作,按下的键是Print键
笑傲IT 2006-03-17
  • 打赏
  • 举报
回复
www.fcsoft.com.cn
或加msn:daiqunbiao@hotmail.com
sx_lxh 2006-03-16
  • 打赏
  • 举报
回复
net实现把窗体的界面打印出来

Imports System.Drawing.Printing

' Specifies what happens when the PrintPage event is raised.
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
Dim obj As Bitmap
Dim iData As IDataObject = Clipboard.GetDataObject()
' Determines whether the data is in a format you can use.
If iData.GetDataPresent(DataFormats.Bitmap) Then
obj = iData.GetData(DataFormats.Bitmap)
ev.Graphics.DrawImage(obj, _
obj.GetBounds(System.Drawing.GraphicsUnit.Pixel)) 'ev.Graphics.VisibleClipBounds)
End If
ev.HasMorePages = False
End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
'Printscreen
SendKeys.SendWait("%{PRTSC}")
' Assumes the default printer.
Dim pd As New PrintDocument()
AddHandler pd.PrintPage, AddressOf Me.pd_PrintPage
pd.DefaultPageSettings.Landscape = True
pd.Print()
Catch ex As Exception
MessageBox.Show("An error occurred while printing" & vbCrLf & _
ex.ToString(), "Error")
End Try
End Sub
End Class

夜雨悠扬 2006-03-16
  • 打赏
  • 举报
回复
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
Dim memoryImage As Bitmap
Private Sub CaptureScreen()
Dim mygraphics As Graphics = Me.CreateGraphics()
Dim s As Size = Me.Size
memoryImage = New Bitmap(s.Width, s.Height, mygraphics)
Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
Dim dc1 As IntPtr = mygraphics.GetHdc
Dim dc2 As IntPtr = memoryGraphics.GetHdc
BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, _
Me.ClientRectangle.Height, dc1, 0, 0, 13369376)
mygraphics.ReleaseHdc(dc1)
memoryGraphics.ReleaseHdc(dc2)
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles _
PrintDocument1.PrintPage
e.Graphics.DrawImage(memoryImage, 0, 0)
End Sub
Private Sub PrintButton_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles PrintButton.Click
CaptureScreen()
PrintDocument1.Print()
End Sub
qhiou 2006-03-16
  • 打赏
  • 举报
回复
MSDN里就有,自己搜一下”打印窗体“就能找到

16,721

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧