请提示:如何获得 在 无鼠标左键单击事件的控件上 单击鼠标左键处的鼠标坐标。(下含自写错误代码)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, OleCtrls, SHDocVw, ExtCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Timer1: TTimer;
Panel1: TPanel;
procedure CMMouseEnter(var Msg: TMessage); message WM_LBUTTONDOWN;
private
{ Private declarations }
public
{ Public declarations }
end;
type
TPanel1= class(TPanel)
procedure cCMMouseEnter(var Msg: TMessage); message WM_LBUTTONDOWN;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure Tform1.CMMouseEnter(var Msg: TMessage);
var
anObject : TObject;
point:TPoint;
m:string;
begin
anObject := TObject(Msg.lParam);
if anObject <> nil then
begin
GetCursorPos(point);
m:='x:'+inttostr(point.X )+','+'y:'+inttostr(point.Y );
showmessage(m);
end;
end; /////////鼠标左键单击form1,成功获得showmessage提示。
procedure TPanel1.cCMMouseEnter(var Msg: TMessage);
var
anObject1 : TObject;
point1:TPoint;
m1:string;
begin
anObject1 := TObject(Msg.lParam);
if anObject1 <> nil then
begin
GetCursorPos(point1);
m1:='x:'+inttostr(point1.X )+','+'y:'+inttostr(point1.Y );
showmessage(m1);
end; //////////鼠标在控件 panel 上单击左键,不能获得showmessage提示。
end;
end.
//////////////不一定是panel,可以是任意一个没有鼠标单击事件的控件////////////////////////
//1.怎么获取鼠标在控件(没有鼠标单击左键事件)上单击左键时的鼠标坐标?
//2.我的思路是否争取,应该怎样考虑?