Hi Gerry,

No, you don't need to do that. You don't need to declare a new pointer 
for to point out those components. As i said before, when you are 
working with Delphi objects, you want or not, you are using pointers. 
Delphi is hiding the implementation details from the programmers so you 
don't need to know that you are working with pointers.

For example :

Unit1 (Main unit)

- has a form named Form1
- there is an edit control on it Edit1

Unit2

- Unit1 is into your uses clause

Now when you want to access to the Edit1 component from the Unit2, you 
just need to type :

  Form1.Edit1.Text := 'I call from the Unit2';

When you want to call the ProgressBar1 from the Unit1, you should add 
the Main, to your uses clause and call directly :
 
  MainForm1.ProgressBar1.Position := CalculatedBarPosition.

Pointers are not using like this. When you create an object variable, 
you can point out an another same typed object. For example, you can do 
something like this into the Unit1 :

var
  MyProgress := TProgressBar;
..

for i := 0 to MainForm1.ComponentCount - 1 do
begin
   if (MainForm1.Components[i] is TProgressBar) then // is this a 
progress bar ?
  begin
    MyProgress := TProgressBar(MainForm1.Components[i]); // now your 
local variable points out the MainForm1's one of the progress bar
    MyProgress.Position := CalculatedBarPosition;  // now you use like 
it's a local
  end;
end;

Above example looks like MyProgress copied all the data includes by 
MainForm1.ProgressBarX, but it's not. This is what i mentioned before. 
Now your MyProgress knows the address of MainForm1's ProgressBarX, so, 
now you can do whatever you want with this address.

Lets wonder that you have a beautiful house near the beach. One day when 
you are talking with one of your best friend, you wanted to talk about 
your beatiful house which is near the sea. You said tons of great things 
about it and finally he said that he wants to visit your home so he 
wants to know where is it. What is the best way ? Would you bring the 
home near him ? or Would you give him its address ?  of course you would 
give the address :)) This is where we need to use pointers.

Final word is, you don't need to create a pointer for to reference to 
the components.

HTH,

Oktay Sancak

Gerry Bendixen wrote:

>Obviously I was not so clear on my goals.
>Here's an attempt to provide an example, stripped of all non-essential 
>details.  Hopefully I present it correctly.
>I have a 'main' unit (Main.pas) with a form.  On the form is ProgressBar1 (a 
>TProgressBar component)
>I have a 'uses' unit (Unit1.pas) that does processing and the goal is to show 
>the progress of this processing by updating the ProgressBar on the main form.
>
>(1) Type PProgressBar = ^TProgressBar ;  //Declare pointer type
>(2)  Var  ProgressBar1Ptr : PProgressBar ;  //Declare pointer variable
>(3)  ProgressBar1Ptr := PProgressBar(ProgressBar1) ;  //Assign value to pointer
>(4)  TProgressBar(ProgressBarPtr).Position := CalculatedBarPosition ;
>
>Line 1 and 2 are visible to both Main and Unit1.
>Line 3 is executed in Main to set the value to the pointer.
>Line 4 is executed in Unit1 is update the position of the progress bar.
>
>Again, thanks in advance for your attention and any hints,
>Gerry B.
>
>_______________________________________________
>Delphi mailing list -> [email protected]
>http://www.elists.org/mailman/listinfo/delphi
>
>
>  
>


__________________________________________________

Do You Yahoo!?

Everything you'll ever need on one web page

from News and Sport to Email and Music Charts

http://uk.my.yahoo.com


_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi
AdmID:40DA4B5E2531C79CC94A9611634913FE
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to