Accessing subclass method

I’ve a window (window1) and by menu actions new instances of this window are created
With several instances of “window1” open, from another class I need to refer to the front window1 opened.

Dim w As Window
w = Window (0)

So w is a reference to the active front window
How can I access the methods, or objects, of that window?

If no instances used I accessed these methods as
window1.theMethod

Since w is a type of just Window, it does not know about any of the methods or properties that you may have actually added to “Window1”.

The solution is to “cast” it to the correct type like this:

[code]Dim w As Window
w = Window(0)

Dim myWindow As Window1
myWindow = Window1(w) // Cast w to Window1

myWindow.theMethod // now works[/code]

Cast it

window1(w).theMethod

Edit: or… Do what Paul suggested a few seconds ago!

THANK YOU! Paul it works.

Thank you Peter

Make sure you TEST it with IsA first just in case your app might one day have many types of windows

[code]Dim w As Window
w = Window(0)

if w IsA myWindow then
Dim myWindow As Window1
myWindow = Window1(w) // Cast w to Window1
myWindow.theMethod // now works
end if[/code]