I added the following line of code to the window1 open event…
Window1.Height = Window1.Height * .5
Everything works as expected. The window is 200, half it’s default height of 400
I cut this line of code and pasted it into the Resized event. And it doesn’t work correctly.
After I resize the window, the window always has 0 height.
But if I change the code in the resized event to…
Window1.Height = 200
It works correctly. The height will always be 200.
Anyone know why?
I even tried this…
Var X As Integer = Window1.Height * .5
Window1.Height = X
Height still always zero.
The resized event gets called multiple (hundreds? thousands?) of times for every “moment” while you’re resizing the window. So what’s going on here is that you’re starting with a height of 200 and through all of these event calls where things get halved, you eventually hit zero. Put a break point in the resized event and you’ll see what I mean and what’s going on.
I thought the resized event only gets called once - after window is resized.
The resizing event gets called many times.
I am using the resized, not resizing.
Ah I missed that you’re using the resized event and you’re absolutely correct! But alas the same thing happens but for a different reason…
The resized event gets called (once), you then halve the height, so the resized event gets called again, things get halved again…all the way down to zero.
If you are trying to prevent the user from resizing the window because you want to keep the width and/or height the same at all times, you have two options that don’t involve writing code:
Set the Width/Height Minimum, Maximum values to be all the same,