VB itself does not allow you a Form, UserControl or a PictureBox on a complete picture to the clipboard. If you use Clipboard.SetData, will only copy the bitmap object loaded. By using the API method, you can go beyond this limit, to ensure all contents are copied, including any you just draw a graph.
Start a new project, in the form put a Command and a PictureBox. The PictureBox's Autoredraw property is set to 1. Then add a standard module, copy the following code into the.
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
'GDI function:
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
'Create a memory DC:
Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As Long) As Long
'In memory to create a bitmap:
Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
'To a GDI object into the DC, back to the original that:
Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
'Delete the 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
'In memory to establish a point we will want to copy the object DC:
lhDC = CreateCompatibleDC (objFrom.hDC)
If (lhDC <> 0) Then
'Create a point will want to copy a bitmap object:
lhBMP = CreateCompatibleBitmap (objFrom.hDC, objFrom.ScaleWidth Screen.TwipsPerPixelX, objFrom.ScaleHeight Screen.TwipsPerPixelY)
If (lhBMP <> 0) Then
'The bitmap selected into the DC we have just set up in and where the old store the original bitmap:
lhBMPOld = SelectObject (lhDC, lhBMP)
'Copy the contents of the objFrom to build a bitmap in:
BitBlt lhDC, 0, 0, objFrom.ScaleWidth Screen.TwipsPerPixelX, objFrom.ScaleHeight Screen.TwipsPerPixelY, objFrom.hDC, 0, 0, SRCCOPY
'Restoration of DC content:
SelectObject lhDC, lhBMPOld
'Now the bitmap into the clipboard:
EmptyClipboard
OpenClipboard 0
SetClipboardData CF_BITMAP, lhBMP
CloseClipboard
'We are here not to delete the establishment of the bitmap -
'It now belongs to the clipboard, when the clipboard changes, Windows will we remove it.
End If
'Clear just created DC:
DeleteObject lhDC
End If
End Function
To test this method, these code to the form:
Private Sub Command1_Click ()
CopyEntirePicture Picture1
End Sub
Private Sub Form_Load ()
Dim i As Long
'Painted in the PictureBox something:
With Picture1.Font
. Name = "Arial"
. Bold = True
. Size = 12
End With
For i = 1 To 20
Picture1.ForeColor = QBColor (i Mod 15)
銆??Picture1.Print "http://www.archtide.com"
Next i
End Sub
銆??绐椾綋鍔犺浇鍚庯紝PictureBox涓皢浼氭湁涓?簺鏂囨湰銆傚綋浣犵偣鍑籆ommand鍚庯紝PictureBox涓殑鍏ㄩ儴鍐呭閮藉皢浼氳澶嶅埗鍒板壀璐存澘閲岋紝浣犲彲浠ユ妸瀹冪矘璐村埌鍒殑绋嬪簭閲岋紝姣斿鐢荤瑪銆乄ord绛夌瓑銆?br />
相关链接:
Revitalization of Road Reflection RFID
Mts to mpg
Quote turnover Trilogy
Flash simulation of the old movie playback
mkv
What is a switch
Shop Seasonal - SCREEN Savers
Index Proposed Simplified DB2 For I5/OS
Failure from SHUTDOWN trouble
vob to Mkv
S1500 Entry-level disk array read is cost-effective
Masanobu CAT
.vob
Religion evaluation
Do Not Ping My Computer
Evaluate Cartoons - Screen Savers
No comments:
Post a Comment