- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
First a great thank you to INTEL for developing IVF and to Steve for maintaining this very helpful forum.
Now my question :
How can a IVF program write into the clipboard so that I can just paste to get a text into a window application (word or outlook) ?
Thanks
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First, you need to use GlobalAlloc to allocate the number of bytes required to store your text.
For example:
hTextBytes = GlobalAlloc(GMEM_MOVEABLE+GMEM_DDESHARE, numberofbytes) ! Returns a handle to the memory object
hText = GlobalLock(hTextBytes) ! Returns a pointer to the first byte of the memory block and locks it for use
Then you put your text into the memory buffer pointed to by hText (use pointer-> target for example where target is a character variable)
Then you need to use the Clipboard functions.
iret=OpenClipboard(hWindow) !claim ownership of the clipboard for your window, handle hWindow
iret = SetClipboardData(CF_TEXT, hTextBytes) !Copy the contents onto clipboard
iret=CloseClipboard() ! Release the clipboard
iret = GlobalUnlock(hTextBytes) ! unlock the allocated memory
iret = GlobalFree(hTextBytes) ! Free the momory
CF_TEXT is a standard clipboard format for text where each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data. Use this format for ANSI text.
You could put all this into a routine CopyToClipboard that supplies a pointer/address of an allocated character string containing the text that you want to copy to the clipboard. You could then determine the the number of bytes in the input text string, determine its starting location using LOC(string) , then use CopyMemory to copy the input text string from its memory location to the allocated memory block and then to the clipboard. You might even be able to copy directly from the input string to the clipboard.
For example:
hTextBytes = GlobalAlloc(GMEM_MOVEABLE+GMEM_DDESHARE, numberofbytes) ! Returns a handle to the memory object
hText = GlobalLock(hTextBytes) ! Returns a pointer to the first byte of the memory block and locks it for use
Then you put your text into the memory buffer pointed to by hText (use pointer-> target for example where target is a character variable)
Then you need to use the Clipboard functions.
iret=OpenClipboard(hWindow) !claim ownership of the clipboard for your window, handle hWindow
iret = SetClipboardData(CF_TEXT, hTextBytes) !Copy the contents onto clipboard
iret=CloseClipboard() ! Release the clipboard
iret = GlobalUnlock(hTextBytes) ! unlock the allocated memory
iret = GlobalFree(hTextBytes) ! Free the momory
CF_TEXT is a standard clipboard format for text where each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data. Use this format for ANSI text.
You could put all this into a routine CopyToClipboard that supplies a pointer/address of an allocated character string containing the text that you want to copy to the clipboard. You could then determine the the number of bytes in the input text string, determine its starting location using LOC(string) , then use CopyMemory to copy the input text string from its memory location to the allocated memory block and then to the clipboard. You might even be able to copy directly from the input string to the clipboard.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Anthonyrichards,
Thanks for your quick answer.
Which file do I have to "USE" to include the clipboard functions ?
Thanks for your quick answer.
Which file do I have to "USE" to include the clipboard functions ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Anthonyrichards,
I found it.... and it works fine.
Thank you very much
Jean-Marc Loriot
I found it.... and it works fine.
Thank you very much
Jean-Marc Loriot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For all of us: what library did you include with "use" to get the clipboard functions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
USE USER32
USER32.LIB is a standard windows library that is usually included in the default library search list for the linker.
GlobalAlloc is in KERNEL32.LIB.
However, if you just use
USE IFWIN
that includes USEs for all the standard IVF and windows modules.
USER32.LIB is a standard windows library that is usually included in the default library search list for the linker.
GlobalAlloc is in KERNEL32.LIB.
However, if you just use
USE IFWIN
that includes USEs for all the standard IVF and windows modules.
![](/skins/images/9701FEC4E90D143B667C09F3DB2F340F/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page