如何算出任何两坐标点之间的坐标呢?如算出点A(200,343)与点B(599,121)之间的每点坐标呢?对了,有可能坐标是负数哟.
解决方案 »
- FocusMe介绍 一个推荐引擎 欢迎大家前来测试
- ■撤消■jinjazz (近身剪(充电中...)) 为 Delphi版大版主
- 怎样实现关自动关闭其他程序的弹出窗口???
- 用Delphi编写的程序能不安装跨平台运行吗?即所谓绿色软件。另外,想请教一下,如何指定ado链接数据库的相对路径?
- 高手,都来谈谈,在定义ACTIVE的接口时,应该注意哪些?(包括参数类型设置、返回值类型等等)
- 静态数组的char 与 动态数组 的char 如何进行“互相”转换?
- 如何获取当前屏幕的长和宽是800*600还是1024*768?
- var MyReg: TRegistry;为什么有错,
- 三层C/S的问题?
- 我已经把整个FORM用图像显示为主窗体,但是没办法实现单击某一部分实现一种功能,请帮忙!!!
- 在 delphi 中如何控制 excel 打印整个工作簿
- 一段添加记录到数据库的代码,请大家帮我看看问题出在那了?{因小弟分散完,抱歉了!}
我用过windows消息记录移动鼠标指针坐标,获得的结果与与MouseMove事件没有多大区别.所以还是不能处理.liangqingzhi:
谢谢你的提示:关于你说的问题,我的意思,就是获得坐标点的x,y是整数型.
添加三个Button加一个Edit,然后双击添加三个Button的Click事件与Form的OnCreate事件就可以看到效果了。
unit Unit1;interface uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls; type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; EventArr:array[0..1000]of EVENTMSG;
EventLog:Integer;
PlayLog:Integer;
hHook,hPlay:Integer;
recOK:Integer;
canPlay:Integer;
bDelay:Bool;
implementation {$R *.DFM}
Function PlayProc(iCode:Integer;wParam:wParam;lParam:lParam):LRESULT;stdcall;
begin
canPlay:=1;
Result:=0;
if iCode < 0 then //必须将消息传递到消息链的下一个接受单元
Result := CallNextHookEx(hPlay,iCode,wParam,lParam)
else if iCode = HC_SYSMODALON then
canPlay:=0
else if iCode = HC_SYSMODALOFF then
canPlay:=1
else if ((canPlay =1 )and(iCode=HC_GETNEXT)) then begin
if bDelay then begin
bDelay:=False;
Result:=50;
end;
pEventMSG(lParam)^:=EventArr[PlayLog];
end
else if ((canPlay = 1)and(iCode = HC_SKIP))then begin
bDelay := True;
PlayLog:=PlayLog+1;
end;
if PlayLog>=EventLog then begin
UNHookWindowsHookEx(hPlay);
end;
end; function HookProc(iCode:Integer;wParam:wParam;lParam:lParam):LRESULT;stdcall;
begin
recOK:=1;
Result:=0; if iCode < 0 then
Result := CallNextHookEx(hHook,iCode,wParam,lParam)
else if iCode = HC_SYSMODALON then
recOK:=0
else if iCode = HC_SYSMODALOFF then
recOK:=1
else if ((recOK>0) and (iCode = HC_ACTION)) then begin
EventArr[EventLog]:=pEventMSG(lParam)^;
EventLog:=EventLog+1; if EventLog>=1000 then begin
UnHookWindowsHookEx(hHook);
end;
end;
end; procedure TForm1.FormCreate(Sender: TObject);
begin
Button1.Caption:='纪录';
Button2.Caption:='停止';
Button3.Caption:='回放';
Button2.Enabled:=False;
Button3.Enabled:=False;
end; procedure TForm1.Button1Click(Sender: TObject);
begin
EventLog:=0;
//建立键盘鼠标操作消息纪录链
hHook:=SetwindowsHookEx(WH_JOURNALRECORD,HookProc,HInstance,0);
Button2.Enabled:=True;
Button1.Enabled:=False;
end; procedure TForm1.Button2Click(Sender: TObject);
begin
UnHookWindowsHookEx(hHook);
hHook:=0; Button1.Enabled:=True;
Button2.Enabled:=False;
Button3.Enabled:=True;
end; procedure TForm1.Button3Click(Sender: TObject);
begin
PlayLog:=0;
//建立键盘鼠标操作消息纪录回放链
hPlay:=SetwindowsHookEx(WH_JOURNALPLAYBACK,PlayProc,
HInstance,0); Button3.Enabled:=False;
end;
end.
points:string;
procedure LineDDAProc(x:Integer;y:Integer;lpData:LParam);stdcall;
begin
points:=points+'('+IntToStr(x)+','+IntToStr(y)+') ';end;procedure TForm1.Button1Click(Sender: TObject);
begin
points:='';
LineDDA(200,343,599,121,@LineDDAProc,0);
ShowMessage(points);
end;