Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Copy text to clipboard
Message
De
09/02/2010 08:17:17
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Copy text to clipboard
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01448320
Message ID:
01448320
Vues:
129
I want to wrte some code to get some text into the Windows Clipboard. The _ClipText is giving to much problems so i want to use the SetClipboardData-function...

----------------------------------------------------------------------------------------------------------
cText = "Text I want to put into the clipboard"

#define CF_TEXT 1

Declare Long OpenClipboard in Win32API Long hWnd
Declare Long CloseClipboard in Win32API
Declare Long EmptyClipboard in Win32API
Declare Long SetClipboardData in Win32API Long uFormat, Long hMem

#define ERR_CLIPNOTOPEN "Cannot open the clipboard"
#define ERR_CLIPNODATA "No bitmap data found on the clipboard"
#define ERR_CLIPSETDATA "Cannot place data on the clipboard"

IF OpenClipboard(0) != 0
EmptyClipboard()

hText = ?????????????

hndl = SetClipboardData(CF_TEXT, hText)
CloseClipboard()
IF hndl = 0
ERROR ERR_CLIPSETDATA
ENDIF
ELSE
RETURN .F.
ENDIF
------------------------------------------------------------------------------------------------------------------------------------


What I don't know is how to get the text into the hText-property.

I found some code how to do this but don't know how to translate this to Foxpro-code :

'source' is here the text to put into the clipboard...

HGLOBAL clipbuffer;
char * buffer;
EmptyClipboard();
clipbuffer = GlobalAlloc(GMEM_DDESHARE, source.GetLength()+1);
buffer = (char*)GlobalLock(clipbuffer);
strcpy(buffer, LPCSTR(source));
GlobalUnlock(clipbuffer);


Can anybody help me ?
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform