Recent

Author Topic: frmMain.Caption confusing  (Read 1595 times)

dietmar

  • Full Member
  • ***
  • Posts: 170
frmMain.Caption confusing
« on: August 22, 2017, 06:48:45 pm »
Hi,

the following procedure works perfectly in an other project (onCreate event):

Code: Pascal  [Select][+][-]
  1. procedure TfrmMain.FormCreate(Sender: TObject);
  2. begin
  3.   TfrmMain.Caption := 'Editor';
  4. end;
  5.  

However, in my new project the compiler doesn't like that:
unit1.pas(101,20) Error: Only class methods, class properties and class variables can be referred with class references
unit1.pas(101,20) Error: Only class methods, class properties and class variables can be accessed in class methods

If I change the code to the following:

Code: Pascal  [Select][+][-]
  1. procedure TfrmMain.FormCreate(Sender: TObject);
  2. begin
  3.   TfrmMain.Caption := 'Editor';
  4. end;
  5.  

it compiles and seems to work.

What is that? What am I missing?

Yours,
Dietmar
Lazarus 2.2.0RC1 with FPC 3.2.2 (32 Bit) on Windows10 (64Bit)

balazsszekely

  • Guest
Re: frmMain.Caption confusing
« Reply #1 on: August 22, 2017, 06:53:35 pm »
TfrmMain is the classname. You need frmMain.Caption or even better Self.Caption.

RAW

  • Hero Member
  • *****
  • Posts: 868
Re: frmMain.Caption confusing
« Reply #2 on: August 22, 2017, 06:54:50 pm »
Yes, or simply "Caption:= ... "
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1312
    • Lebeau Software
Re: frmMain.Caption confusing
« Reply #3 on: August 23, 2017, 02:49:51 am »
Code: Pascal  [Select][+][-]
  1. procedure TfrmMain.FormCreate(Sender: TObject);
  2. begin
  3.   Caption := 'Editor';
  4. end;
  5.  
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

 

TinyPortal © 2005-2018