11 Vote

Delphi: This form of method call only allowed for class methods

Question by Guest | 2012-09-07 at 19:07

I have two units in Delphi, each corresponding to a window in my program. In the first window, I defined a procedure, that I would like to call in the second window.

My first approach to call the procedure was the following:


However, with this approach, Delphi could not find the procedure, so I thought, I have to precede the name of the form to tell Delphi where the procedure is defined:


However, this approach also does not do it. The program compiles, but when you open the program, the following error message occurs, with which I can not do anything:

This form of method call only allowed for class methods

I have already tried to define the procedure in the public section and such things, but it just is not working. Can someone help me?

2Best Answer2 Votes

TForm1 is only the type, so almost a description of how your form looks. Therefore, you can not call a procedure from this.

Try it with the following approach:


Somewhere at the beginning of your unit, there is written "Form1: TForm1". This means, that "Form1" is of the type "TForm1". And therefore, procedures can only be called from "Form1".
2012-09-09 at 23:16

ReplyPositive Negative

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own article on askingbox.com. That’s how it’s done.