On May 21, 2006, at 12:42 AM, Juan Salvatierra wrote:
I see. I recall now having read in the User Guide about the need of
having an instance of a control before creating new controls of
that type. But this approach does work with user created objects.
If the approach we're discussing is:
dim o as new ClassName
then it doesn't work for Control based classes, ie., classes whose
inheritance hierarchy is Object-> Control-> whatever, although Rb has
many non-Control based classes such a dictionary, picture,... which
can be directly instantiated using the above. But for Control based
classes you must first have an indexed instance(instantiated by
Window), then you can clone the instance:
dim o as new InstanceName, where o has been declared as ClassName or
InstanceName
This is seldom a problem. Just a matter of dragging controls of the
desired type onto the window and making them invisible or offscreen
if they are not part of the initial interface.
The problem is then only with RealBasic controls.
The behavior applies to classes that inherit from Rb's Control class,
yes.
I suppose your program does not have the object definition?
I doubt that the OP did, hence his recieipt of a nil object exception
in attempting to reference .graphics.
A possibility, then, would be create an user object with Canvas as
parent?
If the 'user object' is a subclass of Canvas then you would still
need an instance of it to clone as above.
Best,
Jack
El 20/05/2006, a las 19:41, CV escribió:
dim o as new canvas
Typically, the compiler will let you do this but will not return o
as a functional canvas with a graphics object. When
o.graphics.textfont = "system" is attempted a nil object exception
is raised.
The approach is to have an instance of canvas available in a
"control array", say Canvas1 with index = 0, and clone it like this:
dim o as canvas = new Canvas1
_______________________________________________
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>