Listbox full screen

THis might be a stupid question but I want to have two listbox’s next too each other, every time I go full screen they ether overlap or are small.
I have tried different combinations of the lock option but nothing seems to work.
Any help would be appreciated.

Thank You in advance.

EVENT resizing
dim w as integer=self.width/2
lb1.width=w
lb2.width=w
lb2.left=w
END event

lock the left listbox at left,top,bottom and right one at right,top,bottom

I’m not expert but I think using only the locks for the listbox, you could have one that doesn’t grow to the left/right and the other grow with the window. For example, the left with lock top/bottom/left and the right listbox with all 4 locks.

I guess you could write code to check the window size and then set the position for each listbox. I’m not there yet.

Edit: Dave answered with the code needed. Thanks.

Calculate the Width/Left/Right position of the “middle sides” of your Listboxes depending on the Window Size and reposition them in the Resized (or resizing) Event of the Window. Better use the Resized Event and on Windows do not use LiveResize for this Window, to avoid performance issues.

Sascha, I didn’t know about LiveResize so I did a search and found this page. And on Notes it say:
This property no longer has any effect. Windows on all platforms always live resize.

I guess we can no longer use LiveResize on latest Xojo release.

I did a test with Dave’s code in resizing. Then I changed the code to resized.

In windows the final window is ok but I’m getting this on macOS (after resizing from a smaller window to a larger one):

Is this a bug?

Note: I had to add Self.Invalidate to the end of the Resized Event to get it right. On Windows that was not needed.

Did you set the locks as I indicated???

FYI… I wrote/tested this on macOS so no invalidate is required

Yes Dave. Sorry I didn’t make myself clear.

Your code works great if I use it on Resizing. Then just because Sascha commented about the Resized event, I put the code there instead of Resizing.

What I’m getting is the result of using the code in Resized.

Edit: Dave, can you test removing the code on Resizing and putting it on Resized event? I know it is not practical to use Resized because when you are resizing on Mac or Windows, it will look bad the Liveresize. But just to make sure it is happening and it may present some issues in some specific situations.

Edit2: Invalidate is not required if the code is used in Resizing (both Mac and Windows).
Invalidate is needed if the code is used in Resized only on Mac (I tested Windows and it works ok)

Test #2, because the docs say that LiveResize doesn’t work anymore, I created a ‘fake’ LiveResize with this code:

Sub Resizing() Listbox1.Visible = False Listbox2.Visible = False End Sub Sub Resized() listbox1.Visible = True listbox2.Visible = True Dim w As Integer = Self.Width / 2 Listbox1.Width = w - 20 listbox2.Left = w + 5 listbox2.Width = w - 20 End Sub

With this the 2 listbox disappear while resizing, and reappear when I finish resizing.

On windows it show the correct drawing. On Mac it show the same problem (above image). If I change both .Visible statements instead of the top of the Resized event to the bottom, then it works ok on Mac.

My guess is that on windows, the resized event, even if the listbox are shown, if there is a change on width or position, then the listbox is redrawn. It looks on Mac the listbox is only drawn at first with the information it has, and when the width or left position is changed, then the full listbox is not redrawn.

I don’t know if this is by design, something with the OS or a bug.

Note: I changed the code a little just to have some space between each listbox and a little space to the window’s edge.

[quote=383063:@Alberto De Poo]Test #2, because the docs say that LiveResize doesn’t work anymore, I created a ‘fake’ LiveResize with this code:

Sub Resizing() Listbox1.Visible = False Listbox2.Visible = False End Sub Sub Resized() listbox1.Visible = True listbox2.Visible = True Dim w As Integer = Self.Width / 2 Listbox1.Width = w - 20 listbox2.Left = w + 5 listbox2.Width = w - 20 End Sub
[/quote]
This is almost exactly what I do in a resizable window with two ListBoxes. I had to do this for Linux a while back and never removed it.