|
-
Dec 14th, 2001, 10:17 PM
#1
Thread Starter
Junior Member
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... 
-
Dec 14th, 2001, 11:33 PM
#2
Thread Starter
Junior Member
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... 
-
Dec 15th, 2001, 11:15 AM
#3
Conquistador
what's the matter with clipboard.settext?
and clipboard.gettext?
doesn't have enough options?
-
Dec 15th, 2001, 01:24 PM
#4
Thread Starter
Junior Member
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... 
-
Dec 15th, 2001, 08:44 PM
#5
You can use setData for picture...
-
Dec 17th, 2001, 10:39 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|