I have a window that does all the heavy lifting. Other windows set module properties and show the window. The window reads the properties and executes sql. I also use a module property Window (which_window) that is assigned to the window that called the heavy lifting window. When the heavy lifting window is done, it shows the window that had it do the work (which_window) and that works. But i also want to change the value of a control on the window is now shown. I can do that with something like frmMyBigFatWindow.lstItems.enabled=true. But it needs to be variable and which_window.lstItems.enabled=true does not work. is there a way to access controls on the window specified by my which_window property?
You certainly can reach in to a window from the outside like this, but I would recommend against it.
which_window needs to be defined
As MyWindowName not
As Window and you will have access to the controls.
Alternately, you can cast the window to the appropriate type if you have more than one kind of window to deal with.
if which_window IsA frmMyBigFatWindow then frmMyBigFatWindow(which_window).lstItems.enabled = true elseif which_window IsA frmSomeOtherWindow then frmSomeOtherWindow(which_window).lstOtherList.enabled = true end
I’m new to Xojo (but not to programming), your first solution
As MyWindowName i don’t see that as an option in the property type? I only see Window. I’d rather go this route if possible, but your second solution would work although i will have 30+ windows talking to it. On a side note, i tried writing
somewhere else in the code and it error out so i just figured Xojo didn’t support it lol.
Property type is a text field, you type it out. Auto Complete should suggest it after a few letters.
I’m running 2020r1 on Windows. I go into Module and make a new Property. I call it which_window and for type i type in my… there are 4 options in the auto-complete, all are MySQL related. If i type win… i get Window, Window.Locations and Windows.Type. Below type is Default and Scope. Am i in the right spot?
You’re in the right spot. You might have to just type the whole thing in if autocomplete isn’t working right.
That said, if you have a bunch of windows to deal with, you might want to look into a Class Interface. Each window can implement the interface and your property can be of type myInterface. Add a method to the interface like
Then you can call it directly as which_window.EnableList
You can give each window a unique implementation of the method.