如何打印窗体form的内容? 各位: 我编写了一个小程序,只有一个form,上面布置了若干 textbox 等控件,请问不用其他打印控件,如何做到打印全部或部分数据? 我以前在哪儿见过类次代码,现忘了,请各位指教!谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.wave12.com/web/SigCon.asp?bCate=50&sCateName=%B9%A6%C4%DC%BD%E9%C9%DC&ID=173&CateName=wsReport4.5 谢谢 wxrwan(不耻上问)能否详细解释一下方法,我以前试过,没弄出来 PrintForm方法谢谢 on error goto exitsubme.printfromexitsub:exit sub 你试试这个 me.printfrom回打印全部啊,能否只打印窗体的部分区域啊?有没有这个功能! 放两个 PictureBox (不要嵌套)在窗体上。其中 Picture1 中放你要打印的各个控件。Picture2 放在它后面。Private Const twipFactor = 1440Private Const WM_PAINT = &HFPrivate Const WM_PRINT = &H317Private Const PRF_CLIENT = &H4& ' Draw the window's client area.Private Const PRF_CHILDREN = &H10& ' Draw all visible child windows.Private Const PRF_OWNED = &H20& ' Draw all owned windows.Private Declare Function SendMessage Lib "user32" Alias _ "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, ByVal lParam As Long) As LongPrivate Sub Form_Load() Dim sWide As Single, sTall As Single Dim rv As Long Me.ScaleMode = vbTwips ' default sWide = 8.5 stall = 11 ' or 14, etc. Me.Width = twipFactor * sWide Me.Height = twipFactor * stall With Picture1 .Top = 0 .Left = 0 .Width = twipFactor * sWide .Height = twipFactor * stall End With With Picture2 .Top = 0 .Left = 0 .Width = twipFactor * sWide .Height = twipFactor * stall End With Me.Visible = TrueEnd SubPrivate cmdPrint_Click() Picture1.SetFocus Picture2.AutoRedraw = True rv = SendMessage(Picture1.hwnd, WM_PAINT, Picture2.hDC, 0) rv = SendMessage(Picture1.hwnd, WM_PRINT, Picture2.hDC, _ PRF_CHILDREN + PRF_CLIENT + PRF_OWNED) Picture2.Picture = Picture2.Image Picture2.AutoRedraw = False Printer.Print "" Printer.PaintPicture Picture2.Picture, 0, 0 Printer.EndDocEnd Sub 恩,办法都不错。。不过如果是我,我不会那么多操作啦,因为我懒麻!把需要打印的部分,都放在一个PICTUREBOX里面。然后打印PICTUERBOX就可以了。 picturebox怎么打印啊?没有提供打印方法 啊? 请问各位,如何获得一个标题带文字+"+时间日期的窗体句柄 请教高手关于winsock控件问题 为何这样得不到BMP图像的某个字节值呢? 基本问题,谢谢 网页源码 怎都是 &#加一串数字比如:乳 关于运行时添加控件,事件处理的解决办法 帮忙找一下压缩的控件!~(最好不要注册的,或有注册机的) 大虾们--快进来 大家帮一下忙:用Access数据库,如何在一个表中动态追加字段? VB6程序运行时的问题(详见内) 读取文档数据的问题 如何实现QQ的自动聊天功能
能否详细解释一下方法,我以前试过,没弄出来
PrintForm方法谢谢
me.printfrom
exitsub:
exit sub
你试试这个
me.printfrom回打印全部啊,能否只打印窗体的部分区域啊?有没有这个功能!
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 windows.
Private Const PRF_OWNED = &H20& ' Draw all owned windows.Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As LongPrivate Sub Form_Load()
Dim sWide As Single, sTall As Single
Dim rv As Long Me.ScaleMode = vbTwips ' default
sWide = 8.5
stall = 11 ' or 14, etc.
Me.Width = twipFactor * sWide
Me.Height = twipFactor * stall
With Picture1
.Top = 0
.Left = 0
.Width = twipFactor * sWide
.Height = twipFactor * stall
End With
With Picture2
.Top = 0
.Left = 0
.Width = twipFactor * sWide
.Height = twipFactor * stall
End With Me.Visible = True
End SubPrivate cmdPrint_Click()
Picture1.SetFocus
Picture2.AutoRedraw = True
rv = SendMessage(Picture1.hwnd, WM_PAINT, Picture2.hDC, 0)
rv = SendMessage(Picture1.hwnd, WM_PRINT, Picture2.hDC, _
PRF_CHILDREN + PRF_CLIENT + PRF_OWNED)
Picture2.Picture = Picture2.Image
Picture2.AutoRedraw = False Printer.Print ""
Printer.PaintPicture Picture2.Picture, 0, 0
Printer.EndDoc
End Sub
不过如果是我,我不会那么多操作啦,因为我懒麻!
把需要打印的部分,都放在一个PICTUREBOX里面。然后打印PICTUERBOX就可以了。