RAD Studio VCL Reference
|
Indicates whether the clipboard contains data in a specified format.
function HasFormat(Format: Word): Boolean;
__fastcall Boolean HasFormat(Word Format);
Use HasFormat to find out whether the clipboard contains data encoded in a specific format. HasFormat returns true if the format is present and false otherwise. TClipboard keeps a list of available formats in the Formats array property.
Some of the possible values of the Format parameter follow. HasFormat supports additional formats provided by Windows or by other applications as well as custom formats registered with TPicture::.RegisterClipboardFormat.
Value |
Meaning |
CF_TEXT |
Text with a CR-LF combination at the end of each line. A null character identifies the end of the text. |
CF_BITMAP |
A Windows bitmap graphic. |
CF_METAFILEPICT |
A Windows metafile graphic. |
An object of type TPicture. | |
Any persistent object. |
C++ Examples:
/* This example uses a button and an TEdit on a form. When the user clicks the button, any text on the clipboard is pasted into the TEdit. If there is no text on the clipboard, a message box appears. Note: To use this example, you must add Clipbrd to the uses clause. Load the Clipboard by performing a copy in any application. */ #include <Clipbrd.hpp> void __fastcall TForm1::Button1Click(TObject *Sender) { if (Clipboard()->HasFormat(CF_TEXT)) { Edit1->Text = Clipboard()->AsText; Clipboard()->Clear(); } else MessageDlg( "There is no text on the Clipboard", mtInformation, TMsgDlgButtons() << mbOK, 0); }
Delphi Examples:
{ This example uses a button and an TEdit on a form. When the user clicks the button, any text on the clipboard is pasted into the TEdit. If there is no text on the clipboard, a message box appears. Note: To use this example, you must add Clipbrd to the uses clause. Load the Clipboard by performing a copy in any application. } procedure TForm1.Button1Click(Sender: TObject); begin if Clipboard.HasFormat(CF_TEXT) then begin Edit1.Text := Clipboard.AsText; Clipboard.Clear; end else MessageDlg( 'There is no text on the Clipboard', mtInformation, [mbOK],0); end;
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|