How to pass determined window as argument?

I need to pass a window as an argument, to another class. In VB enough just passing it using object type. What would be the correct way in Xojo?
Note - tried with Window type, but when using a method of the window, I got an error.

Sub DoSomething (w As Window)
  …
End Sub

// In your code...
DoSomething( myWindow )

[quote=72109:@Alex Silva]I need to pass a window as an argument, to another class. In VB enough just passing it using object type. What would be the correct way in Xojo?
Note - tried with Window type, but when using a method of the window, I got an error.[/quote]

Right
Window is the super class and does not have whatever method you tried to use
But your specific subclass does
So don’t pass the parameter as

Sub DoSomething (w As Window)

use the NAME of your Window as the type (since it is)

Sub DoSomething (w As MyWindow)

and then you can call the method

Oh right, I misunderstood the question. Ignore my response and use Norman’s advice.

Hi Norman. Thank you (and Kem too) for your answer.
There’s a problem to do this way.
The class that receives the window as argument is generic and should be able to have instances serving different windows. If I set the fixed type I will be taking the usability of the class.

So you want various windows that implement the same method in different ways, and another class that will call that method in whatever window its given?

If that’s right, you want to look at a Class Interface.

Humm… I got it.
All Windows with a same Class Interface…
Yes, it can work.
But if these windows have different controls? It will work?
Because I’ll need to manipulate controls too.

Thank you for the help, in advance.

The super class, Window, knows nothing about your specific subclasses nor the controls they contain
Just like it has no idea about the methods

The interface would have to provide a way to get to the controls you want to manipulate

You can access the individual controls of a window, but if you’re looking for a particular control, create a method as part of the Interface that will return it. Better, if you know what you want to do with the control (turn on a particular checkbox or put text in a certain TextField), create a method that does that and call it.

Finally, you can have a base class for your windows and put your methods, properties, etc., in there, if that works better. Create a class, set its super to Window, then set the base class of your actual windows to the new base class.

Thank you, Norman and Kem!
You help a lot!!

I am struggling with something similar. I am in WINDOW1, which contains some data in some arrays. When the user clicks a button, I open a new window, and I want the data from the originating window (WINDOW1). The problem is with the code:

Dim w as new wndChart

This code fires the open event of the new window, and since I am drawing the graph when the window opens, I cannot assign the calling window property in the class I created.

Bryan: you should start a new conversation with your question.

+1. It is not related.