Another thing you can do is to use a class interface, and add that interface
to both windows. It's a lot less messy than using IsA and multiple dims,
duplicate code, etc.

Create a class interface, add that interface to both windows' interface list
(let's name it "MyWindowInterface"). Then, open up the class interface and
add a sub "DoSomething". REALbasic should now require you to have the same
"DoSomething" method in both MyDocumentWindow and MyPalletteWindow
(although, each window can have different code -- all that matters is the
same declaration).

Then, instead of referring to either window as "Window", refer to it as
"MyWindowInterface". For example:

Sub SomeFunctionThatIsWindowIndependant(Param As MyWindowInterface)
 MyWindowInterface.DoSomething()
End Sub

Cheers.


On 5/18/06, Russ Jones <[EMAIL PROTECTED]> wrote:

Yes, you can do that. But it is maybe not quite as straightforward as
you might think at first blush. Because the system won't think that
the properties and methods are the same.

if you have a property TheWindow as Window
you can have it point to either MyDocumentWindow or MyPaletteWidow.
So far, so good.

Because TheWindow is defined as Window, you can refer to all the
methods and properties that apply to Window.
But if you want to refer to properties or methods that are defined by
MyDocumentWindow or MyPaletteWidow, you need to know which one.

So, for example:

dim mdw as new MyDocumentWindow
dim mpw as new MyPaletteWidow
dim TheWindow as Window
'...
TheWindow = mdw '(maybe)
'...

if TheWindow isa MyDocumentWindow then
// code using mdw
elseif TheWindow isa MyPaletteWindow then
// code using mpw
end

HTH

Russ

On May 18, 2006, at 7:03 PM, FreeFL wrote:

> Hello!
>
>
> I have built a window, set its frame property as document, its name
> is MyDocumentWindow.
> I have made a clone of this and set the frame propery to global
> palette, its name is MyPaletteWindow.
> So now I have two "versions" of the same window. I would like to
> use either one of them, with the same reference in my globals module.
>
> Is it possible to use in code a reference, say TheWindow, to a
> window and have this reference set to point to either
> MyDocumentWindow or MyPaletteWindow, assuming all other properties
> and methods are exactly the same in both ?
>
> Thanks!
>
_______________________________________________
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>




--
Keith Bennett, tA-Kane
Software developer and Macintosh enthusiast

Free iPods!!!
http://www.freeiPods.com/?r=10867472
_______________________________________________
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