闲言少叙,详见代码!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, ExtCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
oldEditWndProc: Pointer;
hk: HHOOK;
hm: HMENU;
r: TRect;
bSelected: Boolean;
function GetMsgProc(c, w: Integer; l: PMSG): Integer stdcall;
begin
if c=HC_ACTION then
if l^.message=WM_LBUTTONUP then
begin
if l^.hwnd = Form1.Edit1.Handle then
if PtInRect(r, Point(LOWORD(l^.lParam), HIWORD(l^.lParam))) then
begin
OutputDebugString(pchar(format('click: %d,%d,%d,%d------%d,%d',[r.Left,r.Top,r.Right,r.Bottom,LOWORD(l^.lParam), HIWORD(l^.lParam)])));
bSelected :=