vfp frx custom paper size code example

Example: vfp frx custom paper size

aa=Fullpath(Getfile('txt'))
tcUnicodeText=Strconv(Filetostr(aa), 5, 1256, 1)
*-------------------------------------------------
Do CopyUnicodeText2Clipboard With tcUnicodeText

Declare Sleep In kernel32 Integer

Declare  Integer FindWindow In WIN32API String , String
Declare  Integer SetForegroundWindow In WIN32API Integer
Declare  Integer  ShowWindow  In WIN32API Integer , Integer
Declare Integer ShellExecute In shell32.Dll ;
	INTEGER hndWin, ;
	STRING cAction, ;
	STRING cFileName, ;
	STRING cParams, ;
	STRING cDir, ;
	INTEGER nShowWin

Local lt, lhwnd
cPhone=[923226857062]
cmd='whatsapp://send?phone=&cPhone'
=ShellExecute(0, 'open', cmd,'', '', 1)
Wait "" Timeout 3
lt = "Whatsapp"
lhwnd = FindWindow (0, lt)
If lhwnd!= 0
	SetForegroundWindow (lhwnd)
	ShowWindow (lhwnd, 1)
	ox = Createobject ( "Wscript.Shell" )
	ox.sendKeys ("^{v}")
	sleep(2000)
	ox.sendKeys ( '{ENTER}' )
Else
	Messagebox ("Whatsapp is not activated!" )
Endif


&& Copy Unicode text into Clipboard
Function CopyUnicodeText2Clipboard(tcUnicodeText)
Local lnDataLen, lcDropFiles, llOk, i, lhMem, lnPtr, lcUnicodeText

#Define CF_UNICODETEXT      13
&&  Global Memory Variables with Compile Time Constants
#Define GMEM_MOVABLE 	0x0002
#Define GMEM_ZEROINIT	0x0040
#Define GMEM_SHARE		0x2000

&& Load required Windows API functions
=LoadApiDlls()

llOk = .T.
lcUnicodeText = tcUnicodeText + Chr(0)+Chr(0)
lnDataLen = Len(lcUnicodeText)
&& Copy Unicode text into the allocated memory
lhMem = GlobalAlloc(GMEM_MOVABLE+GMEM_ZEROINIT+GMEM_SHARE, lnDataLen)
lnPtr = GlobalLock(lhMem)
=CopyFromStr(lnPtr, @lcUnicodeText, lnDataLen)
=GlobalUnlock(lhMem)
&& Open clipboard and store Unicode text into it
llOk = (OpenClipboard(0) <> 0)
If llOk
	=EmptyClipboard()
	llOk = (SetClipboardData(CF_UNICODETEXT, lhMem) <> 0)
&& If call to SetClipboardData() is successful, the system will take ownership of the memory
&&   otherwise we have to free it
	If Not llOk
		=GlobalFree(lhMem)
	Endif
&& Close clipboard
	=CloseClipboard()
Endif
Return llOk

Function LoadApiDlls
&&  Clipboard Functions
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
&&  Memory Management Functions
Declare Long GlobalAlloc In WIN32API Long wFlags, Long dwBytes
Declare Long GlobalFree In WIN32API Long Hmem
Declare Long GlobalLock In WIN32API Long Hmem
Declare Long GlobalUnlock In WIN32API Long Hmem
Declare Long RtlMoveMemory In WIN32API As CopyFromStr Long lpDest, String @lpSrc, Long iLen
RETURN

Tags:

Misc Example