Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Com and Clipboard
Message
 
 
À
10/01/2004 04:45:07
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00865717
Message ID:
00865870
Vues:
23
>I cant send any data from my Com object to the clipboard.
>DataToClip and _cliptext dosent work.

This should work in COM DLL.
FUNCTION text2clipboard(tcText)
lcText = tcText + CHR(0)
#DEFINE CF_TEXT 1

*  Global Memory Variables with Compile Time Constants
#DEFINE GMEM_MOVABLE 	0x0002
#DEFINE GMEM_ZEROINIT	0x0040
#DEFINE GMEM_SHARE		0x2000
*!*  Clipboard Functions
DECLARE LONG OpenClipboard IN user32 LONG HWND
DECLARE LONG CloseClipboard IN user32
DECLARE LONG EmptyClipboard IN user32
DECLARE LONG SetClipboardData In user32 LONG uFormat, LONG hMem

*!*  Memory Management Functions
DECLARE LONG GlobalAlloc IN kernel32 LONG wFlags, LONG dwBytes
DECLARE LONG GlobalFree IN kernel32 LONG HMEM
DECLARE LONG GlobalLock IN kernel32 LONG HMEM
DECLARE LONG GlobalUnlock IN kernel32 LONG HMEM
DECLARE LONG lstrcpyn In kernel32 As CopyFromStr LONG lpDest, ;
				String @lpSrc, LONG iLen
lnDataLen = LEN(lcText)
lhMem = GlobalAlloc(GMEM_MOVABLE+GMEM_ZEROINIT+GMEM_SHARE,lnDataLen)
lnPtr = GlobalLock(lhMem)
CopyFromStr(lnPtr, @lcText, lnDataLen)
GlobalUnlock(lhMem)
IF OpenClipboard(0) <> 0
	EmptyClipboard()
	SetClipboardData(CF_TEXT, lhMem)
	CloseClipboard()
ELSE
	***GlobalFree(lhMem)
	RETURN .F.
ENDIF
RETURN .T.
You can find more about Windows Clipboard API in MSDN http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/dataexchange/clipboard.asp?frame=true
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform