Here is a more detailed example of a big Delphi bug.
I suggest everyone try it as much as possible. I hope the discussion about it will be more lively, so as to
It can be of some help to everyone. There are two similar articles in the
http://www.csdn.net/develop/read_article.asp?id=12606
http://www.csdn.net/develop/read_article.asp?id=12525
Below is the example source code, you can freely play with the settings.
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