Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Clipboard Functions
Message
 
To
13/06/2001 23:41:26
Grover Cox
Regional Transit Partners
Atlanta, Georgia, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00519175
Message ID:
00519232
Views:
21
Hi!
I can suggest to use WinAPI. Functions below works with ThisForm.Text1 content.
They need to be modified to use selection in active control.
PROCEDURE btnCopy.Click
	#define CF_TEXT 1
	#define GMEM_MOVEABLE 2
	#define GMEM_ZEROINIT 64

	Declare Long GlobalAlloc in Win32API Long uFlags, Long dwBytes
	Declare Long GlobalFree in Win32API Long hMem
	Declare Long GlobalLock in Win32API Long hMem
	Declare Long GlobalUnlock in Win32API Long hMem
	Declare String lstrcpy in Win32API Long lpDest, String @ lpStr
	Declare Long OpenClipboard in Win32API Long
	Declare Long CloseClipboard in Win32API
	Declare Long EmptyClipboard in Win32API
	Declare Long SetClipboardData in Win32API Long uFormat, Long hMem

	s = TRIM(ThisForm.Text1.Value)
	h = GlobalAlloc(GMEM_MOVEABLE+GMEM_ZEROINIT, LEN(s)+1)
	ptr = GlobalLock(h)
	lstrcpy(ptr, s)
	GlobalUnlock(h)
	If(OpenClipboard(0) != 0)
		EmptyClipboard()
		SetClipBoardData(CF_TEXT, h)
		CloseClipboard()
	else
		GlobalFree(h)
	EndIf
ENDPROC

PROCEDURE btnPaste.Click
	Declare String GlobalLock in Win32API Long hMem
	Declare Long GlobalUnlock in Win32API Long hMem
	Declare Long OpenClipboard in Win32API Long
	Declare Long CloseClipboard in Win32API
	Declare Long GetClipboardData in Win32API Long uFormat

	If(OpenClipboard(0) != 0)
		h = GetClipBoardData(CF_TEXT)
		ptr = GlobalLock(h)
		ThisForm.Text1.Value = ptr
		GlobalUnlock(h)
		CloseClipboard()
	EndIf
ENDPROC
>I need some help setting up buttons in my form to Cut, Copy & Paste selected text in a field to and from the Windows clipboard. I have achieved some limited success using shortcut keys instead of buttons. But I need the same functionality via a button in my form. The problem is when text is selected in a field and then you select a button the selected text in the field loses focus when the button is clicked and there is then nothing to cut or copy to the clipboard. The only info. I have found on this topic is in Technet that discusses how to use the standard VFP Edit menu bars to perform these functions. I have setup a shortcut menu with these functions that is started and then deactivated in the Init event of a sample form. This allows the shortcut keys (CTRL+X,C,V) to work. But trying to use buttons instead of the shortcut keys doesn't work, apparently for the reason listed above. I am at a deadend right now and could use some one elses point of view on this problem.
Previous
Reply
Map
View

Click here to load this message in the networking platform