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.

1 Like

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

1 Like

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

1 Like

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?

1 Like

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!

2 Likes

“Changing the locking of the controls”: which controls are these?

@Michel_Bujardet has done all the work for you:

Woops, there I go again, replying to a two-year-old thread, sorry.

2 Likes

Thank you for the mention of RubberViews.

Don’t feel bad about replying to old treads, though. It still can be read by people searching the forum.

Look at the Properties pane… this:
image

This control will be resized with the window (North, East, South and West)

Locking on all sides works fine for a single control. However, when several controls are placed on the window with this kind of locking, they simply collide when the window is enlarged.

It was just a screen shot taken from a Control… to illustrate where “Changing the locking of the Controls” are as the OP asked.