主题:一个游戏代码
unit MainFrm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TMainForm = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
HandleEdit: TEdit;
ClassEdit: TEdit;
TextEdit: TEdit;
OnTopCheckBox: TCheckBox;
Timer: TTimer;
procedure FormCreate(Sender: TObject);
procedure TimerTimer(Sender: TObject);
procedure OnTopCheckBoxClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.DFM}
function GetWorkAreaRect: TRect;
begin
SystemParametersInfo(SPI_GETWORKAREA, 0, @Result, 0);
end;
procedure SetStayOnTop(Form: TForm; Value: Boolean);
begin
if Value Then
SetWindowPos(Form.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
else
SetWindowPos(Form.Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE);
end;
procedure TMainForm.FormCreate(Sender: TObject);
var
R: TRect;
begin
R := GetWorkAreaRect;
Left := R.Right - Width;
Top := R.Bottom - Height;
SetStayOnTop(Self, True);
end;
procedure TMainForm.TimerTimer(Sender: TObject);
var
Pos: TPoint;
Handle: HWND;
Buf: array[0..1024] of Char;
begin
GetCursorPos(Pos);
Handle := WindowFromPoint(Pos);
HandleEdit.Text := IntToStr(Handle);
GetClassName(Handle, Buf, 1024);
ClassEdit.Text := Buf;
SendMessage(Handle, WM_GETTEXT, 1024, Integer(@Buf));
TextEdit.Text := Buf;
end;
procedure TMainForm.OnTopCheckBoxClick(Sender: TObject);
begin
SetStayOnTop(Self, OnTopCheckBox.Checked);
end;
end.
此帖转自:[url]http://www.programfan.com/team/team.asp?team_id=1133[/url]
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TMainForm = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
HandleEdit: TEdit;
ClassEdit: TEdit;
TextEdit: TEdit;
OnTopCheckBox: TCheckBox;
Timer: TTimer;
procedure FormCreate(Sender: TObject);
procedure TimerTimer(Sender: TObject);
procedure OnTopCheckBoxClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.DFM}
function GetWorkAreaRect: TRect;
begin
SystemParametersInfo(SPI_GETWORKAREA, 0, @Result, 0);
end;
procedure SetStayOnTop(Form: TForm; Value: Boolean);
begin
if Value Then
SetWindowPos(Form.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
else
SetWindowPos(Form.Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE);
end;
procedure TMainForm.FormCreate(Sender: TObject);
var
R: TRect;
begin
R := GetWorkAreaRect;
Left := R.Right - Width;
Top := R.Bottom - Height;
SetStayOnTop(Self, True);
end;
procedure TMainForm.TimerTimer(Sender: TObject);
var
Pos: TPoint;
Handle: HWND;
Buf: array[0..1024] of Char;
begin
GetCursorPos(Pos);
Handle := WindowFromPoint(Pos);
HandleEdit.Text := IntToStr(Handle);
GetClassName(Handle, Buf, 1024);
ClassEdit.Text := Buf;
SendMessage(Handle, WM_GETTEXT, 1024, Integer(@Buf));
TextEdit.Text := Buf;
end;
procedure TMainForm.OnTopCheckBoxClick(Sender: TObject);
begin
SetStayOnTop(Self, OnTopCheckBox.Checked);
end;
end.
此帖转自:[url]http://www.programfan.com/team/team.asp?team_id=1133[/url]