Recent

Author Topic: visual inheritance, ancestor class not found  (Read 12623 times)

acakadut

  • New Member
  • *
  • Posts: 18
visual inheritance, ancestor class not found
« on: December 09, 2007, 02:35:59 pm »
hi all,

can someone help me what's going on with this...

ancestor class not found, is it bug or something wrong with me ?, but it's working when create the descendant form at the first time.

(http://i253.photobucket.com/albums/hh79/acakadut/testinheritance.gif)

unit ancestor
Code: [Select]
unit Unit2;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ComCtrls;

type

  { TForm2 }

  TForm2 = class(TForm)
    ImageList1: TImageList;
    pcclass: TPageControl;
    tsclass: TTabSheet;
    tbclass: TToolBar;
    btnone: TToolButton;
    btntwo: TToolButton;
    btnthree: TToolButton;
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form2: TForm2;

implementation


initialization
  {$I unit2.lrs}

end.                

form ancestor
Code: [Select]
object Form2: TForm2
  Left = 362
  Height = 300
  Top = 267
  Width = 400
  HorzScrollBar.Page = 399
  VertScrollBar.Page = 299
  Caption = 'Form2'
  ClientHeight = 300
  ClientWidth = 400
  object tbclass: TToolBar
    Height = 26
    Width = 400
    Caption = 'tbclass'
    EdgeBorders = [ebTop, ebBottom]
    TabOrder = 0
    object btnone: TToolButton
      Left = 1
      Top = 2
      Caption = 'btnone'
    end
    object btntwo: TToolButton
      Left = 24
      Top = 2
      Caption = 'btntwo'
    end
    object btnthree: TToolButton
      Left = 47
      Top = 2
      Caption = 'btnthree'
    end
  end
  object pcclass: TPageControl
    Height = 274
    Top = 26
    Width = 400
    ActivePage = tsclass
    Align = alClient
    TabIndex = 0
    TabOrder = 1
    object tsclass: TTabSheet
      Caption = 'tsclass'
    end
  end
  object ImageList1: TImageList
    left = 227
    top = 68
  end
end


unit descendant
Code: [Select]
unit Unit3;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
  StdCtrls, ExtCtrls, CheckLst, Grids, ComCtrls, Unit2 ;

type

  { TForm3 }

  TForm3 = class(TForm2)
    CheckListBox1: TCheckListBox;
    LabeledEdit1: TLabeledEdit;
    StaticText1: TStaticText;
    StringGrid1: TStringGrid;
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form3: TForm3;

implementation


initialization
  {$I unit3.lrs}

end.

form descendant
Code: [Select]
inherited Form3: TForm2
  Caption = 'Form3'
  inherited tbclass: TToolBar
    inherited btnone: TToolButton
    end
    inherited btntwo: TToolButton
    end
    inherited btnthree: TToolButton
    end
  end
  inherited pcclass: TPageControl
    inherited tsclass: TTabSheet
      ClientHeight = 248
      ClientWidth = 392
      object StaticText1: TStaticText
        Left = 81
        Height = 17
        Top = 66
        Width = 65
        Caption = 'StaticText1'
      end
      object LabeledEdit1: TLabeledEdit
        Left = 88
        Height = 23
        Top = 129
        Width = 80
        EditLabel.Left = 88
        EditLabel.Height = 14
        EditLabel.Top = 109
        EditLabel.Width = 62
        EditLabel.Caption = 'LabeledEdit1'
        EditLabel.ParentColor = False
        ParentColor = False
        TabOrder = 0
      end
      object CheckListBox1: TCheckListBox
        Left = 260
        Height = 80
        Top = 152
        Width = 100
        TabOrder = 1
      end
      object StringGrid1: TStringGrid
        Left = 168
        Height = 100
        Top = 56
        Width = 200
        ColCount = 5
        FixedColor = clBtnFace
        Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goSmoothScroll]
        RowCount = 5
        ScrollBars = ssAutoBoth
        TabOrder = 2
        TabStop = True
      end
    end
  end
  inherited ImageList1: TImageList
  end
end


using 0.9.24 on WinXP

TIA

san

acakadut

  • New Member
  • *
  • Posts: 18
RE: visual inheritance, ancestor class not found
« Reply #1 on: December 10, 2007, 09:29:01 am »
somebody ? :shock: , no one know what's the problem ? :roll:

duncanparsons

  • Jr. Member
  • **
  • Posts: 83
RE: visual inheritance, ancestor class not found
« Reply #2 on: December 10, 2007, 11:36:00 am »
don't know if it helps, but with Delphi, sometimes using descendant forms only work properly when the ancestor is open .. I think it's todo with search paths.

Try opening the ancestor file first, then open the descendant - might not work, but worth a try!

DSP

acakadut

  • New Member
  • *
  • Posts: 18
RE: visual inheritance, ancestor class not found
« Reply #3 on: December 10, 2007, 12:32:31 pm »
hi duncan,

i had try opening ancestor unit first, but it's not working too...

san

gerardus

  • Jr. Member
  • **
  • Posts: 93
