(vi)tmainformの(写真)アクションイベント
1)フルスクリーンキャプチャ
[デスクトップをキャプチャ]アクションイベント
手順tmainform.cptdesktopexecute(sender:tobject);
始める
Inc(Capturenum、1);
application.minimize;
遅延(500);
ファイル名:= 'capture'+inttostr(capturenum)+'。BMP';
ファイル名:= defaultDirectory+filename;
createmdichild(filename、true);
statusbar.simpletext:= filename;
Tmdichildが始まるActivemdichildを使用します
image1.picture.bitmap:= CaptureScreen;
horzscrollbar.range:= image1.picture.width;
vertscrollbar.range:= image1.picture.height;
終わり;
child.image1.hint:= 'height:'+inttostr(child.image1.picture.height)+'pixels'
+'width:'+inttostr(child.image1.picture.width)+'pixels';
Application.Restore;
終わり;
2)エリアキャプチャ
領域の画像をキャプチャするには、新しいform1を使用します。「Delphi Image Interceptプログラミングの例(6)」を参照してください。
メインユニットの実装の使用にCapture1を追加します。
メインユニットCaptureareaにプライベートプロセスを追加します。
手順tmainform.capturearea;
始める
tform1.create(application)do
試す
showmodal = mrokの場合
FRECTが始まります
if(右>左)と(下>トップ)を開始します
遅延(400);
abitmap:= tbitmap.create;
abitmap.assign(CaptureScreenRect(FRECT));
child.image1.picture.bitmap:= abitmap;
child.clientwidth:= child.image1.picture.width;
child.clientheight:= child.image1.picture.height;
child.horzscrollbar.range:= child.image1.picture.width;
child.vertscrollbar.range:= child.image1.picture.height;
abitmap.free;
それ以外の場合は始まります
MESSAGEDLG( '画像領域を誤って選択して、再選択してください!'、mtinformation、[mbok]、0);
child.close;
form1.free;
出口;
終わり;
終わり;
ついに
無料;
終わり;
終わり;
[キャプチャエリア]エリアキャプチャのアクションイベント
手順tmainform.cptareaxecute(sender:tobject);
始める
Inc(Capturenum、1);
application.minimize;
遅延(500);
ファイル名:= 'capture'+inttostr(capturenum)+'。BMP';
ファイル名:= defaultDirectory+filename;
{MDIの子ウィンドウを作成}
createmdichild(filename、true);
statusbar.simpletext:= filename;
{画面のキャプチャエリア}
Capturearea;
child.image1.hint:= 'height:'+inttostr(child.image1.picture.height)+'pixels'
+'width:'+inttostr(child.image1.picture.width)+'pixels';
Application.Restore;
終わり;