Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automated printing of Word doc files from Wordview
Message
From
10/01/1999 01:32:08
 
 
To
09/01/1999 21:04:40
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00174307
Message ID:
00174454
Views:
26
>By the way, do you (or anyone else) know what the value should be for stuffing a CTRL+V (for pasting from the clipboard) via the API call:
>declare integer keybd_event in win32api integer, integer, integer, integer
> vk_key=??
>=keybd_event(vk_key,0,0,0)

Hi All,

Just an update to the above. I finally came up with the following which will paste whatever is on the Windows clipboard to the active window. I needed this to paste graphics and text into the RichText control. (Thanks to George Tasker for his help on how to get the graphic onto the clipboard in the first place!)

Hope it helps someone else.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
* To paste text, place it on the clipboard with
* _cliptext='Whatever'
* example: to insert date and time, then a return
* _cliptext=' '+cdow(date())+' '+ttoc(datetime())+chr(13)

* To paste a BMP file, place it on the clipboard with
* lcPicture=getpict('bmp',"",'Select')
* if empt(lcPicture) or uppe(righ(allt(lcPicture),9))=='UNTITLED.'
* * nothing picked
* retu
* else
* DECLARE SHORT OpenClipboard IN Win32API INTEGER hWndNewOwner
* DECLARE INTEGER SetClipboardData IN Win32API ;
* INTEGER uFormat, INTEGER hMem
* DECLARE SHORT CloseClipboard IN Win32API
* DECLARE INTEGER LoadImage IN Win32API ;
* INTEGER hinst, STRING @lpszName, ;
* INTEGER uType, INTEGER cxDesired, ;
* INTEGER cyDesired, INTEGER fuLoad
* declare integer EmptyClipboard in win32api
* OpenClipboard(0)
* EmptyClipboard()
* lnhandle=loadimage(0,@lcPicture,0,0,0,16)
* lnresult=setclipboarddata(2,lnhandle)
* closeclipboard()
* endi

* Set up Keyboard control
declare short VkKeyScan in Win32API INTEGER nChar
declare keybd_event in Win32API INTEGER bVk, INTEGER bScan, INTEGER dwFlags, INTEGER dwExtraInfo
#define VK_CONTROL 0x11
#define KEYEVENTF_KEYUP 2

* Set focus to window that will receive paste
ThisForm.rtf.setfocus()

* And paste
keybd_event(VK_CONTROL,0,0,0)
keybd_event(342,0,0,0)
keybd_event(342,0,KEYEVENTF_KEYUP,0)
keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0)

* That's it

Mike
Previous
Reply
Map
View

Click here to load this message in the networking platform