关于Delphi大Bug的更详细的例子

类别:Delphi 点击:0 评论:0 推荐:

下面是一个关于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.

本文地址:http://com.8s8s.com/it/it5667.htm