unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Grids, ComCtrls;
type
TCursorOper = class(TForm)
Timer1: TTimer;
Button2: TButton;
Panel1: TPanel;
ControlBar1: TControlBar;
Panel2: TPanel;
GroupBox2: TGroupBox;
GroupBox1: TGroupBox;
CursorStatus: TStatusBar;
Panel3: TPanel;
Label8: TLabel;
Button1: TButton;
Edit4: TEdit;
ANXinXiList: TListView;
Button4: TButton;
Panel4: TPanel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
label1: TLabel;
S: TLabel;
ShuBiao_X: TLabel;
ShuBiao_Y: TLabel;
JuBing: TEdit;
NeiRong: TEdit;
LeiMing: TEdit;
Panel5: TPanel;
Panel6: TPanel;
anEnabled: TCheckBox;
anShow: TCheckBox;
CheckBox1: TCheckBox;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure ANXinXiListClick(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
private
{ Private declarations }
CheckHand:Integer;
i:Integer;
procedure GetCurrsorStatus(var Msg: TMessage) ;message WM_LBUTTONDOWN;
procedure AddANXinXi(JuBing,NeiRong,LeiMing:String);
public
{ Public declarations }
end;
var
CursorOper: TCursorOper;
implementation
{$R *.dfm}
//------------------------------------------------------------------------------
function WindowEnabled(aHandle: HWND; aLparam: LPARAM): boolean; stdcall;
begin
if Not IsWindowEnabled(aHandle) then
begin
EnableWindow(aHandle,true);
end;
Result:=True;
end;
//------------------------------------------------------------------------------
function WindowDisEnabled(aHandle: HWND; aLparam: LPARAM): boolean; stdcall;
begin
if IsWindowEnabled(aHandle) then
begin
EnableWindow(aHandle,False);
end;
Result:=True;
end;
//------------------------------------------------------------------------------
function WindowShow(aHandle: HWND; aLparam: LPARAM): boolean; stdcall;
begin
ShowWindow(aHandle,SW_RESTORE);
Result:=True;
end;
function WindowHide(aHandle: HWND; aLparam: LPARAM): boolean; stdcall;
begin
ShowWindow(aHandle,SW_HIDE);
Result:=True;
end;
//------------------------------------------------------------------------------
function GetWindowInfo():Boolean;
begin
Result:=True;
end;
//------------------------------------------------------------------------------
procedure TCursorOper.AddANXinXi(JuBing, NeiRong, LeiMing: String);
var
InflList:TListItem;
JBCount:Integer;
begin
try
for JBCount:=0 to ANXinXiList.Items.Count-1 do
begin
if ANXinXiList.Items.Item[JBCount].Caption=JuBing then Exit;
end;
InflList:=ANXinXiList.Items.Add;
InflList.Caption:=JuBing;
InflList.SubItems.Add(NeiRong);
InflList.SubItems.Add(LeiMing);
except
end;
end;
procedure TCursorOper.Timer1Timer(Sender: TObject);
var
p:TPoint;
hand:hwnd;
str:Array[0..255] of char;
strclass:Array[0..255] of char;
begin
timer1.Enabled:=false;
GetCursorPos(p);
if (p.X>=CursorOper.Left) and (p.X<=CursorOper.Left+CursorOper.Width)
and (p.Y>=CursorOper.Top) and (p.Y<=CursorOper.Top+CursorOper.Height) then
begin
CursorStatus.Panels[0].Text:='在本窗体内';
end else
begin
CursorStatus.Panels[0].Text:='在本窗体外';
hand:=WindowFromPoint(p);
if anEnabled.Checked then EnumChildWindows(hand, @WindowEnabled, 0);
if Not anEnabled.Checked then EnumChildWindows(hand, @WindowDisEnabled, 0);
if anShow.Checked then EnumChildWindows(hand, @WindowShow, 0);
if Not anShow.Checked then EnumChildWindows(hand, @WindowHide, 0);
getwindowtext(hand,@str,length(str));
getclassname(hand,@strclass,length(str));
if CheckHand=hand then
begin
if i>=15 then
begin
AddANXinXi(inttostr(hand),str,strclass);
i:=0;
end else
begin
i:=i+1;
end;
end;
JuBing.Text:= inttostr(hand);
NeiRong.Text:=str;
LeiMing.Text:=strclass;
ShuBiao_X.Caption:=IntToStr(p.X);
ShuBiao_Y.Caption:=IntToStr(p.Y);
CheckHand:=hand;
end;
timer1.Enabled:=true;
end;
procedure TCursorOper.Button1Click(Sender: TObject);
begin
if edit4.Text<>'' then showwindow(strtoint(edit4.Text),sw_hide);
end;
procedure TCursorOper.GetCurrsorStatus(var Msg: Tmessage);
begin
//sendmessage(StrToInt(Edit1.Text),SW_RESTORE,0,0);
//if anHide.Checked then showwindow(strtoint(edit1.Text),sw_hide);
end;
procedure TCursorOper.ANXinXiListClick(Sender: TObject);
begin
if ANXinXiList.ItemIndex>=0 then
edit4.Text:=ANXinXiList.Items.Item[ANXinXiList.ItemIndex].Caption;
end;
procedure TCursorOper.Button4Click(Sender: TObject);
begin
if edit4.Text<>'' then
showwindow(strtoint(edit4.Text),SW_RESTORE);
end;
procedure TCursorOper.CheckBox1Click(Sender: TObject);
begin
setwindowlong(Handle,GWL_STYLE,sw_show);
end;
end.