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.

相关阅读 >>

Delphi 获取大于2g的物理内存大小

Delphi inifile to xml

Delphi使用cef4Delphi制作chromium谷歌内核浏览器

Delphi中messagebox的用法

Delphi 给 tcombobox 添加图标

Delphi 请求时间,为当前时间,数值为1970-01-01以来的毫秒数

Delphi 创建新的messagebox窗口前,先关掉之前已经创建好的

Delphi从外部拖拽文件

Delphi winapi: getcurrentthread、getcurrentthreadid、getcurrentprocess、getcurrentprocessid

Delphi pointer 转成string

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...