Recent

Author Topic: (Solved)Compiler Error  (Read 309 times)

JLWest

  • Hero Member
  • *****
  • Posts: 927
(Solved)Compiler Error
« 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;                   
« Last Edit: October 23, 2020, 09:49:48 pm by JLWest »
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

bytebites

  • Sr. Member
  • ****
  • Posts: 345
Re: Compiler Error
« Reply #1 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.  

lucamar

  • Hero Member
  • *****
  • Posts: 3215
Re: Compiler Error
« Reply #2 on: October 23, 2020, 09:30:10 pm »
To understand better you should read the sections about Properties and, perhaps more useful, Methods 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.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

JLWest

  • Hero Member
  • *****
  • Posts: 927
Re: Compiler Error
« Reply #3 on: October 23, 2020, 09:48:46 pm »
Got it. I see. Thanks.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

 

TinyPortal © 2005-2018