Form Action and Tab Panels

It seems that when a form is opened within a Tab Panel, the form actions are not run. It causes WindowGlobals within the form to be uninitialized and in need some trigger within the form.

I think by “when a form is opened within a Tab Panel” you mean “when a tab panel is switched.” Panorama does not consider that to be opening a form. In fact, what Panorama is doing at that time is actually copying the form objects from the original form into the form with the tab panel. It’s the same as if you created the objects with the newformobject statement.

Of course you might want to run some action when the tab panel switches. What you need to do is have the code that switches the tab panel also run whatever initialization code is needed. Most commonly that means putting (or triggering) the code from the Tab Panel object. For example, Panorama’s Preference window does this as different panels are selected. It also calls this code when the Preference window first opens, in case the default panel needs any initialization.

If you wanted to, you could put your initialization code in the form properties panel, then have your tab switching code retrieve and run it by using the getformoptions(“eventcode”,formname) function. Something like this:

let tabCode = getformoptions("eventcode","PANEL_"+panelName
execute "shortcall formOPEN return "+tabCode

I’m not sure there is a good reason to do it this way unless you are planning to also open the tab panel forms independently. And even then, you might want different code depending on whether the form was opened separately vs. in a panel. So I’ve never actually used this technique.

For that particular application my choice would probably be to set up all possible windowglobal variables in advance when the main window is opened.

I had completely missed that the Tab Panel could run code from its Procedure panel that could effect the Tab Panels. Duh!

1 Like