Lazarus

Free Pascal => Beginners => Topic started by: JLWest on October 23, 2020, 06:49:45 pm

Title: (Solved)Compiler Error
Post by: JLWest on October 23, 2020, 06:49:45 pm
I tried to do this in FormCreate and got an error:

  TForm1.Constraints.MaxWidth:=1475;
  TForm1.Constraints.MinWidth:=1475;
  TForm1.Width:=1475;


unit1.pas(218,23) Error: Only class methods, class properties and class variables can be referred with class references

Don't understand this error.

Can someone help.

Thanks;                   
Title: Re: Compiler Error
Post by: bytebites on October 23, 2020, 06:53:47 pm
Remove T
Code: Pascal  [Select][+][-]
  1.   Form1.Constraints.MaxWidth:=1475;
  2.   Form1.Constraints.MinWidth:=1475;
  3.   Form1.Width:=1475;
  4.  
Title: Re: Compiler Error
Post by: lucamar on October 23, 2020, 09:30:10 pm
To understand better you should read the sections about Properties (https://www.freepascal.org/docs-html/current/ref/refse40.html) and, perhaps more useful, Methods (https://www.freepascal.org/docs-html/current/ref/refse39.html) in the chapter on Classes of the Reference Guide.

What you were trying to do is to access properties as if they were class properties while they are in fact "normal" properties which need an instanced object ("self") in which to work.
Title: Re: Compiler Error
Post by: JLWest on October 23, 2020, 09:48:46 pm
Got it. I see. Thanks.
TinyPortal © 2005-2018