控件command1,command2,picture1,把command1画在picture1中,然后打印Public Declare Function StretchBlt Lib "gdi32" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As LongPublic Const SRCCOPY = &HCC0020 ' (DWORD) dest = sourcePublic Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As LongPrivate Sub Command2_Click() Dim lReturn As Long Dim llhwnd As Long Picture1.Width = Command1.Width Picture1.Height = Command1.Height llhwnd = GetDC(Form1.hwnd) lReturn = StretchBlt(Picture1.hdc, _ 0, 0, _ Picture1.Width / Screen.TwipsPerPixelX, _ Picture1.Height / Screen.TwipsPerPixelY, _ llhwnd, _ Command1.Left / Screen.TwipsPerPixelX, Command1.Top / Screen.TwipsPerPixelY, _ Command1.Width / Screen.TwipsPerPixelX, _ Command1.Height / Screen.TwipsPerPixelY, _ SRCCOPY) Picture1.Refresh End Sub
我是说只打印一个控件.
比如说是一个barcode(条型码)控件.
up
UP
UPUP
UPUPUP
打印一个控件或者打印窗体的(X1,Y1)----(X2,Y2)
printer.PaintPicture form1.image,0,0,,,1000,1000,1000,1000此方法打印窗体的IMAGE
但是,我要打印的是窗体上的控件.
(VB中打印一个控件好像需要此控件有支持打印的功能)不知道我有没有记错.
请高手指点.....
Dim lReturn As Long
Dim llhwnd As Long
Picture1.Width = Command1.Width
Picture1.Height = Command1.Height
llhwnd = GetDC(Form1.hwnd)
lReturn = StretchBlt(Picture1.hdc, _
0, 0, _
Picture1.Width / Screen.TwipsPerPixelX, _
Picture1.Height / Screen.TwipsPerPixelY, _
llhwnd, _
Command1.Left / Screen.TwipsPerPixelX, Command1.Top / Screen.TwipsPerPixelY, _
Command1.Width / Screen.TwipsPerPixelX, _
Command1.Height / Screen.TwipsPerPixelY, _
SRCCOPY)
Picture1.Refresh
End Sub
打印方法
Printer.PaintPicture Picture1.Image, 0, 0
不行,打不出(打出来是Picture1的表面,而没有打出上面的控件Command1)
错....
把Command1画在 picture1上
还有,Picture1 的AutoRedraw设为True了吗?
画在Picture1上的图能不能打出来?
能打出来就没错
Command1在Form1上
Picture1在Form1上
我知道....
Picture控件中有图形
Picture1.Refresh 后 '------------------Picture控件中没有任何图形
把上一句注释掉后Picture有图形.
Printer.PaintPicture Picture1.Image, 0, 0 打印出的是Picture控件的背景.而不是控件的图形.
另
http://expert.csdn.net/Expert/topic/1292/1292883.xml?temp=.8203546
两贴的分一起结.........等你来拿....
http://www.aspbit.com/qprinter160.zip