M
Miros
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
const
MaxStackUse = $10000;
label
stacksizetolow;
var
dwStackLow: DWord;
function FillBlockArea(X, Y: Integer):Boolean;
label ret;
begin
Result := True;
asm
cmp esp, dwStackLow
jbe ret
end;
if (X < 0) or (X > PaintBox1.Width - 1) then Exit;
if (Y < 0) or (Y > PaintBox1.Height-1) then Exit;
if PaintBox1.Canvas.Pixels[X, Y] = clWhite then Exit;
PaintBox1.Canvas.Pixels[X, Y] := clWhite;
Result := FillBlockArea(X, Y - 1)
and FillBlockArea(X + 1, Y - 1)
and FillBlockArea(X + 1, Y)
and FillBlockArea(X + 1, Y + 1)
and FillBlockArea(X, Y + 1)
and FillBlockArea(X - 1, Y + 1)
and FillBlockArea(X - 1, Y)
and FillBlockArea(X - 1, Y - 1);
Exit;
ret:
Application.MessageBox('由于已经达到预定的函数最大堆栈消耗,填充操作未能一次完成,请再次进行操作!', nil, MB_ICONSTOP);
Result := False;
end;
begin
asm
push eax
mov eax, esp
sub eax, MaxStackUse
mov dwStackLow, eax
pop eax
jbe stacksizetolow
end;
PaintBox1.Canvas.Brush.Color := clBlack;
PaintBox1.Canvas.FillRect(PaintBox1.ClientRect);
FillBlockArea(0, 0);
Exit;
stacksizetolow:
Application.MessageBox('栈空间不足,无法完成此操作!', nil, MB_ICONSTOP);
end;
我好象是没写错,但是delphi的确把FillBlockArea 中dwStackLow的地址编译错了在delphi7,delphi2006中都是同样的结果.大家可以把代码copy了亲自调试看看
const
MaxStackUse = $10000;
label
stacksizetolow;
var
dwStackLow: DWord;
function FillBlockArea(X, Y: Integer):Boolean;
label ret;
begin
Result := True;
asm
cmp esp, dwStackLow
jbe ret
end;
if (X < 0) or (X > PaintBox1.Width - 1) then Exit;
if (Y < 0) or (Y > PaintBox1.Height-1) then Exit;
if PaintBox1.Canvas.Pixels[X, Y] = clWhite then Exit;
PaintBox1.Canvas.Pixels[X, Y] := clWhite;
Result := FillBlockArea(X, Y - 1)
and FillBlockArea(X + 1, Y - 1)
and FillBlockArea(X + 1, Y)
and FillBlockArea(X + 1, Y + 1)
and FillBlockArea(X, Y + 1)
and FillBlockArea(X - 1, Y + 1)
and FillBlockArea(X - 1, Y)
and FillBlockArea(X - 1, Y - 1);
Exit;
ret:
Application.MessageBox('由于已经达到预定的函数最大堆栈消耗,填充操作未能一次完成,请再次进行操作!', nil, MB_ICONSTOP);
Result := False;
end;
begin
asm
push eax
mov eax, esp
sub eax, MaxStackUse
mov dwStackLow, eax
pop eax
jbe stacksizetolow
end;
PaintBox1.Canvas.Brush.Color := clBlack;
PaintBox1.Canvas.FillRect(PaintBox1.ClientRect);
FillBlockArea(0, 0);
Exit;
stacksizetolow:
Application.MessageBox('栈空间不足,无法完成此操作!', nil, MB_ICONSTOP);
end;
我好象是没写错,但是delphi的确把FillBlockArea 中dwStackLow的地址编译错了在delphi7,delphi2006中都是同样的结果.大家可以把代码copy了亲自调试看看