Results 1 to 6 of 6

Thread: Help with API (Clipboard)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2001
    Location
    Somewhere in Time
    Posts
    23

    Help with API (Clipboard)

    I dont know much about VB or even know how to use API... but a friend gave a code for copying items to the windows clipboard... i tryed to integrate it to my program.. but i dont know how to debug... as far as i know there is one problem only...

    The program i am doing is a simple winseek with someother functions...

    In the program the problem is on the "COPY COmmand" cmdCOpy
    If there is anyone who can help me... this is the last part of my debugging...
    Artist get ofended by bad Art, I get ofended by bad programming...

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Aug 2001
    Location
    Somewhere in Time
    Posts
    23
    This was the original code given to me....

    ----------------------------------------------------

    Private Declare Function EmptyClipboard _
    Lib "user32" () As Long
    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 GlobalAlloc _
    Lib "kernel32" ( _
    ByVal wFlags As Long, _
    ByVal dwBytes As Long) As Long
    Private Declare Function GlobalLock _
    Lib "kernel32" ( _
    ByVal hMem As Long) As Long
    Private Declare Function GlobalUnlock _
    Lib "kernel32" ( _
    ByVal hMem As Long) As Long

    Private Declare Sub CopyMemory _
    Lib "kernel32" Alias "RtlMoveMemory" ( _
    Destination As Any, _
    Source As Any, _
    ByVal Length As Long)

    Private Const GMEM_MOVEABLE = &H2
    Private Const GMEM_ZEROINIT = &H40
    Private Const GHND = (GMEM_MOVEABLE Or GMEM_ZEROINIT)

    Public Function CopyFile(FileName As String) As Boolean
    Dim data As String
    Dim df As DROPFILES
    Dim hGlobal As Long
    Dim lpGlobal As Long
    Dim i As Long

    ' Open and clear existing crud off clipboard.
    If OpenClipboard(0&) Then
    Call EmptyClipboard

    ' Build double-null terminated list of files.
    data = FileName & vbNullChar & vbNullChar

    ' Allocate and get pointer to global memory,
    ' then copy file list to it.
    hGlobal = GlobalAlloc(GHND, Len(df) + Len(data))
    If hGlobal Then
    lpGlobal = GlobalLock(hGlobal)

    ' Build DROPFILES structure in global memory.
    df.pFiles = Len(df)
    Call CopyMemory(ByVal lpGlobal, df, Len(df))
    Call CopyMemory(ByVal (lpGlobal + Len(df)), ByVal data, Len(data))
    Call GlobalUnlock(hGlobal)

    ' Copy data to clipboard, and return success.
    If SetClipboardData(CF_HDROP, hGlobal) Then
    CopyFile = True
    End If
    End If

    ' Clean up
    Call CloseClipboard
    End If
    End Function
    Artist get ofended by bad Art, I get ofended by bad programming...

  3. #3
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    what's the matter with clipboard.settext?

    and clipboard.gettext?

    doesn't have enough options?

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Aug 2001
    Location
    Somewhere in Time
    Posts
    23
    The clipboard seltext and other options only alows me to copy... text or images.. i need somethign to be able to copy any format or size of file....
    Artist get ofended by bad Art, I get ofended by bad programming...

  5. #5
    DaoK
    Guest
    You can use setData for picture...

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Originally posted by Longshot
    In the program the problem is on the "COPY COmmand" cmdCOpy
    If there is anyone who can help me... this is the last part of my debugging...
    What, specifically is the problem? What is happening?

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