Results 1 to 3 of 3

Thread: Send file to (Explorer's) Clipboard

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Location
    UK
    Posts
    2

    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.

  2. #2
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    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:
    1. Private Sub Form_Click ()
    2.    Const CF_BITMAP = 2   ' Define bitmap format.
    3.    Dim Msg   ' Declare variable.
    4.    On Error Resume Next   ' Set up error handling.
    5.    Msg = "Choose OK to load a bitmap onto the Clipboard."
    6.    MsgBox Msg   ' Display message.
    7.    Clipboard.Clear   ' Clear Clipboard.
    8.    Clipboard.SetData LoadPicture("PAPER.BMP")  ' Get bitmap.
    9.    If Err Then
    10.       Msg = "Can't find the .bmp file."
    11.       MsgBox Msg   ' Display error message.
    12.       Exit Sub
    13.    End If
    14.    Msg = "A bitmap is now on the Clipboard. Choose OK to copy "
    15.    Msg = Msg & "the bitmap from the Clipboard to the form "
    16.    MsgBox Msg   ' Display message.
    17.    Picture = Clipboard.GetData()   ' Copy from Clipboard.
    18.    Msg = "Choose OK to clear the form."
    19.    MsgBox Msg   ' Display message.
    20.    Picture = LoadPicture()   ' Clear form.
    21. End Sub

  3. #3
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    Here is an API Example.

    VB Code:
    1. Const LR_LOADFROMFILE = &H10
    2. Const IMAGE_BITMAP = 0
    3. Const IMAGE_ICON = 1
    4. Const IMAGE_CURSOR = 2
    5. Const IMAGE_ENHMETAFILE = 3
    6. Const CF_BITMAP = 2
    7. 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
    8. Private Declare Function CloseClipboard Lib "user32" () As Long
    9. Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
    10. Private Declare Function EmptyClipboard Lib "user32" () As Long
    11. Private Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
    12. Private Declare Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Long) As Long
    13. Private Sub Form_Load()
    14.     'KPD-Team 1999
    15.     'URL: [url]http://www.allapi.net/[/url]
    16.     'E-Mail: [email][email protected][/email]
    17.     Dim hDC As Long, hBitmap As Long
    18.     'Load the bitmap into the memory
    19.     hBitmap = LoadImage(App.hInstance, "c:\windows\logow.sys", IMAGE_BITMAP, 320, 200, LR_LOADFROMFILE)
    20.     If hBitmap = 0 Then
    21.         MsgBox "There was an error while loading the bitmap"
    22.         Exit Sub
    23.     End If
    24.     'open the clipboard
    25.     OpenClipboard Me.hwnd
    26.     'Clear the clipboard
    27.     EmptyClipboard
    28.     'Put our bitmap onto the clipboard
    29.     SetClipboardData CF_BITMAP, hBitmap
    30.     'Check if there's a bitmap on the clipboard
    31.     If IsClipboardFormatAvailable(CF_BITMAP) = 0 Then
    32.         MsgBox "There was an error while pasting the bitmap to the clipboard!"
    33.     End If
    34.     'Close the clipboard
    35.     CloseClipboard
    36.     'Get the picture from the clipboard
    37.     Me.Picture = Clipboard.GetData(vbCFBitmap)
    38. 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
  •  



Click Here to Expand Forum to Full Width