Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy image to clipboard

Status
Not open for further replies.

sqlpro

Programmer
Dec 30, 2003
297
NZ
Hi friends
do you guys know how to copy an image to clipboard in VFP8
for example we can copy text to clipboard with _cliptext
command?
at the moment i am storing image into a dbf file then
copying it to clipboard.
i am wondering if there is any better way!!
Thank you very much
cheers
Rajani
 
lcMyFile=filetostr("IMG_0207.JPG")

strtofile(lcMyFile,"MyFileOut.JPG")

Brian
 
may b i'm missing ur point .this is what i am doing

LPARAMETER tcFileName
IF !FILE('&tcFileName')
MESSAGEBOX ('File Not Found ', 64, gcProgram)
RETURN .F.
ENDIF

** To be on the Safeside store the opened filename and open that again by the end of this program
lcOldFile = ALIAS()

** Need to Findout the Fullpath of the File Stored

SELECT 0
CREATE CURSOR c_Picture (OnlyPict G)
APPEND BLANK
APPEND GENERAL c_Picture.Onlypict FROM FULLPATH(tcFileName)
local lo
lo = LockScreen()

KEYBOARD "{CTRL+C}{CTRL+W}"
MODIFY GENERAL c_picture.onlyPict
USE IN c_Picture
rele lo

MessageBox('Copied to Clipboard',32,gcProgram)

i wonder how to use ur code to replace my code
 
The way you are doing it is the easiest from VFP that I
can think of. The main other way would be using API calls.

It's a bit involved to post here at this time.

Darrell
 
I guess the question is what do you want to do with it once it is in the clipboard? The code I posted doesn't use the clipboard, but does store the file to memory.

Brian
 
once in memory user can open amy image software i.e paint etc.,
and press paste then they can modify the image.
thats is purpose.
Thanks for ur response.
 
You could make a copy of the file using strtofile() and use a shellexecute to open the file in either the application of your choosing, or the default application for the file type.

Brian
 
actually i have no control over application user
uses to modify image.
sometimes user use word to paste image for their internal
reports.
so i think i may not be able to use shellexecute for this purpose
cheers :)
rajani
 
Rajani,

Modify your code like this, hope this works for you:

MODIFY GENERAL c_picture.onlyPict NOWAIT
KEYBOARD '{CTRL+C}'

USE IN c_Picture
rele lo


-- AirCon --
 
Thanks for tip Aircon

Actually my existing code working fine.
i just want to know if there is any better way.
i am thinking i wrote a big program for simple purpose
cheers
rajani
 
i just want to know if there is any better way.
i am thinking i wrote a big program for simple purpose


I'm not really sure what do you mean. Do you mean you want to go with API ?

-- AirCon --
 
i mean something like _cliptext
i wonder if there is anything like _cliptext command
to put an image in to memory.
u get the idea,right?
 
Well, _Cliptext can only put a 'TEXT' into clipboard. You have to use API for bitmap.

Try this (untested):

*----------------
Declare Long OpenClipboard in User32 Long nhWnd
Declare Long CloseClipboard in User32
Declare Long SetClipboardData in User32 ;
Integer nFormat, Long hMem

Declare Long LoadImage in User32;
Long hInst, String cFilename, Integer nType, ;
Integer cxDesired, Integer cyDesired, Integer fuLoad

hBitmap = LoadImage(0, lc_Filename, 0, 0,0, 0x10)
If (hBitmap != 0)
OpenClipboard(0)
EmptyClipboard()
SetClipboardData(2, hBitmap)
CloseClipboard()
endif
*------------


-- AirCon --
 
Oops, I missed one point.

Put the bitmap file you want into "lc_Filename"

lc_Filename = 'MyBitmap.BMP'

-- AirCon --
 
super
i'll try your idea.
thank you very much for ur time

cheers :)
Rajani
 
Wait a minute...

I missed one declaration, add this one:

Declare Long EmptyClipboard in User32

And, I think you have to put the fullpath for the filename. Let me know how it works

-- AirCon --
 
I believe you could use windows API, but I don't know if you'd get any speed improvement and it would be difficult to implement.

Search for OpenClipboard, EmptyClipboard, CloseClipboard, SetClipboardData etc. in MSDN or Google.

Brian
 
baltman,

I hate it when that happens. [snail]

Slighthaze = NULL
craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Sligthaze,

LOL.. sorry guys, can't help it.. :-D

-- AirCon --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top