Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Clearing Clipboard after DataToClip Method
Message
 
 
To
11/12/2003 07:26:12
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00857933
Message ID:
00858376
Views:
18
>>>How about:
>>>
>>>
>>>_cliptext = ""
>>>
>>>
>>>(in VFP)
>>
>>Hilmar,
>>This makes for an even smaller clipboard content than the two-record workaround ...
>
>And, it is simpler to code.
>
>> ...but still doesn't get rid of the clipboard contents entirely. I tried various combinations of CLEAR, RELEASE, CLOSE and setting to .NULL. of the _CLIPTEXT variable but none of these worked either.
>
>It is not very common for Windows applications to clear the Clipboard completely; an exception might be programs that keep large quantity of data (graphics, long texts) on the Clipboard: when you exit, they ask you whether you want to keep it.
>
>I would not worry about this; but if you do, there might be an API function to erase this. However, I don't know how.

Hilmer,
Thanks to Thread# 784783 and a bit of research, I finally found the necessary API calls to clear the clipboard. They are the following:
*!*  Global Memory Variables with Compile Time Constants

#DEFINE GMEM_MOVABLE 	0x0002
#DEFINE GMEM_ZEROINIT	0x0040
#DEFINE GMEM_SHARE		0x2000

*!*  Code to actually do something that puts data in Clipboard goes here

*!*  Need to clear the Clipboard

*!*  Clipboard Functions
DECLARE LONG OpenClipboard IN user32 LONG HWND
DECLARE LONG CloseClipboard IN user32
DECLARE LONG EmptyClipboard IN user32

*!*  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

lnDataLen = LEN(_CLIPTEXT)
lhMem = GlobalAlloc(GMEM_MOVABLE+GMEM_ZEROINIT+GMEM_SHARE,lnDataLen+1)
GlobalUnlock(lhMem)
IF OpenClipboard(0) <> 0
	EmptyClipboard()
	CloseClipboard()

ELSE
	GlobalFree(lhMem)
	RETURN .F.
ENDIF
Which then leaves the clipboard empty.
Stephen
Previous
Reply
Map
View

Click here to load this message in the networking platform