because I am using it from a method of it.
If you are in a method of a class, you can refer to the class with "self".
But self is implied.
given a method:
procedure TMyClass.MyMethod;
begin
Width := 5;
end;
If TMyClass has a member or property named "Width" then "Width" is the
same as "Self.Width"
If TMyClass does not have a member or property named "Width", then Width
is a global variable.
Look at Pascal Scoping.
You should not reference an instance of a class from within a method of
the class:
type
TMyClass = class
xyzzy : integer;
procedure plugh;
procedure foo;
end;
var
InstOfMyClass : TMyClass;
implementation
procedure TMyClass.plugh;
begin
InstOfMyClass.xyzzy := 9; // THIS IS NOT GENERALLY A GOOD THING TO DO
end;
procedure TMyClass.foo;
begin
xyzzy := 9; // this is a good thing ("Self." is implied)
end;
if we had
var
InstOfMyClass : TMyClass;
InstOfYourClass : TMyClass;
then:
InstOfMyClass,plugh; //sets its own xyzzy (InstOfMyClass.xyzzy;)
InstOfYourClass.plugh; //sets InstOfMyClass.xyzzy;
InstOfMyClass,foo; //sets its own xyzzy (InstOfMyClass.xyzzy;)
InstOfYourClass.foo; //sets its own xyzzy (InstOfYourClass.xyzzy;)
Please feel free to ask more questions.
Doug
Nesler, Thomas J wrote:
> EmailViewerFrm is the form's name (like Form1).
>
> I notice that you are not calling the width by the Forms name like this:
>
> Form1.Width
>
> Why is that?
>
> BTW, When I changed my code to remove the form name, everything worked
> fine...:-)
>
> Thanks!
>
> Tom Nesler
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
> Behalf Of Doug Hale
> Sent: Tuesday, November 24, 2009 3:37 PM
> To: [email protected]
> Subject: Re: [delphi-en] Resizing a form at Runtime
>
> This code works:
> unit Unit1;
> interface
> uses
> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
> Forms,
> Dialogs;
> const
> CustomerFlag = False;//True;
> type
> TForm1 = class(TForm)
> procedure FormShow(Sender: TObject);
> private
> public
> end;
> var
> Form1: TForm1;
> implementation
> {$R *.dfm}
> procedure TForm1.FormShow(Sender: TObject);
> begin
> If CustomerFlag = True then
> Width := 864
> else
> Width := 700;
> end;
> end.
> So, what is "EmailViewerFrm" and does it exist?
>
> Doug
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Nesler, Thomas J wrote:
>
>> I have a form that has two sets of controls. I would like to hide one
>> set when I start the form one way and another set when call the
>>
> form
>
>> another way. What I would like to do is resize the form to hide the
>> controls when I call the form (showModal). Unfortunately, wherever I
>> place the code in my form calling routine I get an access
>>
> violation.
>
>>
>>
>> Can someone suggest the best way to do this?
>>
>>
>>
>> Here is my code:
>>
>>
>>
>> If CustomerFlag = True then EmailViewerFrm.Width := 864
>>
>> else EmailViewerFrm.Width := 700;
>>
>>
>>
>> I tried calling this from the OnShow Event, the OnCreate Event, and
>>
> the
>
>> OnActivate Event.
>>
>>
>>
>> Thanks in advance!
>>
>>
>>
>> Tom Nesler
>>
>>
>>
>>
>>
>> [Non-text portions of this message have been removed]
>>
>>
>>
>> ------------------------------------
>>
>> -----------------------------------------------------
>> Home page: http://groups.yahoo.com/group/delphi-en/
>> To unsubscribe: [email protected]! Groups
>>
> Links
>
>>
>>
>>
>>
> ------------------------------------------------------------------------
>
>> No virus found in this incoming message.
>> Checked by AVG - www.avg.com
>> Version: 8.5.425 / Virus Database: 270.14.80/2523 - Release Date:
>>
> 11/24/09 07:46:00
>
>>
>>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
> -----------------------------------------------------
> Home page: http://groups.yahoo.com/group/delphi-en/
> To unsubscribe: [email protected]! Groups Links
>
>
>
>
>
> ------------------------------------
>
> -----------------------------------------------------
> Home page: http://groups.yahoo.com/group/delphi-en/
> To unsubscribe: [email protected]! Groups Links
>
>
>
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.425 / Virus Database: 270.14.80/2523 - Release Date: 11/24/09
> 07:46:00
>
>