Changing window size when a tabPanel is changed

Hi everyone. I’m here to pick your brains again :smile:. I’ve been writing and throwing code all afternoon on this and I just cannot find a solution. I have finally come back to my initial (and simplest!) code, which seems to work the best. Here’s my problem :
I have a resizable window containing a TabPanel locked to all sides of the window, with three tabs. Each TabPanel contains a listbox locked to all sides of their respective TabPanels. I need to let users change the size of the ListBox along with the window) in tabs 0 and 3, but not in tab 2.
I defined a 2D array, “windowDims(2,1)” property in the window properties, to hold the dimensions of the window for each TabPanel and defined the initial sizes in the “Open” event of the window. I also defined the Integer “curPanIndx” to hold the current SelectedPanelIndex.
In the TabPanel “Change” event I put this :

//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// Set the window size to the stored settings
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

curPanIndx = Window1.TabPanel1.SelectedPanelIndex

Window1.Width = windowDims(curPanIndx, 0)
Window1.Height = windowDims(curPanIndx, 1)

In the window “Resizing” event I put this :

curPanIndx = Window1.TabPanel1.SelectedPanelIndex
If curPanIndx = 1 then return // Panel 1 needs to stay the same size
… to prevent panel 2 from being resized, and in the window “Resized” even I put this :
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// Set the stored dimensions to those of the current window
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

curPanIndx = TabPanel1.SelectedPanelIndex
If curPanIndx = 1 then return // Panel 1 needs to stay the same size

windowDims(curPanIndx, 0) = Window1.Width
windowDims(curPanIndx, 1) = Window1.Height
… and that’s about it.

It works fine for the horizontal window size and if I change the sizes when on each tab, they each “remember” the width setting and recall it correctly. The height setting however doesn’t work ! If I change it in tab0 then move to tab2, tab2 has the same height as tab 0. If I change to tab 1, the height becomes that odf the initial stored state for tab1, and as from there, all tabs take on this height ! The widths continue working correctly.
I just cannot figure out what’s going on here :scream:
Could some kind soul put me right, or is what I’m trying to do, not possible ?
Thanks in advance.
P.S. If I can figure out how to do it, I’ll post a demo file. :wink:
This maybe ?
Demo

What platform?

Have a look at The ZAZ: Animation Kit .

Changing your “Change” event to store the values from the array in Integer variables before using them makes it work:

//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// Set the window size to the stored settings
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

curPanIndx = Window1.TabPanel1.SelectedPanelIndex

Var wWidth As Integer = windowDims(curPanIndx, 0)
Var wHeight As Integer = windowDims(curPanIndx, 1)

Window1.Width = wWidth
Window1.Height = wHeight

Don’t know if its a timing problem or if the values for height aren’t stored as Integer, but this way it works as expected (on macOS, not tested on Windows)…

Sorry ! Mac OS Ventura 13.4

Wow! That really does fix it ! I’m not sure I would ever have thought of doing that.
Perhaps it’s a timing issue as you say.
Thanks for your time. I have marked your answer as the solution.

Thanks for your proposal Beatrix. I WILL take a look at that, but I went to the simplest fix first, and it works :wink: