[DUG] basic question

Myles Penlington myles at ams.co.nz
Wed Jul 25 15:04:43 NZST 2007


Yes you can do this. In this case the Self pointer is nil, and any
reference to any property on the from B will give a AV, but if no
references to class instance properties, then in effect you have a class
function.

 

Is not very good programming. Does not really make sense unless you want
to confuse someone!

 

Myles.

 

From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
On Behalf Of ani chakra
Sent: Wednesday, 25 July 2007 02:58
To: delphi at delphi.org.nz
Subject: [DUG] basic question

 

Hi,

Is it possible to call a method of a class without creating a object of
it, even if the method is not a class function in Delphi ? I wrote the
below code just to test -

1. Created a simple form A and a button on it. 
2. Created another simple form B, written a procedure in it as -
    FormB.Execute;
    begin
      ShowMessage("xyz");
    end;
3. Commented out auto creation of FormB in application.
4. On Button Click in FormA I called the Execute of FormB and it worked
perfectly okay. 

What could be the reason for this? I had the idea that either I need to
create an object before calling any method or I need to declare a class
function.

In the above steps when I am trying to call Show in Execute function of
Form B I got Access violation which is perfectly fine according to the
above statement. 

May be I am missing something simple here, but any pointers will be
great. This was done in D2005 and it's win32 app.

Thanks
-Ani



Attention:
This communication is confidential and may be legally privileged.  If you are not the intended recipient, please do not use, disclose, copy or distribute it, other than to return it to us with your confirmation that it has been deleted from your system.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.adventureeducation.co.nz/pipermail/delphi/attachments/20070725/671cbfc9/attachment.html


More information about the Delphi mailing list