Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copy BMP file content to Windows clipboard....HOW?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00169293
Message ID:
00169690
Views:
21
>Does anyone know an API function that will copy the content of a known, standard BMP file to the Windows Clipboard? I need this so that the user can select a file via GetFile(), then paste it into a RichText OCX.
>
>Any suggestions welcome!
>
>Thanks in advance.
>
Hi Mike,

I must admit that when I first saw this post, I didn't think that there was a way to do (at least easily). However, and I've run only one test, the following seems to work:
* Win32 Declares
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
* Open the clipboard. I use the value from the foxtools
* MainhWnd() function here, but zero is permissable
lnhWnd = MainhWnd()
IF OpenClipboard(lnhWnd) # 0
  * lcfile is the name of the bitmap file
  * Use 16 to load from file
  * Other types (icons, etc. can be loaded too.
  * Parameter 3 in this case indicates a bitmap
  lnhandle = LoadImage(0, @lcfile, 0, 0, 16)
  lnresult = SetClipboardData(2, lnhandle)
  IF lnresult = lnhandle
    * The call succeeded
  ENDIF
  = CloseClipboard()
ENDIF
Note that the image won't be available until the clipboard is closed. Further, failure to close it will make it unavailable to other applications.

hth,
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform