Delphi: This form of method call only allowed for class methods
Question by Guest | Last update on 2022-07-27 | Created on 2012-09-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: Event Order of a Form - From OnCreate to OnDestroy
Info | 1 Comment
Send HTML5 Canvas as Image to Server
Tutorial | 0 Comments
Delphi Error with Form.Hide and Form.Show: This Form of Method Call only allowed for Class Methods
Open Question | 1 Answer
How to get rid of annoying telemarketing calls once and for all
Tip | 0 Comments
Send Form Input as an Array to PHP Script
Tip | 0 Comments
How to resize Image before Upload in Browser
Tutorial | 13 Comments
CSS: Include CSS Stylesheets in HTML
Tutorial | 0 Comments
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, something like a description of how your form looks like. Therefore, you can not call a procedure from this construction plan.
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", not "TForm1".
Last update on 2022-07-27 | Created on 2012-09-09