Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copy text to clipboard
Message
From
09/02/2010 08:17:17
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Copy text to clipboard
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01448320
Message ID:
01448320
Views:
130
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 ?
Next
Reply
Map
View

Click here to load this message in the networking platform