(7) زحف نموذج صورة أو التحكم في صورة
قم بإنشاء نموذج جديد 2 وحفظه كـ capture2.pas. تعيين خصائص الأربعة للحدود السمة على خطأ.
تم تعيين BorderStyle على Bsnone ، يتم تعيين Formstyle على FSStayontop.
متغيران شائعان: FRECT: TRECT ، FBMP: TBITMAP ؛
وحدة التقاط 2 ؛
واجهة
يستخدم
Windows ، الرسائل ، sysutils ، المتغيرات ، الفئات ، الرسومات ، عناصر التحكم ، النماذج ،
مربعات حوار
يكتب
tform2 = فئة (tform)
Formcreate الإجراء (المرسل: TOBJECT) ؛
تكوين الإجراء (المرسل: TOBJECT) ؛
الإجراء FormDestroy (المرسل: tobject) ؛
Formpaint الإجراء (المرسل: tooject) ؛
FormMouseup الإجراء (المرسل: TOBJECT ؛ زر: TMOUSEBUTTON ؛
Shift: TshiftState ؛
خاص
{إعلانات خاصة}
عام
FRECT: TRECT ؛
FBMP: tbitmap ؛
نهاية؛
var
form2: tform2 ؛
تطبيق
{$ r *.dfm}
// قم بإنشاء مؤشر مخصص جديد مؤشر incrsor_1 ووضعه في موارد capture2.res
// في الملف ، هناك حدود مستطيلة بيضاء تبلغ 32*32 للإشارة إلى نطاق الالتقاط.
الإجراء tform2.FormCreate (المرسل: tobject) ؛
var ADC: HDC ؛
const crhand = -18 ؛
يبدأ
screen.cursors [crhand]: = loadcursor (hinstance ، 'cursor_1') ؛
المؤشر: = crhand ؛
fbmp: = tbitmap.create ؛
fbmp.width: = screen.width ؛
fbmp.hight: = screen.hight ؛
ADC: = getDC (0) ؛
bitblt (fbmp.canvas.handle ، 0،0 ، screen.width ، screen.height ، adc ، 0،0 ، srccopy) ؛
تم إصداره (0 ، ADC) ؛
setBounds (0،0 ، screen.width ، screen.hight) ؛
نهاية؛
الإجراء tform2.FormActivate (المرسل: tobject) ؛
const crhand = -18 ؛
يبدأ
screen.cursors [crhand]: = loadcursor (hinstance ، pchar ('cursor_1')) ؛
المؤشر: = crhand ؛
نهاية؛
الإجراء tform2.formdestroy (المرسل: tobject) ؛
يبدأ
fbmp.free ؛
screen.cursor: = crdefault ؛
نهاية؛
الإجراء tform2.formpaint (المرسل: tobject) ؛
يبدأ
canvas.draw (0،0 ، fbmp) ؛
نهاية؛
الإجراء tform2.formmouseup (المرسل: TOBJECT ؛ زر: TMOUSEBUTTON ؛
Shift: TshiftState ؛
يبدأ
ModalResult: = MROK ؛
نهاية؛
نهاية.