🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.winforms.controls.using
Article #202

Re: Component.Dispose(bool) problem

#202
From: Chee Wee Chua (Borland Support)
Date: Wed, 05 Jul 2006 14:35
112 lines
3778 bytes
On Wed, 5 Jul 2006 14:06:04 +0100, "Peter Morris [Droopy eyes software]"
<pete@NO_droopyeyes_SPAM.com> wrote:

>Hi Chee Wee
>
>These are the exact steps, honest :-)
>
>
>1) Create a new Delphi WinForm app (dotnet)
>2) Drop any non-visual component onto the form
>3) Put a break line on the first line of the Dispose method

1. Create a new WinForm application...
2. Copy and update (adjusting the unit name accordingly) the following code into
your WinForm application.
3. Run app, and close app. 'Destroyed' shown. ;o)

unit WinForm3;

interface

uses
  System.Drawing, System.Collections, System.ComponentModel,
  System.Windows.Forms, System.Data, System.IO;

type
  TWinForm3 = class(System.Windows.Forms.Form)
  {$REGION 'Designer Managed Code'}
  strict private
    /// <summary>
    /// Required designer variable.
    /// </summary>
    Components: System.ComponentModel.Container;
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    procedure InitializeComponent;
  {$ENDREGION}
  strict protected
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    procedure Dispose(Disposing: Boolean); override;
  private
    { Private Declarations }
    MyComponent: Component;
  public
    constructor Create;
  end;

  [assembly: RuntimeRequiredAttribute(TypeOf(TWinForm3))]

implementation

{$AUTOBOX ON}

{$REGION 'Windows Form Designer generated code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure TWinForm3.InitializeComponent;
begin
        // 
        // TWinForm3
        // 
        Self.AutoScaleBaseSize := System.Drawing.Size.Create(5, 13);
        Self.ClientSize := System.Drawing.Size.Create(292, 273);
        Self.Name := 'TWinForm3';
        Self.Text := 'WinForm3';
end;
{$ENDREGION}

type
  TMyComponent = class(Component)
  strict protected
    procedure Dispose(disposing: Boolean); override;
  end;

procedure TWinForm3.Dispose(Disposing: Boolean);
begin
  if Disposing then
  begin
    if Components <> nil then
      Components.Dispose();
  end;
  inherited Dispose(Disposing);
end;

constructor TWinForm3.Create;
begin
  inherited Create;
  //
  // Required for Windows Form Designer support
  //
  InitializeComponent;
  //
  // TODO: Add any constructor code after InitializeComponent call
  //
  MyComponent := TMyComponent.Create;
end;

{ TMyComponent }

procedure TMyComponent.Dispose(disposing: Boolean);
begin
  MessageBox.Show('Destroyed!');
  inherited;
end;

end.
Technical Details
Message-ID: <pfjna25aa6vbrm6g4t2400jfp7a63296a2@4ax.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <44ab6a34$1@newsgroups.borland.com> <il0na258mjappn07usvin5sphleob7ege9@4ax.com> <44abb93f$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1eff29,4d562b5bfdb92132
X-Google-Attributes: gid1eff29,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Chee Wee Chua (Borland Support)" <cwchua@borland.com>
Newsgroups: borland.public.delphi.winforms.controls.using
Subject: Re: Component.Dispose(bool) problem
Date: Wed, 05 Jul 2006 22:35:12 +0800
Organization: Borland Support
Message-ID: <pfjna25aa6vbrm6g4t2400jfp7a63296a2@4ax.com>
References: <44ab6a34$1@newsgroups.borland.com> <il0na258mjappn07usvin5sphleob7ege9@4ax.com> <44abb93f$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 3.2/32.830
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 219.74.1.201
X-Trace: newsgroups.borland.com 1152110116 219.74.1.201 (5 Jul 2006 07:35:16 -0700)
Lines: 112
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail