RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TClipboard.Close Method

Closes the clipboard if it is open.

Pascal
procedure Close; virtual;
C++
virtual __fastcall Close();

Call Close when you are finished adding items to the clipboard. 

The clipboard can be opened with multiple calls to the Open method before being closed. Open and Close maintain a count of the number of times the clipboard has been opened and will not close it until Close has been called the same number of times.  

Delphi Examples: 

 

{
Open, Close, GetAsHandle example
The following code locks the memory for text on the Clipboard, then reads the text.
}

uses clipbrd;

procedure TForm1.Button1Click(Sender: TObject);
var
  MyHandle: THandle;
  TextPtr: PChar;
begin
  ClipBoard.Open;
try
  MyHandle := Clipboard.GetAsHandle(CF_TEXT);
  TextPtr := GlobalLock(MyHandle);
  ListBox1.Items.Add(StrPas(TextPtr));
  GlobalUnlock(MyHandle);
finally
  Clipboard.Close;
end;
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!