delphi [FMX]如何使用剪贴板  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi [FMX]如何使用剪贴板


剪贴板
就在前几天,我在Clipboard上看到了一篇文章,顺便说一句,Delphi中的Clipboard太容易使用了,我还没有用Qiita编写它,也许您不知道从柏林出来的新Clipboard服务!我决定写它。

*本文适用于FireMonkey。VCL是另一种方式。

unit1.pas
unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
  FMX.Controls.Presentation, FMX.Edit, FMX.Objects, FMX.Layouts;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Edit1: TEdit;
    Panel1: TPanel;
    Button1: TButton;
    Layout1: TLayout;
    StyleBook1: TStyleBook;
    procedure Button1Click(Sender: TObject);
  private
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

uses
  FMX.Clipboard, FMX.Platform;

procedure TForm1.Button1Click(Sender: TObject);
begin
  var Clipboard: IFMXExtendedClipboardService;
  if
    not TPlatformServices.Current.SupportsPlatformService(
      IFMXExtendedClipboardService,
      Clipboard)
  then
    Exit;

  if Clipboard.HasText then
    Edit1.Text := Clipboard.GetText;

  if Clipboard.HasImage then
    Image1.Bitmap.Assign(Clipboard.GetImage);
end;

end.

推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.039031982421875 seconds