2个回答
展开全部
您可以这样写:(D7下已经通过了)
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
strpos:string; //定义整形变量
begin
strpos:=format('X=%3d, Y=%3d',[x,y]); //获取鼠标指针的当前坐标
statusbar1.panels[0].text:=strpos; //输出鼠标指针的当前坐标
Edit1.Text := intToStr(x);
Edit2.Text := intToStr(y);
end;
窗体unit1全部源码为:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
StatusBar1: TStatusBar;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
public
end;
var
Form1: TForm1;
implementation
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
strpos:string; //定义整形变量
begin
strpos:=format('X=%3d, Y=%3d',[x,y]); //获取鼠标指针的当前坐标
statusbar1.panels[0].text:=strpos; //输出鼠标指针的当前坐标
Edit1.Text := intToStr(x);
Edit2.Text := intToStr(y);
end;
end.
------------------------------------------------
窗体上定义2个Edit组件,分别叫edit1和edit2,有定义一个statusbar组件叫statusbar1,对statusbar1进行编辑,起码有一个元素panels[0],其width=150,这些是基本条件,你早就知道了。
按照以上做法就可以在 edit1上显示x值,edit2上显示y值,在状态条上显示x和y值
-----------------------------------------------
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
strpos:string; //定义整形变量
begin
strpos:=format('X=%3d, Y=%3d',[x,y]); //获取鼠标指针的当前坐标
statusbar1.panels[0].text:=strpos; //输出鼠标指针的当前坐标
Edit1.Text := intToStr(x);
Edit2.Text := intToStr(y);
end;
窗体unit1全部源码为:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
StatusBar1: TStatusBar;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
public
end;
var
Form1: TForm1;
implementation
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
strpos:string; //定义整形变量
begin
strpos:=format('X=%3d, Y=%3d',[x,y]); //获取鼠标指针的当前坐标
statusbar1.panels[0].text:=strpos; //输出鼠标指针的当前坐标
Edit1.Text := intToStr(x);
Edit2.Text := intToStr(y);
end;
end.
------------------------------------------------
窗体上定义2个Edit组件,分别叫edit1和edit2,有定义一个statusbar组件叫statusbar1,对statusbar1进行编辑,起码有一个元素panels[0],其width=150,这些是基本条件,你早就知道了。
按照以上做法就可以在 edit1上显示x值,edit2上显示y值,在状态条上显示x和y值
-----------------------------------------------
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询