I managed to "solve" my problem with the hints provided by Dennis,
Karen and Jack
My window (with its StaticText2) was called WinSeaAna
The canvas it contained was called AnaCanvas.
In the MouseDown event of the canvas(AnaCanvas), I now have the
following code which works
If Me.Window IsA winSeeAna Then
winSeeAna(Me.Window).StaticText2.text = "frog"
End
This WORKED!
The original problem that I was dealing with was clicking in the
canvas and wanting to be able to drag something there AND to leave a
text message in a static text control of the containing window.
First, I though that I would be able to get to message to the
containing window by capturing the MouseDown in the window Event AS
WELL AS the Canvas MouseDown event.
That worked fine until I added the demand that dragging of something
was required. That meant that the MouseDown event in the Canvas had
to return True and then the Window MouseDown event no longer got
fired off. Before, I had returned False and I was OK because under
those circumstances the MouseDown event in the Window also fired off
and I could use that to set the static text.
That is when I had problems. I spent some time trying to figure out
how to get the MouseDown Event to the Window even though it was
"swallowed up" by the Canvas when I returned True in the MouseDown
event. I thought that perhaps I could do this by setting off a timer
and assigning a value to some global variable which would be
transfered to the static text but that really seemed such a kludge
that I thought I would write the NUG first. The latter approach
worked for me because the the contributions acknowledged above.
_________________________
I am interested in trying to understand other approaches. My solution
would appear to be "rigid" in that I am assuming that every window I
might place this canvas is a WinSeaAna type of window.
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.
I must say that I am confused as to how you can create a staticText
property in a CANVAS and specify where it is to appear on the WINDOW
that contains the canvas.
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.
I think that in essence that is what I am doing but Karen seem to be
correctly saying that I really did not have to bother with creating a
"window" property of the canvas. Me.Window was already an reference
to the containing Window.
Thanks for chiming in.
_______________________________________________
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>