RE: visual inheritance, ancestor class not found
« Reply #4 on: December 10, 2007, 12:57:04 pm »
I think that the definition of TForm3 on the .lfm file should be


Code: [Select]
inherited Form3: TForm3
  Caption = 'Form3'


and not

Code: [Select]
inherited Form3: TForm2
  Caption = 'Form3'



Regards,

Gerard.

acakadut

  • New Member
  • *
  • Posts: 18
Re: RE: visual inheritance, ancestor class not found
« Reply #5 on: December 10, 2007, 01:56:06 pm »
Quote from: "gerardus"
I think that the definition of TForm3 on the .lfm file should be


Code: [Select]
inherited Form3: TForm2
  Caption = 'Form3'


and not

Code: [Select]
inherited Form3: TForm3
  Caption = 'Form3'



Regards,

Gerard.


hi gerard,

changed it to
Code: [Select]
inherited Form3: TForm3
  Caption = 'Form3'


doesn't work too...

clean, build all and doesnt work too..


i try to make new testing project to make sure, maybe the first time has been corrupt... and this's the code...

unit ancestor
Code: [Select]

unit Unit2;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ComCtrls;

type

  { TForm2 }

  TForm2 = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ToolButton10: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    ToolButton9: TToolButton;
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form2: TForm2;

implementation

{ TForm2 }

procedure TForm2.FormCreate(Sender: TObject);
begin

end;

initialization
  {$I unit2.lrs}

end.


form ancestor
Code: [Select]
object Form2: TForm2
  Left = 290
  Height = 300
  Top = 190
  Width = 400
  HorzScrollBar.Page = 399
  VertScrollBar.Page = 299
  Caption = 'Form2'
  ClientHeight = 300
  ClientWidth = 400
  OnCreate = FormCreate
  object ToolBar1: TToolBar
    Height = 26
    Width = 400
    Caption = 'ToolBar1'
    TabOrder = 0
    object ToolButton1: TToolButton
      Left = 1
      Top = 2
      Caption = 'ToolButton1'
    end
    object ToolButton2: TToolButton
      Left = 24
      Top = 2
      Caption = 'ToolButton2'
    end
    object ToolButton3: TToolButton
      Left = 47
      Top = 2
      Caption = 'ToolButton3'
    end
    object ToolButton4: TToolButton
      Left = 70
      Top = 2
      Width = 23
      Caption = 'ToolButton4'
      Style = tbsSeparator
    end
    object ToolButton5: TToolButton
      Left = 93
      Top = 2
      Caption = 'ToolButton5'
    end
    object ToolButton6: TToolButton
      Left = 116
      Top = 2
      Caption = 'ToolButton6'
    end
    object ToolButton7: TToolButton
      Left = 139
      Top = 2
      Caption = 'ToolButton7'
    end
    object ToolButton8: TToolButton
      Left = 162
      Top = 2
      Width = 23
      Caption = 'ToolButton8'
      Style = tbsSeparator
    end
    object ToolButton9: TToolButton
      Left = 185
      Top = 2
      Caption = 'ToolButton9'
    end
    object ToolButton10: TToolButton
      Left = 208
      Top = 2
      Caption = 'ToolButton10'
    end
  end
  object PageControl1: TPageControl
    Height = 274
    Top = 26
    Width = 400
    ActivePage = TabSheet1
    Align = alClient
    TabIndex = 0
    TabOrder = 1
    object TabSheet1: TTabSheet
      Caption = 'TabSheet1'
    end
  end
end


lrs ancestor
Code: [Select]
{ This is an automatically generated lazarus resource file }

