分享
 
 
 

模拟delphi编辑窗体操作控件。。。

王朝delphi·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, ExtCtrls, StdCtrls, jpeg;

const LMouseDown=False;

type

TForm1 = class(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;

Button1: TButton;

procedure Edit1MouseMove(Sender: TObject; Shift: TShiftState; X,

Y: Integer);

procedure Edit1MouseDown(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

procedure Edit1MouseUp(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

procedure FormMouseDown(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

procedure Button1MouseDown(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

procedure Button1MouseMove(Sender: TObject; Shift: TShiftState; X,

Y: Integer);

procedure Button1MouseUp(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

s,a:boolean;

implementation

{$R *.dfm}

procedure ManipulateControl(Control: TControl; Shift: TShiftState; X, Y, Precision: integer);

var SC_MANIPULATE: Word;

begin

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//光标在控件的最左侧**********************************************************

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

if (X<=Precision) and (Y>Precision) and (Y<Control.Height-Precision)

then begin

SC_MANIPULATE := $F001;

Control.Cursor := crSizeWE;

end

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//光标在控件的最右侧**********************************************************

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

else if (X>=Control.Width-Precision) and (Y>Precision) and (Y<Control.Height-Precision)

then begin

SC_MANIPULATE := $F002;

Control.Cursor := crSizeWE;

end

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//光标在控件的最上侧**********************************************************

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

else if (X>Precision) and (X<Control.Width-Precision) and (Y<=Precision)

then begin

SC_MANIPULATE := $F003;

Control.Cursor := crSizeNS;

end

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//光标在控件的左上角**********************************************************

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

else if (X<=Precision) and (Y<=Precision)

then begin

SC_MANIPULATE := $F004;

Control.Cursor := crSizeNWSE;

end

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//光标在控件的右上角**********************************************************

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

else if (X>=Control.Width-Precision) and (Y<=Precision)

then begin

SC_MANIPULATE := $F005;

Control.Cursor := crSizeNESW ;

end

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//光标在控件的最下侧**********************************************************

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

else if (X>Precision) and (X<Control.Width-Precision) and (Y>=Control.Height-Precision)

then begin

SC_MANIPULATE := $F006;

Control.Cursor := crSizeNS;

end

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//光标在控件的左下角**********************************************************

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

else if (X<=Precision) and (Y>=Control.Height-Precision)

then begin

SC_MANIPULATE := $F007;

Control.Cursor := crSizeNESW;

end

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//光标在控件的右下角**********************************************************

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

else if (X>=Control.Width-Precision) and (Y>=Control.Height-Precision)

then begin

SC_MANIPULATE := $F008;

Control.Cursor := crSizeNWSE;

end

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//光标在控件的客户区(移动整个控件)******************************************

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

else if (X>5) and (Y>5) and (X<Control.Width-5) and (Y<Control.Height-5)

then begin

SC_MANIPULATE := $F009;

Control.Cursor := crSizeAll;

end

else begin

SC_MANIPULATE := $F000;

Control.Cursor := crDefault;

end;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

if Shift=[ssLeft] then

begin

ReleaseCapture;

Control.Perform(WM_SYSCOMMAND, SC_MANIPULATE, 0);

end;

end;

procedure TForm1.Edit1MouseMove(Sender: TObject; Shift: TShiftState; X,

Y: Integer);

begin

ManipulateControl((Sender as TControl), Shift, X, Y, 9);

edit1.Hint:='Edit1:TEdit'+chr(13)+'Origin:'+IntToStr(edit1.Top)+','

+IntToStr(edit1.Left)+';'+'Size:'+IntToStr(edit1.Width)+IntToStr(edit1.Height)+chr(13)+'Tab Stop:Ture;Order:0';

if s=true then

begin

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+(edit1.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+(edit1.Height div 2)-3;

panel7.Left:=edit1.Left+edit1.Width;

panel8.top:=edit1.Top+edit1.Height;

panel8.Left:=edit1.Left+edit1.Width;

end;

end;

procedure TForm1.Edit1MouseDown(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

begin

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+(edit1.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+(edit1.Height div 2)-3;

panel7.Left:=edit1.Left+edit1.Width;

panel8.top:=edit1.Top+edit1.Height;

panel8.Left:=edit1.Left+edit1.Width;

end;

procedure TForm1.Edit1MouseUp(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

begin

if s=true then

begin

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+(edit1.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+(edit1.Height div 2)-3;

panel7.Left:=edit1.Left+edit1.Width;

panel8.top:=edit1.Top+edit1.Height;

panel8.Left:=edit1.Left+edit1.Width;

end;

end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

begin

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;

end;

procedure TForm1.Button1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

begin if a=true then

begin

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;

end;

end;

procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

begin

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;

end;

procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,

Y: Integer);

begin

ManipulateControl((Sender as TControl), Shift, X, Y, 9);

edit1.Hint:='Button1:TButton'+chr(13)+'Origin:'+IntToStr(Button1.Top)+','

+IntToStr(Button1.Left)+';'+'Size:'+IntToStr(Button1.Width)+IntToStr(Button1.Height)+chr(13)+'Tab Stop:Ture;Order:0';

if a=true then

begin

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;

end;

end;

end.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有