Resizing Controls In A Window Programmically at Runtime

I looked at the programmer’s reference and there was no mention of how to programmically resize two controls (For example two listboxes) in a window, where the one listbox you want to expand, and the other listbox you want to decrease. I looked at window.resize, but I do not think that is the way to do it. It would be nice to change the pointer to show that you can resize the controls, like two listboxes.

A little help on this would be nice. Thanks!

For runtime resizing of controls based on this type of user interaction, you need a splitter-type control that provides a handle for the mouse to grab and automatically does the resizing for you. I offer GraffitiSplitter and GraffitiActionBar for desktop, and there other alternatives out there.

For completeness, you could build this functionality yourself using the mouse events of a canvas to perform the resizing as desired.

I put a separator in the window and made it thin, but I guess that would not work to resize the two listboxes, unless I did not figure this out correctly. I guess there is no way to know if the left mouse button is depressed and your draging the control left or right. I do not think I figured this out correctly. Any help would be great.

Unfortunately not. A separator is a decoration that doesn’t have all of the necessary events to implement this functionality.

I have a variation of this splitter here: GitHub - oleman108/imSplitter: Canvas based splitter for Xojo desktop builds

Thanks! I tried it, it works if you do not set the window’s position or change the size of the window – or put the window on maximize. Is there a work-around to this problem with imsplitter?

When setting the position of the window I always set/restore the position of the splitter, too. What problem do you have with maximising?

I was looking at window event handler “Resizing”, I do not know what code I should put in there. I have two listboxes and the spliter on a window. All I did was put the code in the imsplitter’s open event… me.AddControl(Window2.Listbox1,False) and
me.AddControl(Window2.Listbox2,True). When I resize, the listboxes move away from each other and when the form is maximized, the listboxes are two to three hundred pixels from each other and only on the bottom half of the window.

I am going to change what sides of the window controls are locked in the ide, I wonder if that might fix the problem.

Solution: Changing the locking of the controls solved the problem I was having. Sorry to bother you about this, but I learned something. The IMsplitter is very nice, thank you!

1 Like
Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.