(vi) เหตุการณ์การกระทำของ Tmainform (รูปภาพ)
1) การจับภาพเต็มหน้าจอ
[Capture Desktop] กิจกรรมการกระทำ
ขั้นตอน tmainform.cptdesktopexecute (ผู้ส่ง: tobject);
เริ่ม
Inc (Capturenum, 1);
Application.minimize;
ล่าช้า (500);
ชื่อไฟล์: = 'Capture'+inttoStr (capturenum)+'. bmp';
ชื่อไฟล์: = defaultDirectory+ชื่อไฟล์;
createemdichild (ชื่อไฟล์จริง);
StatusBar.SimpleText: = ชื่อไฟล์;
ด้วย activemdichild เมื่อ tmdichild เริ่มต้นขึ้น
Image1.picture.bitmap: = CapturesCreen;
horzscrollbar.Range: = image1.picture.width;
Vertscrollbar.Range: = image1.picture.height;
จบ;
child.image1.hint: = 'ความสูง:'+inttostr (child.image1.picture.height)+'พิกเซล'
+'ความกว้าง:'+inttoStr (child.image1.picture.width)+'พิกเซล';
Application.restore;
จบ;
2) การจับพื้นที่
ในการจับภาพพื้นที่พื้นที่ Form1 ใหม่จะใช้ดู "ตัวอย่างการเขียนโปรแกรม Delphi Image Intercepting (6)"
เพิ่ม Capture1 ในการใช้งานหน่วยหลัก
เพิ่มกระบวนการส่วนตัวในหน่วยหลัก Capturearea:
ขั้นตอน tmainform.capturearea;
เริ่ม
ด้วย tform1.create (แอปพลิเคชัน) ทำ
พยายาม
ถ้า showmodal = mrok แล้ว
ด้วย Frect จะเริ่มต้นขึ้น
ถ้า (ขวา> ซ้าย) และ (ด้านล่าง> ด้านบน) แล้วเริ่มต้น
ความล่าช้า (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.vertscrollbar.Range: = child.image1.picture.height;
abitmap.free;
จุดเริ่มต้นเริ่มต้น
MessageGlg ('เลือกพื้นที่ภาพไม่ถูกต้องโปรดกลับมาอีกครั้ง!', mtinformation, [mbok], 0);
child.close;
Form1.free;
ออก;
จบ;
จบ;
ในที่สุด
ฟรี;
จบ;
จบ;
[พื้นที่จับภาพ] กิจกรรมแอ็คชั่นสำหรับการจับภาพพื้นที่
ขั้นตอน tmainform.cptareaexecute (ผู้ส่ง: tobject);
เริ่ม
Inc (Capturenum, 1);
Application.minimize;
ความล่าช้า (500);
ชื่อไฟล์: = 'Capture'+inttoStr (capturenum)+'. bmp';
ชื่อไฟล์: = defaultDirectory+ชื่อไฟล์;
{สร้างหน้าต่างลูก mdi}
createemdichild (ชื่อไฟล์จริง);
StatusBar.SimpleText: = ชื่อไฟล์;
{พื้นที่จับภาพหน้าจอ}
Capturearea;
child.image1.hint: = 'ความสูง:'+inttostr (child.image1.picture.height)+'พิกเซล'
+'ความกว้าง:'+inttoStr (child.image1.picture.width)+'พิกเซล';
Application.restore;
จบ;