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 ;

But you don't need a pointer type. In fact, you're not using it as a pointer at all! You could just as well declare ProgressBar1Ptr as a LongInt, or a Single, and that code would work.


If you want to refer to a TProgressBar, then declare a variable of type TProgressBar. That variable is an object *reference*. It does not hold a copy of the object itself. In that sense, the variable is _already_ a pointer.

(1) var ProgressBar1Ptr: TProgressBar;
(2) ProgressBar1Ptr := ProgressBar1;
(3) ProgressBar1Ptr.Position := CalculatedBarPosition;

When you do those three steps, you will in fact be operating on the same TProgressBar instance as you would have been had you operated directly on the ProgressBar1 variable. They both "reference" the same TProgressBar instance.

--
Rob

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

Reply via email to