บทที่หน่วย 1;
ส่วนต่อประสาน
ใช้
Windows, ข้อความ, sysutils, ตัวแปร, คลาส, กราฟิก, การควบคุม, รูปแบบ,
กล่องโต้ตอบ, extctrls, stdctrls, jpeg;
const lmousedown = false;
พิมพ์
tform1 = คลาส (tform)
Edit1: Tedit;
Panel2: tpanel;
Panel1: tpanel;
Panel3: tpanel;
Panel4: tpanel;
Panel5: tpanel;
Panel6: tpanel;
Panel7: tpanel;
Panel8: tpanel;
Panel11: tpanel;
Panel22: tpanel;
Panel33: tpanel;
Panel44: tpanel;
Panel55: tpanel;
Panel66: tpanel;
Panel77: tpanel;
Panel88: tpanel;
ปุ่ม 1: tbutton;
ขั้นตอนการแก้ไข 1Mousemove (ผู้ส่ง: tobject; shift: tshiftstate; x, x,
y: จำนวนเต็ม);
ขั้นตอนการแก้ไข 1Mousedown (ผู้ส่ง: tobject; ปุ่ม: tmouseButton;
SHIFT: TSHIFTSTATE; x, y: จำนวนเต็ม);
ขั้นตอน EDIT1MOUSUP (ผู้ส่ง: TOBJECT; ปุ่ม: TMOUSEBUTTON;
SHIFT: TSHIFTSTATE; x, y: จำนวนเต็ม);
โพรซีเดอร์ Formmousedown (ผู้ส่ง: tobject; ปุ่ม: tmouseButton;
Shift: TSHIFTSTATE; x, y: จำนวนเต็ม);
ขั้นตอน button1mousedown (ผู้ส่ง: tobject; ปุ่ม: tmouseButton;
Shift: TSHIFTSTATE; x, y: จำนวนเต็ม);
ขั้นตอน button1mousemove (ผู้ส่ง: tobject; shift: tshiftstate; x, x,
y: จำนวนเต็ม);
ขั้นตอน button1mouseup (ผู้ส่ง: tobject; ปุ่ม: tmouseButton;
Shift: TSHIFTSTATE; x, y: จำนวนเต็ม);
ส่วนตัว
{ประกาศส่วนตัว}
สาธารณะ
{ประกาศสาธารณะ}
จบ;
วาจา
Form1: TFORM1;
S, A: บูลีน;
การดำเนินการ
{$ r *.dfm}
ขั้นตอน MANIPULATECONTROL (การควบคุม: TCONTROL; Shift: TSHIFTSTATE; X, Y, ความแม่นยำ: จำนวนเต็ม);
var sc_manipulate: Word;
เริ่ม
-
// 光标在控件的最左侧 *************************************************** ***************
-
if (x <= ความแม่นยำ) และ (y> ความแม่นยำ) และ (y <control.height-precision)
จากนั้นเริ่มต้น
sc_manipulate: = $ f001;
control.cursor: = crsizewe;
จบ
-
// 光标在控件的最右侧 *************************************************** ***************
-
อื่นถ้า (x> = control.Width-Precision) และ (y> ความแม่นยำ) และ (y <control.height-Precision)
จากนั้นเริ่มต้น
sc_manipulate: = $ f002;
control.cursor: = crsizewe;
จบ
-
// 光标在控件的最上侧 *********************************************** **************
-
อื่นถ้า (x> ความแม่นยำ) และ (x <control.Width-Precision) และ (y <= ความแม่นยำ)
จากนั้นเริ่มต้น
sc_manipulate: = $ f003;
control.cursor: = crsizens;
จบ
-
// 光标在控件的左上角 *********************************************** **************
-
อื่นถ้า (x <= ความแม่นยำ) และ (y <= ความแม่นยำ)
จากนั้นเริ่มต้น
sc_manipulate: = $ f004;
control.cursor: = crsizenwse;
จบ
-
// 光标在控件的右上角 *********************************************** **************
-
อื่นถ้า (x> = control.Width-Precision) และ (y <= ความแม่นยำ)
จากนั้นเริ่มต้น
sc_manipulate: = $ f005;
control.Cursor: = CRSIZENESW;
จบ
-
// 光标在控件的最下侧 *************************************************** ***************
-
อื่นถ้า (x> ความแม่นยำ) และ (x <control.Width-Precision) และ (y> = control.height-Precision)
จากนั้นเริ่มต้น
sc_manipulate: = $ f006;
control.cursor: = crsizens;
จบ
-
// 光标在控件的左下角 *********************************************** **************
-
อื่นถ้า (x <= ความแม่นยำ) และ (y> = control.height-precision)
จากนั้นเริ่มต้น
sc_manipulate: = $ f007;
control.Cursor: = CRSIZENESW;
จบ
-
// 光标在控件的右下角 *********************************************** **************
-
อื่นถ้า (x> = control.Width-Precision) และ (y> = control.height-Precision)
จากนั้นเริ่มต้น
sc_manipulate: = $ f008;
control.cursor: = crsizenwse;
จบ
-
// 光标在控件的客户区(移动整个控件) *********************************************** *****
-
อื่นถ้า (x> 5) และ (y> 5) และ (x <control.width-5) และ (y <control.height-5)
จากนั้นเริ่มต้น
sc_manipulate: = $ f009;
control.cursor: = crsizeall;
จบ
เริ่มต้นอื่น
sc_manipulate: = $ f000;
control.cursor: = crdefault;
จบ;
-
ถ้า shift = [ssleft] แล้ว
เริ่ม
releasecapture;
control.perform (wm_syscommand, sc_manipulate, 0);
จบ;
จบ;
ขั้นตอน tform1.edit1mousemove (ผู้ส่ง: tobject; shift: tshiftstate; x, x,
y: จำนวนเต็ม);
เริ่ม
manipulatecontrol ((ผู้ส่งเป็น tControl), shift, x, y, 9);
edit1.hint: = 'edit1: tedit'+chr (13)+'ต้นกำเนิด:'+inttoStr (edit1.top)+','
+inttoStr (edit1.left)+';'+'ขนาด:'+inttoStr (edit1.width)+inttoStr (edit1.Height)+Chr (13)+'แท็บหยุด: ture; คำสั่ง: 0';
ถ้า s = จริงแล้ว
เริ่ม
A: = FALSE;
Panel1.visible: = true; Panel2.visible: = true; Panel3.Visible: = true;
Panel4.visible: = true; Panel5. Visible: = true;
Panel6.visible: = true; Panel7.visible: = true; Panel8.visible: = true;
Panel1.top:=edit1.top-6;
Panel1.left: = edit1.left-6;
Panel2.top:=edit1.top+(Dit1.Height Div 2) -3;
Panel2.left: = edit1.left-6;
Panel3.top:=edit1.top+edit1.height;
Panel3.Left: = edit1.left-6;
Panel4.top:=edit1.top-6;
Panel4.left: = edit1.left+(edit1.width div 2);
Panel5.top:=edit1.top+edit1.height;
Panel5.left: = edit1.left+(edit1.width div 2);
Panel6.top:=edit1.top-6;
Panel6.left: = edit1.left+edit1.width;
Panel7.top:=edit1.top+(Dit1.Height Div 2) -3;
Panel7.left: = edit1.left+edit1.width;
Panel8.top:=edit1.top+edit1.height;
Panel8.left: = edit1.left+edit1.width;
จบ;
จบ;
ขั้นตอน tform1.edit1mousedown (ผู้ส่ง: tobject; ปุ่ม: tmouseButton;
SHIFT: TSHIFTSTATE; x, y: จำนวนเต็ม);
เริ่ม
Panel11.visible: = false; Panel22.visible: = false; Panel33. Visible: = false;
Panel44.visible: = false; Panel55. Visible: = false;
Panel66.visible: = false; Panel77.visible: = false; Panel88. Visible: = FALSE;
s: = true;
A: = FALSE;
Panel1.visible: = true; Panel2.visible: = true; Panel3.Visible: = true;
Panel4.visible: = true; Panel5. Visible: = true;
Panel6.visible: = true; Panel7.visible: = true; Panel8.visible: = true;
Panel1.top:=edit1.top-6;
Panel1.left: = edit1.left-6;
Panel2.top:=edit1.top+(Dit1.Height Div 2) -3;
Panel2.left: = edit1.left-6;
Panel3.top:=edit1.top+edit1.height;
Panel3.Left: = edit1.left-6;
Panel4.top:=edit1.top-6;
Panel4.left: = edit1.left+(edit1.width div 2);
Panel5.top:=edit1.top+edit1.height;
Panel5.left: = edit1.left+(edit1.width div 2);
Panel6.top:=edit1.top-6;
Panel6.left: = edit1.left+edit1.width;
Panel7.top:=edit1.top+(Dit1.Height Div 2) -3;
Panel7.left: = edit1.left+edit1.width;
Panel8.top:=edit1.top+edit1.height;
Panel8.left: = edit1.left+edit1.width;
จบ;
ขั้นตอน TFORM1.EDIT1MOUSUP (ผู้ส่ง: TOBJECT; ปุ่ม: TMOUSEBUTTON;
Shift: TSHIFTSTATE; x, y: จำนวนเต็ม);
เริ่ม
ถ้า s = จริงแล้ว
เริ่ม
A: = FALSE;
S: = FALSE;
Panel1.visible: = true; Panel2.visible: = true; Panel3.Visible: = true;
Panel4.visible: = true; Panel5. Visible: = true;
Panel6.visible: = true; Panel7.visible: = true; Panel8.visible: = true;
Panel1.top:=edit1.top-6;
Panel1.left: = edit1.left-6;
Panel2.top:=edit1.top+(Dit1.Height Div 2) -3;
Panel2.left: = edit1.left-6;
Panel3.top:=edit1.top+edit1.height;
Panel3.Left: = edit1.left-6;
Panel4.top:=edit1.top-6;
Panel4.left: = edit1.left+(edit1.width div 2);
Panel5.top:=edit1.top+edit1.height;
Panel5.left: = edit1.left+(edit1.width div 2);
Panel6.top:=edit1.top-6;
Panel6.left: = edit1.left+edit1.width;
Panel7.top:=edit1.top+(Dit1.Height Div 2) -3;
Panel7.left: = edit1.left+edit1.width;
Panel8.top:=edit1.top+edit1.height;
Panel8.left: = edit1.left+edit1.width;
จบ;
จบ;
ขั้นตอน TFORM1.FormMousedOwn (ผู้ส่ง: tobject; ปุ่ม: tmouseButton;
Shift: TSHIFTSTATE; x, y: จำนวนเต็ม);
เริ่ม
A: = FALSE;
S: = FALSE;
Panel1.visible: = false; Panel2.visible: = false; Panel3.Visible: = FALSE;
Panel4.visible: = false; Panel5. Visible: = false;
Panel6.visible: = false; Panel7.visible: = false; Panel8.visible: = false;
-
Panel11.visible: = false; Panel22.visible: = false; Panel33. Visible: = false;
Panel44.visible: = false; Panel55. Visible: = false;
Panel66.visible: = false; Panel77.visible: = false; Panel88. Visible: = FALSE;
จบ;
ขั้นตอน TFORM1.Button1MouseUp (ผู้ส่ง: tobject; ปุ่ม: tmouseButton; shift: tshiftstate; x, y: จำนวนเต็ม);
เริ่มต้นถ้า a = true แล้ว
เริ่ม
A: = FALSE;
S: = FALSE;
Panel1.visible: = false; Panel2.visible: = false; Panel3.Visible: = FALSE;
Panel4.visible: = false; Panel5. Visible: = false;
Panel6.visible: = false; Panel7.visible: = false; Panel8.visible: = false;
Panel11.visible: = true;
Panel22.visible: = true;
Panel33. Visible: = true;
Panel44. Visible: = true;
Panel55. Visible: = true;
Panel66.visible: = true;
Panel77.visible: = true;
Panel88. Visible: = true;
Panel11.top:=button1.top-6;
Panel11.left: = button1.left-6;
Panel22.top:=button1.top+(Button1.Height Div 2) -3;
Panel22.left: = button1.left-6;
Panel33.top:=button1.top+button1.height;
Panel33.left: = button1.left-6;
Panel44.top:=button1.top-6;
Panel44.left: = button1.left+(button1.width div 2);
Panel55.top:=button1.top+button1.height;
Panel55.left: = button1.left+(button1.width div 2);
Panel66.top:=button1.top-6;
Panel66.left: = button1.left+button1.width;
Panel77.top:=button1.top+(Button1.Height Div 2) -3;
Panel77.left: = button1.left+button1.width;
panel88.top:=button1.top+button1.height;
Panel88.left: = button1.left+button1.width;
จบ;
จบ;
ขั้นตอน tform1.button1mousedown (ผู้ส่ง: tobject; ปุ่ม: tmouseButton;
SHIFT: TSHIFTSTATE; x, y: จำนวนเต็ม);
เริ่ม
A: = true;
S: = FALSE;
Panel1.visible: = false; Panel2.visible: = false; Panel3.Visible: = FALSE;
Panel4.visible: = false; Panel5. Visible: = false;
Panel6.visible: = false; Panel7.visible: = false; Panel8.visible: = false;
Panel11.visible: = true; Panel22.visible: = true; Panel33. Visible: = true;
Panel44. Visible: = true; Panel55. Visible: = true;
Panel66.visible: = true; Panel77.visible: = true; Panel88. Visible: = true;
Panel11.top:=button1.top-6;
Panel11.left: = button1.left-6;
Panel22.top:=button1.top+(Button1.Height Div 2) -3;
Panel22.left: = button1.left-6;
Panel33.top:=button1.top+button1.height;
Panel33.left: = button1.left-6;
Panel44.top:=button1.top-6;
Panel44.left: = button1.left+(button1.width div 2);
Panel55.top:=button1.top+button1.height;
Panel55.left: = button1.left+(button1.width div 2);
Panel66.top:=button1.top-6;
Panel66.left: = button1.left+button1.width;
Panel77.top:=button1.top+(Button1.Height Div 2) -3;
Panel77.left: = button1.left+button1.width;
panel88.top:=button1.top+button1.height;
Panel88.left: = button1.left+button1.width;
จบ;
ขั้นตอน tform1.button1mousemove (ผู้ส่ง: tobject; shift: tshiftstate; x, x,
y: จำนวนเต็ม);
เริ่ม
manipulatecontrol ((ผู้ส่งเป็น tControl), shift, x, y, 9);
edit1.hint: = 'button1: tbutton'+chr (13)+'ต้นกำเนิด:'+inttoStr (button1.top)+','
+inttoStr (button1.left)+';'+'ขนาด:'+inttoStr (button1.width)+inttoStr (button1.height)+chr (13)+'แท็บหยุด: ture; สั่ง: 0';
ถ้า a = จริงแล้ว
เริ่ม
S: = FALSE;
Panel1.visible: = false; Panel2.visible: = false; Panel3.Visible: = FALSE;
Panel4.visible: = false; Panel5. Visible: = false;
Panel6.visible: = false; Panel7.visible: = false; Panel8.visible: = false;
Panel11.visible: = true; Panel22.visible: = true; Panel33. Visible: = true;
Panel44. Visible: = true; Panel55. Visible: = true;
Panel66.visible: = true; Panel77.visible: = true; Panel88. Visible: = true;
Panel11.top:=button1.top-6;
Panel11.left: = button1.left-6;
Panel22.top:=button1.top+(Button1.Height Div 2) -3;
Panel22.left: = button1.left-6;
Panel33.top:=button1.top+button1.height;
Panel33.left: = button1.left-6;
Panel44.top:=button1.top-6;
Panel44.left: = button1.left+(button1.width div 2);
Panel55.top:=button1.top+button1.height;
Panel55.left: = button1.left+(button1.width div 2);
Panel66.top:=button1.top-6;
Panel66.left: = button1.left+button1.width;
Panel77.top:=button1.top+(Button1.Height Div 2) -3;
Panel77.left: = button1.left+button1.width;
panel88.top:=button1.top+button1.height;
Panel88.left: = button1.left+button1.width;
จบ;
จบ;
จบ.