There are a whole bunch of approaches you can take to this problem.  The
main question you want to answer, though, is how tightly coupled do you want
the canvas and the window to be?  Do you want to be able to use your
AnaCanvas on any arbitrary window?  Or do you have a more rigid layout in
mind, where the window is going to always be the same?

If you want to use the AnaCanvas class in any arbitrary window, you should
either give your canvas a StaticText property, that you set in the
instance's Open event, or, even better, give the AnaCanvas a DisplayText
event, that you can provide code for in the instance.

RB windows do have a Control array and a ControlCount property that you can
use to iterate through all the controls in the window, if you desire.  You
could look for a StaticText control with a particular name that way.

If you want a more rigid layout, then you might want to subclass the window,
so you can access it's controls more freely.  Then you would cast the
canvas' Window property to your subclass in order to access it's predefined
controls.

HTH,
Tim


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of
> William Squires
> Sent: Monday, January 08, 2007 5:02 PM
> To: REALbasic NUG
> Subject: Re: Canvas Class Instance Knowing Its Window
>
>
>    You'll have to provide a socket (object-reference property) in
> your custom canvas if you want to manipulate another control's state
> (properties) or call any of its methods. I don't believe RB windows
> have a global (for the window) control list (or other iterable
> container) object that you can get to. It's much like making an
> outlet in ObjC/Cocoa.
>
> On Jan 8, 2007, at 1:13 PM, Robert Livingston wrote:
>
> > I have a canvas class (AnaCanvas) that sits in a window.
> >
> > I have experimented with that canvas class having a property
> > (windowInhabited) and that property is the window in which it lives
> >
> > When the window opens (the window that contains the canvas instance
> > myAnaCanvas), the canvas instance windowInhabited.property is
> > assigned the window
> >
> > Using that concept, I am able to get the width and height of the
> > window, when I want, within methods of the canvas class.
> >
> > However, I would like to have the canvas control have access to
> > other window controls (in my case a static text box)
> > That does not seem to work.
> >
> >
> > Open Event of  mainWindow
> >
> > Self.myAnaCanvas. windowInhabited = Me
> >
> >
> > _________________
> >
> >
> > Some method of the AnaCanvas
> >
> >
> > Dim widthValue As Integer
> >
> > widthValue = Me.windowInhabited.Width 'this works
> >
> > BUT
> >
> > Me.windowInhabited.staticText1.Text = "Frog"
> >
> > Does NOT work.
> >
> >
> >
> > Why?
> > _______________________________________________
> > Unsubscribe or switch delivery mode:
> > <http://www.realsoftware.com/support/listmanager/>
> >
> > Search the archives of this list here:
> > <http://support.realsoftware.com/listarchives/lists.html>
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.432 / Virus Database: 268.16.7/619 - Release Date:
> 1/7/2007 6:29 PM
>
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.7/619 - Release Date: 1/7/2007
6:29 PM

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to