喫茶XRAYトップページ

[スレッド全体
]

[12226] クリップボード (FMX)返信 削除
2018/9/3 (月) 14:17:23 Mr.XRAY
[ FMX で TbitmaP からTbitmapSurface への変換方法は? ]
http://madia.world.coocan.jp/cgi-bin/DelphiBBS/wwwlng.cgi?print+201809/18090002.txt


は TBitmap --> TBitmapSurface ですが,TBitmap をクリップボードへ...は
例えば以下の感じでできるようです.
動作確認は Windows 7 U64(SP1) + Delphi 10.2.3 Community  FMX( 32 ビット Windows ) です.
uses に以下が必要です.
  FMX.Platform
  FMX.Clipboard
  FMX.Surfaces

procedure TForm1.Button3Click(Sender: TObject);
var
  LClipbrdService : IFMXExtendedClipboardService;
  LBitmap         : TBitmap;
  LBmpSurface     : TBitmapSurface;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXExtendedClipboardService,
                                                       LClipbrdService) then begin
    LBitmap     := TBitmap.Create;
    LBmpSurface := TBitmapSurface.Create;
    try
      LBitmap.LoadFromFile('Image_01.bmp');
      LBmpSurface.Assign(LBitmap);
      ImageControl1.Bitmap.Assign(LBmpSurface);
      LClipbrdService.SetImage(LBmpSurface);
    finally
      FreeAndNil(LBitmap);
      FreeAndNil(LBmpSurface);
    end;
  end;
end;


直接 TBitmap をコピーするのであれば,

procedure TForm1.Button4Click(Sender: TObject);
var
  LClipbrdService : IFMXExtendedClipboardService;
  LBitmap         : TBitmap;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXExtendedClipboardService,
                                                       LClipbrdService) then begin
    LBitmap := TBitmap.Create;
    try
      LBitmap.LoadFromFile('Image_01.bmp');
      ImageControl1.Bitmap.Assign(LBitmap);
      LClipbrdService.SetClipboard(LBitmap);
    finally
      FreeAndNil(LBitmap);
    end;
  end;
end;

[参考]
[ クリップボード / ペーストボードを使用するには? ]
https://ht-deko.com/techf018.html
[ Delphi XE8でFiremonkeyアプリケーションでクリップボードに文字列をコピーする – 山本隆の開発日誌 ]
https://www.gesource.jp/weblog/?p=6903

えっ !?
上の記事とオンラインヘルプの丸写し ?
そういうことはですね.気にしないでくださいませ (^^;


[12227] Re:クリップボード (FMX)返信 削除
2018/9/3 (月) 22:13:07 Mr.XRAY
> 上の記事とオンラインヘルプの丸写し ?

『優れたプログラマは真似る.偉大なプログラマは盗む 』
っていいますから (これもスティーブ・ジョブスの真似です)


[12236] 凡人は真似る.天才は盗む返信 削除
2018/9/6 (木) 23:23:37 Mr.XRAY
> 『優れたプログラマは真似る.偉大なプログラマは盗む 』
> っていいますから (これもスティーブ・ジョブスの真似です)


ちょっと調べただけですが,スティーブ・ジョブスは,
『優れた芸術家は真似る.偉大な芸術家は盗む 』
と言ったようですが,これは

『凡人は真似る.天才は盗む 』

というピカソの言葉が元のようです.


[▼次のスレッド]
INCM/CMT
Cyclamen v3.82