Option Explicit
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 = &HCC0020Private Sub Picture1_Click()
'Picture1.AutoRedraw = True
Rem Picture1.Picture = Me.PrintForm
BitBlt Picture1.hDC, 0, 0, Me.ScaleWidth / Screen.TwipsPerPixelX, Me.ScaleHeight / Screen.TwipsPerPixelY, Me.hDC, 0, 0, SRCCOPY
End Sub另外,如果对你有帮助,请回复我的一个帖子:)
http://www.csdn.net/expert/topic/654/654811.xml?temp=.8152735
主题: 我自认VB水平不错,请大家给我估估价!
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 = &HCC0020Private Sub Picture1_Click()
'Picture1.AutoRedraw = True
Rem Picture1.Picture = Me.PrintForm
BitBlt Picture1.hDC, 0, 0, Me.ScaleWidth / Screen.TwipsPerPixelX, Me.ScaleHeight / Screen.TwipsPerPixelY, Me.hDC, 0, 0, SRCCOPY
End Sub另外,如果对你有帮助,请回复我的一个帖子:)
http://www.csdn.net/expert/topic/654/654811.xml?temp=.8152735
主题: 我自认VB水平不错,请大家给我估估价!
解决方案 »
- [调查]你向往发展的城市是哪个?
- 关于指数的问题
- 请教一下,为什么findwindw函数为什么找不到信使服务窗口?
- NETTERM 如何实现自动登录打开历程记录并指定到文件(SESSION LOGGING)
- 怎么取消Datagrid添加的新记录??谢谢!
- 请DimVar进来领分!
- 不能上网的原因?
- 我想问问各位高人:怎么样来解决记录集移动时顺序的问题。急急急
- 我用datagrid显示了一系列的数据,但我想点击某个cell时显示一个对话框,我该怎么办?急急急!谢谢!
- 问一个好简单的问题,帮帮忙
- 模拟聊天的算法,怎样实现
- 我用FtpFindFirstFile,为什么一用到这个api就会出现vb运行出错,程个程序都退出,请指点,急,马上给分
Rem Picture1.Picture = Me.PrintForm
Picture1.Visible = False
BitBlt Picture1.hDC, 0, 0, Me.ScaleWidth / Screen.TwipsPerPixelX, Me.ScaleHeight / Screen.TwipsPerPixelY, Me.hDC, 0, 0, SRCCOPY
Picture2.Picture = Picture1.Image
End Sub
Private Sub Picture1_Click()
Picture1.AutoRedraw = True
Rem Picture1.Picture = Me.PrintForm
Picture1.Visible = False
BitBlt Picture1.hDC, 0, 0, Me.ScaleWidth / Screen.TwipsPerPixelX, Me.ScaleHeight / Screen.TwipsPerPixelY, Me.hDC, 0, 0, SRCCOPY
Picture2.Picture = Picture1.Image
或者:
dim MyPicture as Picture
set MyPicture = Picture1.Image
End Sub
'本例使用 SavePicture 语句保存画在 Form 对象的 Picture 属性中的图形。
'要试用此例,可将以下代码粘贴到 Form 对象的声明部分,然后运行此例,单击 Form 对象。Private Sub Form_Click()
' 声明变量。
Dim CX, CY, Limit, Radius As Integer, Msg As String
ScaleMode = vbPixels ' 设置比例模型为像素。
AutoRedraw = True ' 打开 AutoRedraw。
Width = Height ' 改变宽度以便和高度匹配。
CX = ScaleWidth / 2 ' 设置 X 位置。
CY = ScaleHeight / 2 ' 设置 Y 位置。
Limit = CX ' 圆的尺寸限制。
For Radius = 0 To Limit ' 设置半径。
Circle (CX, CY), Radius, RGB(Rnd * 255, Rnd * 255, Rnd * 255)DoEvents ' 转移到其它操作。
Next Radius
Msg = "Choose OK to save the graphics from this form "
Msg = Msg & "to a bitmap file."
MsgBox Msg
SavePicture Image, "TEST.BMP" ' 将图片保存到文件。
End Sub
Private Sub Picture1_Click()
Picture1.AutoRedraw = True
Rem Picture1.Picture = Me.PrintForm
Picture1.Visible = False
Picture1.BorderStyle = 0
Picture1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
BitBlt Picture1.hDC, 0, 0, Me.ScaleWidth / Screen.TwipsPerPixelX, Me.ScaleHeight / Screen.TwipsPerPixelY, Me.hDC, 0, 0, SRCCOPY
Picture2.Picture = Picture1.Image
End Sub如果要测试,可以添加Form2(比Form1的尺寸大,以看出整个图片),以下是Form2的代码:
Private Sub Form_Click()
Me.BackColor = vbRed
Me.Picture = Form1.Picture1.Image
End Sub
Picture1.AutoRedraw = True
Rem Picture1.Picture = Me.PrintForm
Picture1.Visible = False
Picture1.BorderStyle = 0
Picture1.Move 0, 0, Me.Width, Me.Height
Dim ScreenDC As Long
ScreenDC = GetDC(0)
BitBlt Picture1.hDC, 0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, ScreenDC, Me.Left / Screen.TwipsPerPixelX, Me.Top / Screen.TwipsPerPixelY, SRCCOPY
Picture2.Picture = Picture1.Image
End Sub其中,应添加一个模块,模块中的代码如下:
Option ExplicitPublic 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
Public Const SRCCOPY = &HCC0020Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long解决了吧?
用SavePicture方法,可保存图片为图形文件.给分?
没有一点反应,夜蛾没有错误信息,,,,,为什么呢???
给分?
要加上refresh
picture1.Refresh
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 GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Const SRCCOPY = &HCC0020Private Sub Picture1_Click()
Picture1.AutoRedraw = True Dim DeskHdc&, Ret& ' Get Desktop DC
DeskHdc = GetDC(0)
Picture1.Width = Screen.Width
Picture1.Height = Screen.Height
BitBlt Picture1.hdc, 0, 0, Picture1.Width / Screen.TwipsPerPixelX, Picture1.Height / Screen.TwipsPerPixelY, DeskHdc, 0, 0, vbSrcCopy
Ret = ReleaseDC(0&, DeskHdc)
Picture1.Refresh
End Sub