掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Firemonkeyでフォームのイメージを取得したい (ID:43333)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
FiremonkeyのコンポーネントにはMakeScreenshotメソッドがありますが、フォームには無いので VCLでスクリーンショットを撮って ストリームに保存して、Firemonkeyに渡す作業が必要みたいです。 (参考:http://stackoverflow.com/questions/10303256/how-to-take-a-screenshot-with-firemonkey-multi-platforms) Windowsで成功したコードも書いておきます。 implementation uses Winapi.Windows, Vcl.Graphics, FMX.Platform.Win; procedure TForm1.GetFormShot(var dest: FMX.Types.TBitmap); var cVCL : Vcl.Graphics.TCanvas; bmpVCL: Vcl.Graphics.TBitmap; msBmp : TMemoryStream; begin bmpVCL := Vcl.Graphics.TBitmap.Create; cVCL := Vcl.Graphics.TCanvas.Create; cVCL.Handle := GetWindowDC(FMX.Platform.Win.FmxHandleToHWND(Form1.Handle)); try bmpVCL.Width := 640; bmpVCL.Height := 473; bmpVCL.Canvas.CopyRect(Rect(0, 0, 640, 473), cVCL, Rect(8, 30, 648, 503) ); finally ReleaseDC(0, cVCL.Handle); cVCL.Free; end; msBmp := TMemoryStream.Create; try bmpVCL.SaveToStream(msBmp); msBmp.Position := 0; dest.LoadFromStream(msBmp); finally msBmp.Free; end; end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.