unit ForWinmineU;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Grids, ComCtrls;
type
TForm1 = class(TForm)
btnStart: TButton;
RadioGroup1: TRadioGroup;
Button4: TButton;
StringGrid1: TStringGrid;
btnContinue: TButton;
CheckBox1: TCheckBox;
Label1: TLabel;
UpDown1: TUpDown;
Edit1: TEdit;
CheckBox2: TCheckBox;
btnCheat: TButton;
procedure btnStartClick(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button4Click(Sender: TObject);
procedure btnContinueClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure btnCheatClick(Sender: TObject);
private
{ Private declarations }
procedure OnHotKey(var msg: TMessage); message WM_HOTKEY;
public
{ Public declarations }
end;
type
TCell = record
Value: char;
bNeed: boolean;
end;
const
dx: array[1..8] of short = (-1, 0, 1, 1, 1, 0, -1, -1);
dy: array[1..8] of short = (-1, -1, -1, 0, 1, 1, 1, 0);
var
Form1: TForm1;
hSweep: THandle;
mSweep: HMenu;
dcSweep: HDC;
atomSweep: ATOM;
ColNum, RowNum: short;
Cells: array[0..31, 0..17] of TCell;
implementation
{$R *.dfm}
//0..8表示数字,9表示没有打开,*表示雷,F表示标记
function GetCellInfo(x, y: short): char;
var
cl0, cl1: DWORD;
begin
{0c..colnum*10+0b}{1..colnum}
{37..rownum*10+36}{1..rownum}
if (x<1)or(y<1)or(x>ColNum)or(y>RowNum) then
begin
Result := '0';
Exit;
end;
cl0 := GetPixel(dcSweep, (x-1)*16+$C+1, (y-1)*16+$37+1);
if cl0=$00FFFFFF then
begin
cl1 := GetPixel(dcSweep, (x-1)*16+$C+8, (y-1)*16+$37+8);
case cl1 of
$00C6C3C6: Result := '9';
$00000000: Result := 'F';
end;
Exit;
end;
cl1 := GetPixel(dcSweep, (x-1)*16+$C+8, (y-1)*16+$37+8);
// SetPixel(dcSweep, (x-1)*16+$C, (y-1)*16+$37, clRed);
// Ellipse(dcSweep, (x-1)*16+$C-2, (y-1)*16+$37-2, (x-1)*16+$C+2, (y-1)*16+$37+2);
case cl1 of
$00C6C3C6:
begin
cl0 := GetPixel(dcSweep, (x-1)*16+$C+10, (y-1)*16+$37+10);
if cl0=0 then
Result := '7'
else
Result := '0';
end;
$00FF0000: Result := '1';
$00008200: Result := '2';
$000000FF: Result := '3';
$00840000: Result := '4';
$00000084: Result := '5';
$00848200: Result := '6';
$00848284: Result := '8';
$00000000: Result := '*';
else
Result := '7';
end;
end;
//模拟左键点击
procedure ClickIt(x, y: short);
begin
if hSweep<=0 then
Exit;
SendMessage(hSweep, WM_LB
UTTONDOWN, 0, MAKELONG((x-1)*16+$C, (y-1)*16+$37));
SendMessage(hSweep, WM_LBUTTONUP, 0, MAKELONG((x-1)*16+$C, (y-1)*16+$37));
end;
//模拟右键标旗子
procedure FlagIt(x, y: short);
begin
if hSweep<=0 then
Exit;
SendMessage(hSweep, WM_RBUTTONDOWN, 0, MAKELONG((x-1)*16+$C, (y-1)*16+$37));
end;
//模拟左右键双击
procedure DbClickIt(x, y: short);
begin
if hSweep<=0 then
Exit;
SendMessage(hSweep, WM_LBUTTONDOWN, 0, MAKELONG((x-1)*16+$C, (y-1)*16+$37));
SendMessage(hSweep, WM_RBUTTONDOWN, 0, MAKELONG((x-1)*16+$C, (y-1)*16+$37));
SendMessage(hSweep, WM_LBUTTONUP, 0, MAKELONG((x-1)*16+$C, (y-1)*16+$37));
end;
procedure TForm1.OnHotKey(var msg: TMessage);
begin
if (msg.LParamHi=$58)and(msg.LParamLo=MOD_CONTROL or MOD_ALT) then
begin
if hSweep<=0 then
Exit;
if not btnContinue.Enabled then
Exit;
btnContinueClick(nil);
end;
end;
procedure TForm1.FormCreate(Sender: TObjec