Board index » delphi » Clipboard contents...

Clipboard contents...

hi,

i need to use clipboard to add some texts to a component. but i
also need to restore the previous contents of clipboard after
finishing my task.

for example, currently there is a bitmap in clipboard. i want to
save it to a variable and then do my task (copy/paste a text),
and finally restore that bitmap.

i can do this for texts as below:

if Clipboard.HasFormat(CF_TEXT) then AStringVar = Clipbard.AsText;
// Do the work
if AStringVar <> '' then Clipbaord.AsText = AStringVar;

but it restores the clipboard content, only if it contains a
string.

how can i save the content of the clipbard and restore it?

any comments would be appreciated,
Gerhard

 

Re:Clipboard contents...


Gerhard,
Quote
"Gerhard" <ans...@this.forum> wrote in message

news:3e645c52$1@newsgroups.borland.com...

Quote
> i need to use clipboard to add some texts to a component. but i
> also need to restore the previous contents of clipboard after
> finishing my task.

> for example, currently there is a bitmap in clipboard. i want to
> save it to a variable and then do my task (copy/paste a text),
> and finally restore that bitmap.

> i can do this for texts as below:

> if Clipboard.HasFormat(CF_TEXT) then AStringVar = Clipbard.AsText;
> // Do the work
> if AStringVar <> '' then Clipbaord.AsText = AStringVar;

> but it restores the clipboard content, only if it contains a
> string.

> how can i save the content of the clipbard and restore it?

TClipboard.GetAsHandle and SetAsHandle are more generic than AsText,
so you can use them.
You can also use OleGetClipboard to get an IDataObject interface of
the clipboard data and OleSetClipboard to restore it.

Re:Clipboard contents...


Quote
"Gerhard" <ans...@this.forum> wrote:
> i need to use clipboard to add some texts to a component. but
> i also need to restore the previous contents of clipboard [...]

The following link describes how to save the ClipBoard to a file:

        http://www.infojet.cz/program/delphi/tips/tip0015.html

but a quick google didn't show any examples how to load the
ClipBoard from a file.

Your solution might instead be found with why you feel you must
use the ClipBoard. I'm interested in knowing the circumstances.

~ JD

Re:Clipboard contents...


Quote
"Constantine Yannakopoulos" wrote:
>TClipboard.GetAsHandle and SetAsHandle are more generic than
>AsText, so you can use them.
>You can also use OleGetClipboard to get an IDataObject
>interface of the clipboard data and OleSetClipboard to
>restore it.

ok, i tried to use GetAsHandle/SetAsHandle before asking this
question. but i don't know how to use them!

if you have an example that could help me in this case, please
include it in your reply.

Best regards,
Gerhard

Other Threads