再不搞定,我要死了,555555555555555555555555555555555555555555555555

fucool 2001-07-16 06:31:23
我用PICTUREBOX做打印输出时,发现PICTUREBOX里的控件(textbox)内容
无法在纸上输出。
我用的方法如下:


Private Sub Command2_Click()
'打印图片框
Call Printtopicture
Printer.PaintPicture Me.Picture1, 0, 0
End Sub



Private Sub Printtopicture()
'把控件(textbox)内容输出在图片框中,但是输出时到图片框的顶上,
'有什么办法
'输出到控件原位置,要用API吗,应如何做???
Dim objcon As Control

For Each objcon In Controls
If TypeOf objcon Is TextBox Then Picture1.Print objcon.Text
Next

End Sub
...全文
159 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
MakeZ 2001-07-18
  • 打赏
  • 举报
回复
打两次不就可以了吗?
Printer.PaintPicture Me.Picture1, 0, 0
Printer.CurrentX = ?
Printer.CurrentY = ?
Printer.Print Text1.Text
fucool 2001-07-16
  • 打赏
  • 举报
回复
不对,全部的窗体都打出来了,我要的只是PICTUREBOX里的东西,
另外,如果取得控件在窗口的位置。
我可以使用picture1.print的方法打印控件内容在原位置,这样
也是可行的。
请大家多指教。
xxlroad 2001-07-16
  • 打赏
  • 举报
回复
主  题:★★★简单问题送100分★★★:如何打印框架容器里的的全部内容,包括mschart图表,label,combox等?
作  者:deak
所属论坛:Visual Basic
问题点数:100
回复次数:6
发表时间:2001-6-23 11:24:00





回复贴子:
 回复人:jaguarcts(jaguarcts) (2001-6-23 12:20:00) 得0分
用窗口的PRING方法。
在窗口的按鈕:
form1.print
 回复人:deak() (2001-6-23 13:45:00) 得0分
to jaguarcts:用printform方法是打印窗体,我要求的是打印框架容器里的的全部内容
 回复人:deak() (2001-6-26 11:47:33) 得0分
who knows?
 回复人:playyuer(女㊣爱) (2001-6-26 12:09:04) 得100分
在 Frame 里放一个等大的 PictureBox,利用 ClipBoard 打印图像 (PaintPicture)
Option Explicit

Private Const HORZRES = 8 ' Horizontal width in pixels
Private Const VERTRES = 10 ' Vertical width in pixels
Private Const CF_BITMAP = 2
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source

Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function EmptyClipboard Lib "user32" () As Long
Private Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long

Private Sub Command1_Click()
Dim hScrDC As Long
hScrDC = GetDC(Picture1.hwnd)

Dim hMemDC As Long
hMemDC = CreateCompatibleDC(hScrDC)

Dim xScrn As Integer
Dim yScrn As Integer
Picture1.ScaleMode = vbPixels
xScrn = Picture1.ScaleWidth '+ 200
yScrn = Picture1.ScaleHeight '+ 200
Dim hBitmap As Long
hBitmap = CreateCompatibleBitmap(hScrDC, xScrn, yScrn)
Dim hOldmap As Long
hOldmap = SelectObject(hMemDC, hBitmap)
BitBlt hMemDC, 0, 0, xScrn, yScrn, hScrDC, 0, 0, SRCCOPY
hBitmap = SelectObject(hMemDC, hOldmap)
DeleteDC hScrDC
DeleteDC hMemDC
OpenClipboard hwnd
EmptyClipboard
SetClipboardData CF_BITMAP, hBitmap
CloseClipboard
Dim pictureX As Picture
Set pictureX = Clipboard.GetData()
Printer.Print " "
Printer.PaintPicture pictureX, 0, 0
Printer.EndDoc
End Sub
 回复人:deak() (2001-6-26 14:27:32) 得0分
test?
 回复人:deak() (2001-6-28 14:55:15) 得0分
add
xxlroad 2001-07-16
  • 打赏
  • 举报
回复

http://www.csdn.net/expert/topic/168/168999.shtm

武稀松 2001-07-16
  • 打赏
  • 举报
回复
picture上的文字不要用text控件
用picture1.print的方法
MonkeyLin 2001-07-16
  • 打赏
  • 举报
回复
up
fucool 2001-07-16
  • 打赏
  • 举报
回复
我要死了,呵呵呵!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!
1!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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