Recent

Author Topic: Inherited from TButton  (Read 1606 times)

kaedusoft

  • New Member
  • *
  • Posts: 12
Inherited from TButton
« on: October 14, 2018, 07:23:19 pm »
Hi, I have a problem. I have declared a class that extends TButton:

Code: Pascal  [Select][+][-]
  1. TVisualCell= class(TButton)
  2.           private
  3.               f, c: integer;
  4.           public
  5.               constructor Crear(f, c: integer);
  6. end;
  7.  

Next, y create a new instance of this class in a variable called myButton in the FormCreate procedure of an TForm component:

Code: Pascal  [Select][+][-]
  1. MyButton:= TVisualCell.Crear(i,j);
  2. MyButton.Parent:= Self;
  3.  

So, Lazarus thows a SIGSEV error when I try to access TButton properties. ¿Why I can´t use a custom TButtom inheritance?

I want to have some new atributes on my buttons, but it wont´t work.

Thanks for your help.


howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Inherited from TButton
« Reply #1 on: October 14, 2018, 07:41:20 pm »
Without compilable code that shows the issue I may misunderstand what you are doing.
But if all the object instantiation is done via code (with no button .lfm resource), you have to use a CreateNew constructor (not a Create constructor).


Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Inherited from TButton
« Reply #2 on: October 14, 2018, 07:43:06 pm »
I guess you don't call
Code: Pascal  [Select][+][-]
  1. inherited Create();
in your own constructor Crear();.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

kaedusoft

  • New Member
  • *
  • Posts: 12
Re: Inherited from TButton
« Reply #3 on: October 14, 2018, 11:40:34 pm »
Thanks, it works fine. You save my life!!!!

 

TinyPortal © 2005-2018