Recent

Author Topic: Extending TSelectDirectoryDialog  (Read 5871 times)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Extending TSelectDirectoryDialog
« on: August 29, 2007, 06:58:04 am »
I'm trying to extend the TSelectDirectoryDialog so it contains TCheckBox inside the dialog. It compiles, but I got AccessViolation at runtime. Here's the code:
Code: [Select]

unit xxx;

...

interface

type
  TMySelectDirectoryDialog = class(TSelectDirectoryDialog)
    CheckRecurse: TCheckBox;
    constructor Create(AOwner: TComponent); override;
  end;

...

implementation

constructor TMySelectDirectoryDialog.Create(AOwner: TComponent);
begin
  Inherited Create(AOWner);
  Title:='Select Folder to Add';
  Options:=[ofPathMustExist,ofViewDetail];
  with CheckRecurse do begin
    Autosize:=true;
    Checked:=false;
    Left:=14;
    Top:=10;
    Caption:='Recurse Subdirectory';
  end;
end;

...

end.

Anyone can help?

arnoldb

  • Jr. Member
  • **
  • Posts: 97
RE: Extending TSelectDirectoryDialog
« Reply #1 on: August 29, 2007, 09:24:17 am »
You'll have to add "CheckRecurse := TCheckbox.Create(AOwner)" in constructor TMySelectDirectoryDialog
You are getting the access violation because the checkbox has not been created.

HTH

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2680
RE: Extending TSelectDirectoryDialog
« Reply #2 on: August 29, 2007, 12:12:59 pm »
Create it with Self and not AOwner
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

 

TinyPortal © 2005-2018