General information
Category:
Windows API functions
Title:
Copy text to clipboard
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only