|
-
Oct 17th, 2001, 10:51 AM
#1
Thread Starter
New Member
Send file to (Explorer's) Clipboard
Hi,
Does anyone know how to place a file onto Clipboard so that you can then go into Explorer and paste it?
- Andy.
-
Oct 17th, 2001, 11:01 AM
#2
Frenzied Member
Look at MSDN and do a search for clipboard. Here is some code that i found to past an image. Maybe you can come up with something from this.
VB Code:
Private Sub Form_Click ()
Const CF_BITMAP = 2 ' Define bitmap format.
Dim Msg ' Declare variable.
On Error Resume Next ' Set up error handling.
Msg = "Choose OK to load a bitmap onto the Clipboard."
MsgBox Msg ' Display message.
Clipboard.Clear ' Clear Clipboard.
Clipboard.SetData LoadPicture("PAPER.BMP") ' Get bitmap.
If Err Then
Msg = "Can't find the .bmp file."
MsgBox Msg ' Display error message.
Exit Sub
End If
Msg = "A bitmap is now on the Clipboard. Choose OK to copy "
Msg = Msg & "the bitmap from the Clipboard to the form "
MsgBox Msg ' Display message.
Picture = Clipboard.GetData() ' Copy from Clipboard.
Msg = "Choose OK to clear the form."
MsgBox Msg ' Display message.
Picture = LoadPicture() ' Clear form.
End Sub
-
Oct 17th, 2001, 11:02 AM
#3
Frenzied Member
Here is an API Example.
VB Code:
Const LR_LOADFROMFILE = &H10
Const IMAGE_BITMAP = 0
Const IMAGE_ICON = 1
Const IMAGE_CURSOR = 2
Const IMAGE_ENHMETAFILE = 3
Const CF_BITMAP = 2
Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal dwImageType As Long, ByVal dwDesiredWidth As Long, ByVal dwDesiredHeight As Long, ByVal dwFlags As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) 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 IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Long) As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: [url]http://www.allapi.net/[/url]
Dim hDC As Long, hBitmap As Long
'Load the bitmap into the memory
hBitmap = LoadImage(App.hInstance, "c:\windows\logow.sys", IMAGE_BITMAP, 320, 200, LR_LOADFROMFILE)
If hBitmap = 0 Then
MsgBox "There was an error while loading the bitmap"
Exit Sub
End If
'open the clipboard
OpenClipboard Me.hwnd
'Clear the clipboard
EmptyClipboard
'Put our bitmap onto the clipboard
SetClipboardData CF_BITMAP, hBitmap
'Check if there's a bitmap on the clipboard
If IsClipboardFormatAvailable(CF_BITMAP) = 0 Then
MsgBox "There was an error while pasting the bitmap to the clipboard!"
End If
'Close the clipboard
CloseClipboard
'Get the picture from the clipboard
Me.Picture = Clipboard.GetData(vbCFBitmap)
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|