重赏!vb 保存picturebox中的内容为图片

vb 保存picturebox中的内容为图片,包括里面的控件,以及被遮挡部分,即picturebox的大小超出窗体大小,所以一部分是看不到的……我用两个picturebox加滚动条可以观察到,但是保存图像的时候截取不到!重赏!
好吧,上面的问题我想到另外的方法解决了
换个问题:
怎样设置打印的边距为0
Picture1.Picture = LoadPicture("D:\1.jpg")
Printer.ScaleLeft = 0
Printer.ScaleTop = 0
Printer.CurrentX = 0
Printer.CurrentY = 0
Printer.PaintPicture Picture1.Image, 0, 0, Picture1.Width, Picture1.Height
Printer.EndDoc
用上面的代码打印出来的边距并不为0,顶和左还有5mm的距离,修改Scale参数也无法改变,甚至会把图片裁剪掉!
求:怎样让打印从纸张的边缘开始打印!
就是设置物理边距,我可以将图片放到word里面,设置边距基本为0

你的要求太高了,被遮挡的部分没有办法保存,其它条件可实现,模块代码:

' General functions:
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

' GDI functions:
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 Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
' Creates a memory DC
Declare Function CreateCompatibleDC Lib "gdi32" _
(ByVal hDC As Long) As Long
' Creates a bitmap in memory:
Declare Function CreateCompatibleBitmap Lib "gdi32" _
(ByVal hDC As Long, _
ByVal nWidth As Long, ByVal nHeight As Long) As Long
' Places a GDI Object into DC, returning the previous one:
Declare Function SelectObject Lib "gdi32" _
(ByVal hDC As Long, ByVal hObject As Long) As Long
' Deletes a GDI Object:
Declare Function DeleteObject Lib "gdi32" _
(ByVal hObject As Long) As Long

' Clipboard functions:
Private Declare Function OpenClipboard Lib "USER32" _
(ByVal hWnd As Long) As Long
Private Declare Function CloseClipboard Lib "USER32" () As Long
Private Declare Function SetClipboardData Lib "USER32" _
(ByVal wFormat As Long, ByVal hMem As Long) As Long
Private Declare Function EmptyClipboard Lib "USER32" () As Long
Private Const CF_BITMAP = 2

Public Function CopyEntirePicture(ByRef objFrom As Object) As Boolean
Dim lhDC As Long
Dim lhBMP As Long
Dim lhBMPOld As Long
Dim lWidthPixels As Long
Dim lHeightPixels As Long

' Create a DC compatible with the object we're copying
' from:
lhDC = CreateCompatibleDC(objFrom.hDC)
If (lhDC <> 0) Then
' Create a bitmap compatible with the object we're
' copying from:
lWidthPixels = objFrom.ScaleX( _
objFrom.ScaleWidth, _
objFrom.ScaleMode, _
vbPixels)
lHeightPixels = objFrom.ScaleY( _
objFrom.ScaleHeight, _
objFrom.ScaleMode, _
vbPixels)
lhBMP = CreateCompatibleBitmap(objFrom.hDC, _
lWidthPixels, lHeightPixels)
If (lhBMP <> 0) Then
' Select the bitmap into the DC we have created,
' and store the old bitmap that was there:
lhBMPOld = SelectObject(lhDC, lhBMP)

' Copy the contents of objFrom to the bitmap:
BitBlt lhDC, 0, 0, lWidthPixels, lHeightPixels, _
objFrom.hDC, 0, 0, SRCCOPY

' Remove the bitmap from the DC:
SelectObject lhDC, lhBMPOld

' Now set the clipboard to the bitmap:
OpenClipboard 0
EmptyClipboard
SetClipboardData CF_BITMAP, lhBMP
CloseClipboard

' We don't delete the Bitmap here - it is now owned
' by the clipboard and Windows will delete it for us
' when the clipboard changes or the program exits.
End If

' Clear up the device context we created:
DeleteObject lhDC
End If
End Function

Form1窗体代码:

Private Sub Command1_Click()
CopyEntirePicture Picture1
SavePicture Clipboard.GetData(vbCFBitmap), "c:\1.bmp"
End Sub追问

这些我都会~·主要是被遮挡部分无法截取到,要不然我也不会200分提问!

追答

这要求超出了VB的能力,做不到的

温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-05-20
把图片显示方式调成 缩放试试

或者 载入前先读取图片的宽高 然后把窗口 和控件的 大小自动调节 可以试试
第2个回答  2012-05-18
“picturebox的大小超出窗体大小,所以一部分是看不到的……”电话装修公司把窗口凿宽点~或者你走到外面看进来不就看到了?追问

牛头不对马嘴

追答

你是牛我是马还是我是马你是牛

第3个回答  2012-05-18
Picture1.AutoRedraw = False
Set Picture1.Picture = Picture1.Image
SavePicture Picture1.Picture, App.Path & "\123.bmp"
这样试试追问

这个方法是不可能把窗体上的控件保存的,你都没试过~

追答

我贴的肯定是试过的
留下QQ可以传源代码

第4个回答  2012-05-20
把分辨率调高一点追问

…………我的分辨率够高了,别人的电脑都是1024的……

追答

采纳呗,都过去六年多了