realbasic-betas.mbox
[Top] [All Lists]

Re: Sex, Lies, and Dynamic Control Instantiation

To: REALbasic Betas <realbasic-betas at lists dot realsoftware dot com>
Subject: Re: Sex, Lies, and Dynamic Control Instantiation
From: James Sentman <sentman at wwa dot com>
Date: Tue, 23 Mar 1999 16:39:15 -0800 (PST)
>
Hey Toby,

I'm not sure I understand the exact nature of what you are doing, but I can
describe my own dealings with a similar problem.

What I've got is a class, that has several controls associated with it.
This class needs to be created dynamically and needs to hold it's own
references to the controls. I didn't want a whole bunch of control arrays
in the window, I wanted only one array of my class which hold all the other
references.

In the window I created an invisible version of all the controls I wanted
to create dynamically. (Since you cant create them without a template
version somewhere)

It was not possible for me to create a new control except inside of the
window that held them. Referencing the window as you do below c = new
window1.canvas did not work at all.

So what I did was add a method to the window with my class as it's
parameter, then in that method I used that reference to create a new
control and store it's reference back in my class. Kind of round about I
know:) my class had several references like:

myListbox as ListboxInWindow1
myCanvas as CanvasInWindow1
etc..

then in window1 create a method like:

sub CreateControl( c as myClass)
  c.myListbox = new ListboxInWindow1
  c.myCanvas = new CanvasInWindow1
end sub

and call it from my class like:

window1.CreateControl self

this worked for me. Give it a try.

-James

>I have what might be a bug, but I want to run it by the list members to
>make sure I am not doing something wrong.
>
>The goal I have in mind is to create a control subclass which can
>instantiate new controls on the fly. Here's the play-by-play:
>
>Create a new project. In this project, create a new class and make it a
>subclass of the ListBox control. Name it "TestListBox". Create another
>new class, and make it a subclass of Canvas. Name it "TestCanvas".
>
>Drag a ListBox to the window and change its super to TestListBox. Drag a
>Canvas to the window and change its super to TestCanvas.
>
>Open the TestListBox class (not the control, but the class in the
>properties window). Type the following code into the Open Event:
>
>dim c as TestListBox
>c=new window1.canvas1
>
>When running this project, I either get a stackOverflowException or
>(more often) the machine locks up. Aren't I mean, telling you this after
>you run the program? :)
>
>Anyway, I admittedly am still learning the whole control instantiation
>process, but if I can get this to work I think it would be very
>powerful. Am I doing something wrong, or is this a bug/limitation in
>REALbasic? If it is the former, what can I do to make this work? If it
>is the latter, can this be fixed, or is there a workaround?
>
>Thanks!
>
>--
>***************************************************
>Toby W. Rush  -  trush at unoco dot edu
><A  
>HREF="http://macinsearch.com/users/tobyrush/software.html";>http://macinsearch.com/users/tobyrush/software.html</A>
>"Quondo omni flunkus, mortati."
>***************************************************
>
> - - - - - - - - - -
>REALbasic FAQ at <<A  
>HREF="http://www.mactimes.com/lowend/lists/realbasic.shtml";>http://www.mactimes.com/lowend/lists/realbasic.shtml</A>>
>
>Report REALbasic bugs and feature requests to <bugs at realsoftware dot com>
>
>For list commands, send "Help" in the body of a message to
><requests at lists dot realsoftware dot com>

______________________________________________
Identity Research and Business Filings
   (608)251-2797
   <A  HREF="http://www.idresearch.com/";>http://www.idresearch.com/</A>
   <A  HREF="http://www.bizfilings.com/";>http://www.bizfilings.com/</A>

 - - - - - - - - - -
REALbasic FAQ at <<A  
HREF="http://www.mactimes.com/lowend/lists/realbasic.shtml";>http://www.mactimes.com/lowend/lists/realbasic.shtml</A>>

Report REALbasic bugs and feature requests to <bugs at realsoftware dot com>

For list commands, send "Help" in the body of a message to 
<requests at lists dot realsoftware dot com>

<Prev in Thread] Current Thread [Next in Thread>