Option Explicit
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () 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 LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
Const CF_BITMAP = 2
Const LR_LOADMAP3DCOLORS = &H1000
Const LR_LOADFROMFILE = &H10
Const LR_LOADTRANSPARENT = &H20
Const IMAGE_BITMAP = 0
Private Declare Function CopyImage Lib "user32" (ByVal handle As Long, _
ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
Private Sub cmdDemo_Click()
Dim FileName As String
Dim BitMapLong As Long
Dim TempLong As Long
Dim CopyMapLong As Long
Dim TempLong1 As Long
If txtName.Text = "" Then
MsgBox "이미지를 선택하세요.", vbInformation
Exit Sub
End If
If Right(File1.Path, 1) = "\" Then
FileName = File1.Path & File1.FileName
Else
FileName = File1.Path & "\" & File1.FileName
End If
'클립보드를 연다.
TempLong = OpenClipboard(0)
'클리보드 초기화
TempLong = EmptyClipboard()
'리소스로부터 비트맵 이비지를 로드한다.
BitMapLong = LoadImage(0, FileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE Or LR_LOADMAP3DCOLORS Or LR_LOADTRANSPARENT)
'클리보드된 데이타의 전송시작
TempLong = SetClipboardData(CF_BITMAP, BitMapLong)
'클립보드를 닫는다.
TempLong = CloseClipboard()
' 클립보드로부터 복사됩니다.(clipboard 상수==>비트맵 (.bmp 파일))
Set Picture1.Picture = Clipboard.GetData(vbCFBitmap)
'/새로운 이미지로 복사한다.
CopyMapLong = CopyImage(BitMapLong, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
'클리보드된 데이타의 전송시작
TempLong1 = SetClipboardData(CF_BITMAP, CopyMapLong)
'클립보드를 닫는다.
TempLong1 = CloseClipboard()
' 클립보드로부터 복사됩니다.(clipboard 상수==>비트맵 (.bmp 파일))
Set Picture2.Picture = Clipboard.GetData(vbCFBitmap)
End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
txtName = File1.FileName
End Sub
Private Sub Form_Load()
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
End Sub
CopyImage.zip