Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Copy,Copy...Can you tell me how to copy file(s) to the clipboard

123 views
Skip to first unread message

GOH

unread,
Mar 2, 2001, 5:07:36 AM3/2/01
to
Hi
I'm having problem with copying file(s) to the clipboard from my
application. It looks like noOne has done it before, at least not put it on
the web. the only thing I can find is copy string or pictures.
I dont want to copy files directly, from one destination to another but,
what I want is put the
file(s) on the clipboard so I can get it anywhere else in some other
application like IE or Word or desktop.
In all copy functions I have seen so far, then I always have to say where to
copy from and where to.
EX : from C:\test\filename.XXX to C:\temp\filename.XXX
and it won't go to clipboard


thank you


John Herbster

unread,
Mar 2, 2001, 9:52:53 AM3/2/01
to
GOH,
Have you studied TClipboard -- in particular TClipboard.HasFormat?
Regards, JohnH


GOH

unread,
Mar 2, 2001, 12:36:34 PM3/2/01
to
Hi,

thank you,

but I have already read it. And I have done it again. but I dont understand
how it can help me.

Ok I can create my format or use CF_COMPONENT but how can i get the files
let's say its file number 2,4,5,7,8,9 in the list. because I can only have
one object at the time on the clipboard.

And if I create my format can other applications understand it like word or
ie or mspaint or just what ever?

procedure TForm1.Button1Click(Sender: TObject);

begin

clipboard.Open;

clipboard.Clear;

//This is my problem

//??????????????????????????????????????????????

clipboard.Assign(filelistbox1.Items); // or clipboard.SetComponent or ??????


clipboard.Close;

end;

I hope you can help me

thank you again

"John Herbster" <jo...@petronworld.com> wrote in message
news:3a9fb43c$1_1@dnews...

John Herbster

unread,
Mar 2, 2001, 12:56:02 PM3/2/01
to
GOH <g...@net-album.net> wrote
> but I have already read it [in help about TClipboard.HasFormat].

GOH, I have only used clipboard through the AsText property. But,
as I understand it, the same information is allowed to exist on the
clipboard in several formats -- ex: plain text, html, etc. and the
reader of the clipboard selects the format that it wants. Maybe an
expert will jump in here and help. Regards, JohnH

GOH

unread,
Mar 2, 2001, 1:09:14 PM3/2/01
to
ok I try it, thanks

"John Herbster" <jo...@petronworld.com> wrote in message

news:3a9fdeb0$1_1@dnews...

Marin Atanasov

unread,
Mar 2, 2001, 2:09:28 PM3/2/01
to
I'm afraid it won't help you, but I'll try.
Here you are some code, you can use to tell explorer same as when you
Right Click on file and choose "Copy"

.........
Uses ..............Clipboard, ShlObj.........;

Procedure ...................
Const
m : array[0..14] of Char = 'F:\index.html'#0#0; // It is file on my hard
disk you must choose existing file on your.
Var
df : DROPFILES;
p : Pointer;
p1 : ^Byte;
gm : THandle;

begin
gm := GlobalAlloc( GMEM_FIXED, SizeOf( df) + SizeOf( m));
p := GlobalLock( gm);

df.pFiles := SizeOf( df);
df.pt := Point(0,0);
df.fWide := FALSE;
Move( df, p^, SizeOf( df));
p1 := p;
Inc( p1, SizeOf( df));
Move( m, p1^, SizeOf( m));
GlobalUnlock( gm);

ClipBoard.Open;
SetClipboardData( CF_HDROP, gm);
Clipboard.Close;
end;

After executing this procedure you can Right Click on your Desktop (for
example, or any folder opened from explorer) and choose "Paste"

If you want to "copy" more than one file they should be in format
<FILE_NAME_1>#0<FILE_NAME_2>#0....<FILE_NAME_N>#0#0 - note double '#0' at
end.

Hope, it will help you.
Marin Atanasov

"GOH" <g...@net-album.net> wrote in message
news:97nrkk$lu...@bornews.inprise.com...

Peter Below (TeamB)

unread,
Mar 2, 2001, 3:05:08 PM3/2/01
to
Duplicate post answered in ObjectPascal.

Please do not post your question to several of the newsgroups at once,
it is against the forum guidelines (see
http://www.borland.com/newsgroups/) and just wastes resources (both
server and human, somebody might spend time on answering a post that
has already been answered in another newsgroup).

Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

GOH

unread,
Mar 5, 2001, 5:11:49 AM3/5/01
to
thank you I think it will help

"Marin Atanasov" <mata...@scientist.com> wrote in message
news:3a9ff0c4$1_1@dnews...

0 new messages