LazarusResources.Add('TForm2','FORMDATA',[
  'TPF0'#6'TForm2'#5'Form2'#4'Left'#3'"'#1#6'Height'#3','#1#3'Top'#3#190#0#5'Wi'
  +'dth'#3#144#1#18'HorzScrollBar.Page'#3#143#1#18'VertScrollBar.Page'#3'+'#1#7
  +'Caption'#6#5'Form2'#12'ClientHeight'#3','#1#11'ClientWidth'#3#144#1#8'OnCre'
  +'ate'#7#10'FormCreate'#0#8'TToolBar'#8'ToolBar1'#6'Height'#2#26#5'Width'#3
  +#144#1#7'Caption'#6#8'ToolBar1'#8'TabOrder'#2#0#0#11'TToolButton'#11'ToolBut'
  +'ton1'#4'Left'#2#1#3'Top'#2#2#7'Caption'#6#11'ToolButton1'#0#0#11'TToolButto'
  +'n'#11'ToolButton2'#4'Left'#2#24#3'Top'#2#2#7'Caption'#6#11'ToolButton2'#0#0
  +#11'TToolButton'#11'ToolButton3'#4'Left'#2'/'#3'Top'#2#2#7'Caption'#6#11'Too'
  +'lButton3'#0#0#11'TToolButton'#11'ToolButton4'#4'Left'#2'F'#3'Top'#2#2#5'Wid'
  +'th'#2#23#7'Caption'#6#11'ToolButton4'#5'Style'#7#12'tbsSeparator'#0#0#11'TT'
  +'oolButton'#11'ToolButton5'#4'Left'#2']'#3'Top'#2#2#7'Caption'#6#11'ToolButt'
  +'on5'#0#0#11'TToolButton'#11'ToolButton6'#4'Left'#2't'#3'Top'#2#2#7'Caption'
  +#6#11'ToolButton6'#0#0#11'TToolButton'#11'ToolButton7'#4'Left'#3#139#0#3'Top'
  +#2#2#7'Caption'#6#11'ToolButton7'#0#0#11'TToolButton'#11'ToolButton8'#4'Left'
  +#3#162#0#3'Top'#2#2#5'Width'#2#23#7'Caption'#6#11'ToolButton8'#5'Style'#7#12
  +'tbsSeparator'#0#0#11'TToolButton'#11'ToolButton9'#4'Left'#3#185#0#3'Top'#2#2
  +#7'Caption'#6#11'ToolButton9'#0#0#11'TToolButton'#12'ToolButton10'#4'Left'#3
  +#208#0#3'Top'#2#2#7'Caption'#6#12'ToolButton10'#0#0#0#12'TPageControl'#12'Pa'
  +'geControl1'#6'Height'#3#18#1#3'Top'#2#26#5'Width'#3#144#1#10'ActivePage'#7#9
  +'TabSheet1'#5'Align'#7#8'alClient'#8'TabIndex'#2#0#8'TabOrder'#2#1#0#9'TTabS'
  +'heet'#9'TabSheet1'#7'Caption'#6#9'TabSheet1'#0#0#0#0
]);


unit descendant
Code: [Select]

unit Unit3;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Unit2;

type
  TForm3 = class(TForm2)
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form3: TForm3;

implementation

initialization
  {$I unit3.lrs}

end.  

form descendant
Code: [Select]

inherited Form3: TForm3
  Caption = 'Form3'
  inherited ToolBar1: TToolBar
    inherited ToolButton1: TToolButton
    end
    inherited ToolButton2: TToolButton
    end
    inherited ToolButton3: TToolButton
    end
    inherited ToolButton4: TToolButton
    end
    inherited ToolButton5: TToolButton
    end
    inherited ToolButton6: TToolButton
    end
    inherited ToolButton7: TToolButton
    end
    inherited ToolButton8: TToolButton
    end
    inherited ToolButton9: TToolButton
    end
    inherited ToolButton10: TToolButton
    end
  end
  inherited PageControl1: TPageControl
    inherited TabSheet1: TTabSheet
    end
  end
end


Code: [Select]
{ This is an automatically generated lazarus resource file }

LazarusResources.Add('TForm3','FORMDATA',[
  'TPF0'#241#6'TForm3'#5'Form3'#7'Caption'#6#5'Form3'#0#241#8'TToolBar'#8'ToolB'
  +'ar1'#0#241#11'TToolButton'#11'ToolButton1'#0#0#241#11'TToolButton'#11'ToolB'
  +'utton2'#0#0#241#11'TToolButton'#11'ToolButton3'#0#0#241#11'TToolButton'#11
  +'ToolButton4'#0#0#241#11'TToolButton'#11'ToolButton5'#0#0#241#11'TToolButton'
  +#11'ToolButton6'#0#0#241#11'TToolButton'#11'ToolButton7'#0#0#241#11'TToolBut'
  +'ton'#11'ToolButton8'#0#0#241#11'TToolButton'#11'ToolButton9'#0#0#241#11'TTo'
  +'olButton'#12'ToolButton10'#0#0#0#241#12'TPageControl'#12'PageControl1'#0#241
  +#9'TTabSheet'#9'TabSheet1'#0#0#0#0
]);


and it's doesn't work too..


(http://i253.photobucket.com/albums/hh79/acakadut/lasttets.gif)

example source code


TIA

san

gerardus

  • Jr. Member
  • **
  • Posts: 93
RE: Re: RE: visual inheritance, ancestor class not found
« Reply #6 on: December 10, 2007, 04:34:53 pm »
Hi, I downloaded your example and I get the same results (latest 0.9.25 SVN)
However, if I clear the descendant lfm by hand, it works:

inherited Form3: TForm3
end

The problem is that when saved, the lfm reverts to what you posted and it doesn't work anymore. :?

I'll try to see what goes on here. No promises, I'm very busy.

acakadut

  • New Member
  • *
  • Posts: 18
RE: Re: RE: visual inheritance, ancestor class not found
« Reply #7 on: December 10, 2007, 04:43:43 pm »
ok, thank

i sent it to bug tracker too http://www.freepascal.org/mantis/view.php?id=10394

TIA

san

acakadut

  • New Member
  • *
  • Posts: 18
visual inheritance, ancestor class not found
« Reply #8 on: January 04, 2008, 10:15:08 am »
from bug tracker :

Quote

The error message was a bit misleading.
The real error was that TCustomNotebook was not ready to be used with inherited/overidden streams and deleted the TabSheet1.
I fixed that.


http://bugs.freepascal.org/view.php?id=10394


thanks Mattias :D

 

TinyPortal © 2005-2018