Board index » delphi » Clipboard.Open and Clipboard.Close

Clipboard.Open and Clipboard.Close

According to the Delphi 1.02 documentation it should be possible to use

      uses ...., Clpboard, ...
    ....
      Memo1 : TMemo;
      Memo2 : TMemo;
    ....  
      Clipboard.Open;
      Memo1.SelectAll;
      Memo1.CopyToClipboard;
      Memo2.SelectAll;
      Memo2.CopyToClipboard;
      Clipboard.Close;

to merge two chunks of text on the clipboard. This does not seem to
work. When I try it by stepping through the code, the text
  <Cannot open clipboard>
appears on the clipboard as soon as Clipboard.Open has executed.

Does anyone have any clues?

/Lars Renman

 

Re:Clipboard.Open and Clipboard.Close


Hi there,

I don't use the Clipbrd UNIT myself but I do know that subsequent Clipboard
functions OVERWRITE the current data in the clipboard. So if you copy once,
then again, the initial copy gets wiped out. This is clearly stated in the
Windows API function descriptions. I should clatify and state that objects of
similar TYPE are erased (i.e. cf_TEXT, etc).

Also, only ONE app can "own" the Clipboard at a time. The problem you may be
having is that you are trying to "Open" the clipboard twice? I *think* (don't
quote me on this :-) that by USEing the Clipbrd UNIT, it handles the OPEN/CLOSE
functionality for you. So then all you have to do is call the CopytoClipboard,
etc functions without worrying...

Also note that contrary to popular belief, the Clipboard CAN hold more than 64K
of data. Most Clipboard functions use PChar which has a max size of WORD
(65535). However, you have the Clipboard pointer point to ANY valid pointer
type (this requires some memory tricks). I wrote an app that actually directly
"writes" into the Clipboard memory (MB worth of data) with no problems...

Hope this helps.

Cheers,
George.---

Quote
l...@amc.chalmers.se (Lars Renman) wrote:

>According to the Delphi 1.02 documentation it should be possible to use

>      uses ...., Clpboard, ...
>    ....
>      Memo1 : TMemo;
>      Memo2 : TMemo;
>    ....  
>      Clipboard.Open;
>      Memo1.SelectAll;
>      Memo1.CopyToClipboard;
>      Memo2.SelectAll;
>      Memo2.CopyToClipboard;
>      Clipboard.Close;

>to merge two chunks of text on the clipboard. This does not seem to
>work. When I try it by stepping through the code, the text
>  <Cannot open clipboard>
>appears on the clipboard as soon as Clipboard.Open has executed.

Re:Clipboard.Open and Clipboard.Close


Lars Renman wrote in a message to All:

LR> to merge two chunks of text on the clipboard. This does not seem to
LR> work. When I try it by stepping through the code, the text
LR>   <Cannot open clipboard>
LR> appears on the clipboard as soon as Clipboard.Open has executed.

I think the clipboard is already open. Skip these calls and just say somethign like:

  Clipboard.AsText := 'my test';

Groetjes,

Berend (-:
fido: 2:281/527.23
email: 100120.3...@compuserve.com
SEEN-BY: 1/1 60/0

Other Threads