以下是一個關於Delphi大Bug的更詳盡的例子。
我建議大家盡可以好好去試試。關於它的討論,希望熱烈一點,藉此,
能對大家多少有些幫助。兩外兩篇類似的文章在
http://www.csdn.net/develop/read_article.asp?id=12606
http://www.csdn.net/develop/read_article.asp?id=12525
以下是範例原始碼,其中的設置,您盡可以自由發揮。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, ExtCtrls, jpeg;
type
TForm1 = class(TForm)
Button1: TButton;
MainMenu1: TMainMenu;
xiangya1: TMenuItem;
Image1: TImage;
Shape1: TShape;
PRocedure Button1Click(Sender: TObject);
procedure xiangya1Click(Sender: TObject);
procedure Image1Click(Sender: TObject);
procedure Shape1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
type
TxObject = class
destructor Destroy;override;
end;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
x: TxObject;
begin
x := TxObject.Create;
ShowMessage('xiangya');
x.Free;
end;
{ TxObject }
destructor TxObject.Destroy;
begin
MessageBox(0, PChar('TxObject'),'Free',MB_OK);
inherited;
end;
procedure TForm1.xiangya1Click(Sender: TObject);
var
x: TxObject;
begin
x := TxObject.Create;
ShowMessage('xiangya');
x.Free;
end;
procedure TForm1.Image1Click(Sender: TObject);
var
x: TxObject;
begin
// x := TxObject.Create;
// ShowMessage('xiangya');
x.Free;
end;
procedure TForm1.Shape1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
xx: TxObject;
begin
// xx := TxObject.Create;
ShowMessage('xiangya');
xx.Free;
end;
end