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:
MyProcedure(Sender);
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:
TForm1.MyProcedure(Sender);
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?
Related Topics
Delphi Error with Form.Hide and Form.Show: This Form of Method Call only allowed for Class Methods
Open Question | 1 Answer
Delphi/Lazarus: Class with different Create Methods
Question | 1 Answer
Delphi/Lazarus: Abort ModalResult Button and prevent closing Form
Question | 1 Answer
Delphi/Lazarus: ShowModal Result
Tip | 0 Comments
Send form input as an array to PHP script
Tip | 0 Comments
HTML5 Validator: Bad value "" for attribute "action" on element "form": Must be non-empty
Question | 2 Answers
Delphi: Quit program with ESC key
Tip | 1 Comment
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.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
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